list map int input split list map int input split while or or 10 for i

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
A = list(map(int,input().split()))
B = list(map(int,input().split()))
n = 0
while A != [] or B != [] or n < 10**6:
#for i in range(2):
print(A[0])
print(B[0])
print(A)
print(B)
if A[0] == 0 and B[0] == 9:
A.append(A[0])
A.append(B[0])
B.pop(0)
A.pop(0)
elif B[0] == 0 and A[0] == 9:
B.append(B[0])
B.append(A[0])
B.pop(0)
A.pop(0)
elif A[0] > B[0]:
A.append(A[0])
A.append(B[0])
B.pop(0)
A.pop(0)
elif A[0] < B[0]:
B.append(B[0])
B.append(A[0])
B.pop(0)
A.pop(0)
n += 1
if n == 10**6:
print('botva')
elif A == []:
print('second', n)
else:
print('first', n)