#971. 老魔杖
老魔杖
说明
仔仔 在一周内看完八部哈利波特电影之后,体会到了老魔杖的威力之大。如果老魔杖目前效忠于巫师 A,而巫师 A 被巫师 B 击败,则老魔杖会开始效忠于巫师 B。
现在若干位巫师将进行 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>N 次决斗。已知老魔杖最初效忠的巫师和 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>N 次决斗的结果,求:
- 在 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>N 次决斗之后,老魔杖效忠的对象。
- 老魔杖曾经效忠于几位巫师?
输入格式
第一行输入一个大写字母,表示老魔杖最初效忠的巫师。
第二行输入整数 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>N,表示决斗的次数。
接下来的 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>N 行中的第 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>i 行,输入两个用空格分开的大写字母 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>�</mi><mn>1</mn></msub></mrow></semantics></math>Z1 和 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>�</mi><mn>2</mn></msub></mrow></semantics></math>Z2,表示第 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>�</mi></mrow></semantics></math>i 次决斗,巫师 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>�</mi><mn>1</mn></msub></mrow></semantics></math>Z1 击败了巫师 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>�</mi><mn>2</mn></msub></mrow></semantics></math>Z2。
输出格式
第一行输出一个大写字母,表示问题 1 的答案。
第二行输出一个整数,表示问题 2 的答案。
样例
A
3
B A
C B
D A
C
3
提示
样例解释
老魔杖最初效忠于巫师 A。第一次决斗之后,老魔杖开始效忠于 B。第二次决斗之后,老魔杖开始效忠于 C。此后的第三次对老魔杖的效忠对象无影响。
数据规模与约定
对于 <math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>100</mn><mi mathvariant="normal">%</mi></mrow></semantics></math>100% 的数据,<math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mo>≤</mo><mi>�</mi><mo>≤</mo><mn>100</mn></mrow></semantics></math>1≤N≤100。