• + 0 comments

    f# solution

    open System
    
    let toTuple [ a; b ] = (a, b)
    
    let q = Console.ReadLine() |> int
    
    [ 1..q ]
    |> List.map (fun _ ->
        Console.ReadLine()
        |> (fun s -> s.Split(" ") |> List.ofArray |> List.map int))
    |> List.map (fun l -> l |> List.chunkBySize 2 |> List.map toTuple)
    |> List.concat
    |> List.groupBy (fun (key, _) -> key)
    |> List.filter (fun (_, value) -> value |> List.length = q)
    |> List.map (fun (_, value) -> value |> List.min)
    |> List.map (fun (key, value) -> [ key; value ])
    |> List.concat
    |> List.map string
    |> String.concat " "
    |> Console.WriteLine