Problem:


カップゲーム

3 つのカップがふせて置かれています。カップの置かれている場所を、順に A,B,C と呼ぶことにします。最初は A に置かれているカップの中にボールが隠されているとします。カップの位置を入れ替えると、中に入っているボールも一緒に移動します。

入れ替える２つのカップの位置を読み込んで、最終的にどの場所のカップにボールが隠されているかを出力するプログラムを作成してください。

Input

入れ替える２つのカップの位置が順番に複数行にわたり与えられます。各行に、入れ替える２つのカップの位置を表す文字（A, B, または C）がカンマ区切りで与えられます。

入れ替える操作は 50 回を超えません。

Output

ボールが入っているカップの場所（A, B, または C）を１行に出力します。

Sample Input

B,C
A,C
C,B
A,B
C,B

Output for the Sample Input

A



Sample input:
B,C
A,C
C,B
A,B
C,B


Sample output:
A

Submission status: Accepted

Solution code:
# coding=utf-8

###
### for atcorder program
###

import sys
import math

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

#abc list
#abc = [chr(ord('a') + i) for i in range(26)]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

def get_input():
    N = []
    while True:
        try:
            N.append(input())
            #N.append(int(input()))
            #N.append(float(input()))
        except EOFError:
            break
    return N

def conv(s):
    num = 2
    if s == 'A':
        num = 0
    elif s == 'B':
        num = 1
    return num

N = get_input()
C = [1, 0, 0]

for i in N:
    a, b = [x for x in i.split(',')]
    a = conv(a)
    b = conv(b)
    C[a], C[b] = C[b], C[a]

if C[0] == 1:
    print("A")
elif C[1] == 1:
    print("B")
else:
    print("C")

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    
    pos = ["o","x","x"]
    ALF = ["A","B","C"]

    while True:
        try:
            s1,s2 = input().split(",")

            if s1 in ["A","B"] and s2 in ["A","B"]:
                pos[0],pos[1] = pos[1],pos[0]
            elif s1 in ["A","C"] and s2 in ["A","C"]:
                pos[0],pos[2] = pos[2],pos[0]
            elif s1 in ["B","C"] and s2 in ["B","C"]:
                pos[1],pos[2] = pos[2],pos[1]

        except EOFError:
            break
    print(ALF[pos.index("o")])

Submission status: Accepted

Solution code:
Q={"A":1,"B":0,"C":0}
while True:
    try:
        N=list(input().split(","))
        Q[N[0]],Q[N[1]]=Q[N[1]],Q[N[0]]
    except:
        for v,m in Q.items():
            if m==1:
                print(v)
        break

Submission status: Accepted

Solution code:
n = [0,1,2]
d = dict(zip(["A","B","C"],[0,1,2]))
d_ = dict(zip([0,1,2],["A","B","C"]))
while(1):
    try:
        a,b = input().split(",")
        temp = n[d[a]]
        n[d[a]] = n[d[b]]
        n[d[b]] = temp
    except EOFError:
        print(d_[n.index(0)])
        break

Submission status: Accepted

Solution code:
ball = 'A'
while 1:
    try:
        cuplist = list(map(str, input().split(",")))
        if cuplist == ['']:
            break
    except:
        break

    if cuplist[0] == ball:
        ball = cuplist[1]
    elif cuplist[1] == ball:
        ball = cuplist[0]

print(ball)

Submission status: Accepted

Solution code:
A, B, C = 1, 2, 3
while True:
    try: n = input().split(',')
    except:
        if A == 1:
            print('A')
        elif B == 1:
            print('B')
        else:
            print('C')
        break
    if 'A' in n and 'B' in n:
        A, B = B, A
    elif 'A' in n and 'C' in n:
        A, C = C, A
    elif 'B' in n and 'C' in n:
        B, C = C, B

Submission status: Runtime Error

Solution code:
ball = 0
while True:
 try:
  a, b = map(lambda x: ord(x) - ord("A") raw_input().strip().split(","))
  if (a == ball):
   ball = b;

print chr(ball + ord("A"))

Submission status: Runtime Error

Solution code:
ball = 0
while True:
 try:
  a, b = map(lambda x: ord(x) - ord("A") raw_input().strip().split(","))
  if (a == ball):
   ball = b;
 except:
  break;

print chr(ball + ord("A"))

Submission status: Runtime Error

