Language: C++

currentPlace = []
array = []
height = 0
start = 0
abs_len = 0

def get_input():
    array = []
    N = []
    while True:
        try:
            str1,str2,str3 = input().split()
            int1,int2,int3 = int(str1),int(str2),int(str3)
            if int1 == 0 and int2 == 0 and int3 == 0:
                break
            yield [int1,int2,int3]
        except EOFError:
            break

if __name__ == '__main__':
    array_total = list(get_input())
    #print(array)
    while True:
        #print("start???{0}".format(start))
        height = array_total[start][1]
        who = array_total[start][2]
        array = array_total[start:start+height+1]
        #print(array)
        #print("height???{0}".format(height))

        #print("?????????{0}".format(array[start]))
        #??¢????????????????????????????????????
        currentPlace = [height,who]
        #print("??±???array???{0}".format(array))
        del array[0]
        array.sort(key = lambda x:x[0],reverse = True)
        #print(array)

        for i in range(len(array)):
            currentPlace[0] = int(array[i][0])
            #print("?????¨?????????{0}".format(currentPlace))
            #print(currentPlace)
            if (int(array[i][0]) == currentPlace[0]
            and (int(array[i][1]) == currentPlace[1]
            or int(array[i][2]) == currentPlace[1])):
                if int(array[i][1]) == currentPlace[1]:
                    currentPlace[1] = int(array[i][2])
                else:
                    currentPlace[1] = int(array[i][1])
                #print("?????¨?????????{0}????§????".format(currentPlace))

        print(currentPlace[1])
        #?¬??????¢???????????????????????????start?????£??\

        start = start + height + 1
        abs_len = abs_len + height + 1
        #print(abs_len)
        del array[:]

        if abs_len + 1 > len(array_total):
            break

Compiler output:
a.cc:20:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   20 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:22:6: error: invalid preprocessing directive #print
   22 |     #print(array)
      |      ^~~~~
a.cc:24:10: error: invalid preprocessing directive #print
   24 |         #print("start???{0}".format(start))
      |          ^~~~~
a.cc:28:10: error: invalid preprocessing directive #print
   28 |         #print(array)
      |          ^~~~~
a.cc:29:10: error: invalid preprocessing directive #print
   29 |         #print("height???{0}".format(height))
      |          ^~~~~
a.cc:31:10: error: invalid preprocessing directive #print
   31 |         #print("?????????{0}".format(array[start]))
      |          ^~~~~
a.cc:32:10: error: invalid preprocessing directive #?
   32 |         #??¢????????????????????????????????????
      |          ^
a.cc:32:12: error: extended character ¢ is not valid in an identifier
   32 |         #??¢????????????????????????????????????
      |            ^
a.cc:34:10: error: invalid preprocessing directive #print
   34 |         #print("??±???array???{0}".format(array))
      |          ^~~~~
a.cc:37:10: error: invalid preprocessing directive #print
   37 |         #print(array)
      |          ^~~~~
a.cc:41:14: error: invalid preprocessing directive #print
   41 |             #print("?????¨?????????{0}".format(currentPlace))
      |              ^~~~~
a.cc:42:14: error: invalid preprocessing directive #print
   42 |             #print(currentPlace)
      |              ^~~~~
a.cc:50:18: error: invalid preprocessing directive #print
   50 |                 #print("?????¨?????????{0}????§????".format(currentPlace))
      |                  ^~~~~
a.cc:53:10: error: invalid preprocessing directive #?
   53 |         #?¬??????¢???????????????????????????start?????£??\
      |          ^
a.cc:53:11: error: extended character ¬ is not valid in an identifier
   53 |         #?¬??????¢???????????????????????????start?????£??\
      |           ^
a.cc:53:18: error: extended character ¢ is not valid in an identifier
   53 |         #?¬??????¢???????????????????????????start?????£??\
      |                  ^
a.cc:53:56: error: extended character £ is not valid in an identifier
   53 |         #?¬??????¢???????????????????????????start?????£??\
      |                                                        ^
a.cc:57:10: error: invalid preprocessing directive #print
   57 |         #print(abs_len)
      |          ^~~~~
a.cc:1:1: error: 'currentPlace' does not name a type
    1 | currentPlace = []
      | ^~~~~~~~~~~~