implementation

雑に書いてWAした。loopを抜けた後にも確認と出力が必要な形で書いたのにそれを忘れた。

#!/usr/bin/env python3
n, q = map(int, input().split())
xs = []
xs += [( 0, 'kogakubu10gokan' )]
for _ in range(n):
    year, name = input().split()
    xs += [( int(year), name )]
while True:
    year, name = xs.pop()
    if year <= q:
        print(name)
        break