Solution code:
let () =
  let rec read pos =
    try let l = read_line ()
                |> Str.split (Str.regexp_string ",")
        in
        if (List.nth l 0) = pos then
          read (List.nth l 1)
        else if (List.nth l 1) = pos then
          read (List.nth l 0)
        else
          read pos
    with End_of_file -> pos
  in print_endline (read "A")
;;

Submission status: Runtime Error

Solution code:
import sys

d = {'A': 1, 'B': 0, 'C': 0}

for line in sys.stdin:
    a, t = line.split(',')
    d[a], d[t] = d[t], d[a]

for k, v in d.items():
    if v:
        print(k)

Submission status: Runtime Error

Solution code:
import sys

d = {'A': 1, 'B': 0, 'C': 0}

_input = sys.stdin
for line in _input:
    a, t = line.split(',')
    d[a], d[t] = d[t], d[a]

for k, v in d.items():
    if v:
        print(k)

Submission status: Runtime Error

Solution code:
import sys

d = {'A': 1, 'B': 0, 'C': 0}

for line in sys.stdin:
    a, t = line.split().split(',')
    d[a], d[t] = d[t], d[a]

for k, v in d.items():
    if v:
        print(k)

Submission status: Runtime Error

Solution code:
import sys

d = {'A': True, 'B': False, 'C': False}

for line in sys.stdin:
    a, t = line.split().split(',')
    d[a], d[t] = d[t], d[a]

for k, v in d.items():
    if v:
        print(k)

Submission status: Runtime Error

Solution code:
d = {'A': True, 'B': False, 'C': False}

while True:
    try:
        line = input()
    except:
        break
    a, t = line.split().split(',')
    d[a], d[t] = d[t], d[a]

for k, v in d.items():
    if v:
        print(k)

Submission status: Runtime Error

Solution code:
import sys

d = {'A': True, 'B': False, 'C': False}

for line in sys.stdin:
    a, t = line.split(',')
    d[a], d[t] = d[t], d[a]

for k, v in d.items():
    if v:
        print(k)

Submission status: Runtime Error

Solution code:
Ans = "A"
while True:
    
    Pos = list(map(str,input().split(",")))
    if Pos == ['']:
        print(Ans)
        break
    if Ans in Pos:
        Ans = Pos[((Pos.index(Ans)) + 1) % 2]

Submission status: Runtime Error

Solution code:
Ans = "A"
while True:
    try:
        if Ans in Pos:
            Ans = Pos[((Pos.index(Ans)) + 1) % 2]
    except EOFError:
         print(Ans)
            break

Submission status: Runtime Error

Solution code:
Ans = "A"
while True:
    try:
        if Ans in Pos:
            Ans = Pos[((Pos.index(Ans)) + 1) % 2]
    except:
         print(Ans)
            break

Submission status: Runtime Error

Solution code:
cups=[True, False, False]
for line in sys.stdin:
    l= line.strip().split(",")
    if "A"in l and "B"in l:
        cups[0], cups[1]= cups[1], cups[1]
    elif "A"in l and "C"in l:
        cups[0], cups[2]= cups[2], cups[0]
    else:
        cups[1], cups[2]= cups[2], cups[1]
for i in range(3):
    if cups[i]:
        if i== 0:
            print('A')
        elif i== 1:
            print('B')
        else:
            print('C')

Submission status: Runtime Error

Solution code:
d = {"A":1, "B":0, "C":0}
while True:
    try:
        swap1, awap2 = input().split(",")
        d[swap1], d[swap2] = d[swap2], d[swap1]
    except:
        break
print(d.keys()[d.values().index(1)])

Submission status: Runtime Error

Solution code:
p = "A"

while True:
    try:
        s, t = raw_input().split(",")
    except EOFError as e:
        break
    if s == p:
        p = t
    elif t == p:
        p = s

print("%s" % (chA, ))

Submission status: Runtime Error

Solution code:
ls = {"A":0, "B":1, "C":2}
cup = [1,0,0]
while 1:
    try:
	x, y = map(str,	raw_input().split(","))
	tmp = cup[ls[x]]
	cup[ls[x]] = cup[ls[y]]
	cup[ls[y]] = cup[ls[x]]
    except:
        break
p = cup.index(1)
if c == 0:
    print "A"
else:
    print "B" if c == 1	else "C"