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

)
