open Printf
open Scanf

module Pos = struct
    type t = int * int
    let compare = compare
end

module PosSet = MoreLabels.Set.Make(Pos)

let get_trans sign pict =
    let (ox, oy) = List.hd sign in
    let converted = ListLabels.map sign ~f:(fun (x, y) ->
        (x - ox, y - oy)) in
    let (dx, dy) = PosSet.choose (PosSet.filter pict ~f:(fun (px, py) ->
        ListLabels.for_all converted ~f:(fun (x, y) ->
            PosSet.mem (px + x, py + y) pict))) in
    (dx - ox, dy - oy)

let read_npos () = scanf "%d\n" (fun line ->
    let rec loop acc = function
        | 0 -> acc
        | i -> scanf "%d %d\n" (fun x y ->
                loop ((x, y) :: acc) (i - 1)) in
    List.rev (loop [] line))

let _ =
    let rec loop () =
        let sign = read_npos () in
        match sign with
        | [] -> ()
        | _ ->
                let pict = PosSet.of_list (read_npos ()) in
                let (tx, ty) = get_trans sign pict in
                printf "%d %d\n" tx ty;
                loop () in
    loop ()