fun quicksort [] = [] | quicksort (h::tl) = let val (s, b) = List.foldl (fn (x, (small, big)) => if x <= h then (x::small, big) else (small, x::big)) ([], []) tl in (quicksort s) @ [h] @ (quicksort b) end fun readInt () = valOf (TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn) fun intString n = if 0 <= n then Int.toString n else "-" ^ Int.toString (abs n) val () = let val x1 = readInt () val y1 = readInt () val x2 = readInt () val y2 = readInt () val x3 = readInt () val y3 = readInt () val candidates = List.foldl (fn (l, acc) => l @ acc) [] (List.tabulate (201, (fn x => List.map (fn yy => (x - 100, yy)) (List.tabulate (201, (fn y => y - 100)))))) val ans = List.find (fn (x, y) => let val d1 = (x1 - x) * (x1 - x) + (y1 - y) * (y1 - y) val d2 = (x2 - x) * (x2 - x) + (y2 - y) * (y2 - y) val d3 = (x3 - x) * (x3 - x) + (y3 - y) * (y3 - y) val sorted = quicksort [d1, d2, d3] in if List.nth (sorted, 0) = List.nth (sorted, 1) andalso List.nth (sorted, 0) * 2 = List.nth (sorted, 2) then ( if List.nth (sorted, 2) = d1 then (y2 - y) * (y3 - y) = (~1) * (x2 - x) * (x3 - x) andalso (x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3) = d2 else if List.nth (sorted, 2) = d2 then (y1 - y) * (y3 - y) = (~1) * (x1 - x) * (x3 - x) andalso (x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1) = d1 else (y2 - y) * (y1 - y) = (~1) * (x2 - x) * (x1 - x) andalso (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) = d1 ) else false end) candidates in case ans of NONE => print ("-1" ^ "\n") | SOME (x, y) => print (intString x ^ " " ^ intString y ^ "\n") end