int input -1 for in range input split y1 y2 split int y1 60 int y2 z1

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
n = int(input())
a = [-1]
b = [1]
j = 1
for i in range(n):
x,y,z = input().split()
y1,y2 = y.split(':')
y = int(y1)*60+int(y2)
z1, z2 = z.split(':')
z = int(z1) * 60 + int(z2)
v = a.index(min(a))
if y >= min(a) or b[-1] > 10:
a[v] = z
print(x,b[v])
else:
j += 1
a.append(z)
b.append(j)
print(x,b[v])