Scanf.scanf "%d %d\n" (fun n t->
  let rec loop i m=
    if i=n then m else
    let m = Scanf.scanf "%d %d\n" (fun c1 t1 ->
            if t1<t && c1<=m then c1 else m
    ) in
    loop (i+1) m
  in
  let a = loop 0 500000 in
  if a=500000 then Printf.printf "TLE\n" else Printf.printf "%d\n" a

)
