let solve abLst xyLst = let m = List.length xyLst let chooseLst = seq abLst |> Seq.map (fun (a, b) -> Seq.init m (fun i -> (a, b, xyLst.[i]))) |> Seq.concat |> Seq.map (fun (a, b, (i, x, y)) -> async { return if (x <= a) && (y >= b) then Some(i) else None }) |> Async.Parallel |> Async.RunSynchronously |> Array.toSeq |> Seq.choose id |> Seq.countBy id |> Seq.sortBy (fun (i, iCnt) -> (-iCnt, i)) |> Seq.toList if List.isEmpty chooseLst then stdout.WriteLine(0) else let maxCnt = List.map (fun (i, iCnt) -> iCnt) chooseLst |> List.max List.filter (fun (i, iCnt) -> iCnt = maxCnt) chooseLst |> List.iter (fun (i, iCnt) -> printfn "%A" i) let () = let n = stdin.ReadLine() |> int let abLst = seq { for i in 1..n do let ab = stdin.ReadLine() |> fun s -> s.Split() |> fun arr -> (int arr.[0], int arr.[1]) yield ab } |> Seq.toList let m = stdin.ReadLine() |> int let xyLst = seq { for i in 1..m do let xy = stdin.ReadLine() |> fun s -> s.Split() |> fun arr -> (i, int arr.[0], int arr.[1]) yield xy } |> Seq.toList solve abLst xyLst