Scanf.scanf "%d %d %d %d %d %d" (fun p q r a b c -> let nmin1 = p * a - p + 1 in let nmax1 = p * a in let nmin2 = q * (a + b) - q + 1 in let nmax2 = q * (a + b) in let nmin3 = r * (a + b + c) - r + 1 in let nmax3 = r * (a + b + c) in let nmin = max (max nmin1 nmin2) nmin3 in let nmax = min (min nmax1 nmax2) nmax3 in if nmin <= nmax then Printf.printf "%d %d\n" nmin nmax else print_endline "-1" )