{$apptype console}
// ACM 2009
// Problem C
// (C) Chistyakov T. S.

function nod(c, d: integer): integer;
begin
  if c = 0 then
    Result := d
  else if d = 0 then
    Result := c
  else if c > d then
    Result := nod(c mod d, d)
  else
    Result := nod(d mod c, c);
end;

var
  fi, fo: textfile;
  i, n: integer;
  a, b: array of integer;
  c, d, e: integer;
begin
  assignfile(fi, 'input.txt');
  assignfile(fo, 'output.txt');
  reset(fi);
  rewrite(fo);

  read(fi, n);
  setlength(a, n);
  setlength(b, n);
  for i := 0 to n - 1 do
    read(fi, a[i]);
  for i := 0 to n - 1 do
    read(fi, b[i]);

  i := n - 1;
  c := 0; d := 0; // avoid warning
  while i >= 0 do begin
    if (a[i] <> 0) xor (b[i] <> 0) then begin
      if a[i] = 0 then 
        c := 0
      else
        c := 1;
      d := 1 - c;
      break;
    end
    else if a[i] <> 0 then begin
      c := a[i];
      d := b[i];
      break;
    end
    else 
      dec(i);
  end;

  e := nod(c, d);
  write(fo, c div e, ' ', d div e);

  closefile(fi);
  closefile(fo);
end.