a,b = map(int,input().split())
b //=1000
l = []
s = []
for i in range(a):
l.append([int(x) for x in input().split()])
for i in l:
if i[1]<=29:
s.append(i[0]+b*10)
elif i[1]<=39:
s.append(i[0]+b*50)
else:
s.append(i[0]+b*100)
maxs = [0,0]
for i in range(a):
if s[i] > maxs[1]:
maxs[1]=s[i]
maxs[0]=i+1
print(*maxs)