// (C) Timofey S. Chistyakov 2005

{$apptype console}

// Предположения:
// 1. Машины врежутся
// 2. В начальный момент они не врезались
// 3. Скорость хотя бы одной машины ненулевая (следствие 1 и 2)

uses
  SysUtils, Math;

const
  NEVER: extended = 1e3000;
  
type
  TCar = record
    x, y, u, v, w, s: extended;
    sx, sy: extended;  // speed components
    xx, yy: array [1..4] of extended;  // corners, clockwise, starting with b/l
  end;

var
  car1, car2: TCar;


procedure CalcCar(var Car: TCar);
var
  dx, dy, n: extended;
begin
  with Car do begin
    dx := u - x;
    dy := v - y;
    n := Norm([dx, dy]);
    sx := dx / n * s;
    sy := dy / n * s;

    xx[1] := x; yy[1] := y;
    xx[2] := u; yy[2] := v;
    xx[3] := u + dy / n * w;
    yy[3] := v - dx / n * w;
    xx[4] := (x - u) + xx[3];
    yy[4] := (y - v) + yy[3];
  end;
end;


function CrossTime(
  const X0, Y0, SX, SY, X0s, Y0s, DX, DY: extended;
  out P, XC, YC: extended): extended;

  function getT(AP: extended): extended;
  begin
    P := AP;
    if (SX <> 0) then
      Result := ((X0s - X0) + AP * DX) / SX
    else
      Result := ((Y0s - Y0) + AP * DY) / SY;
    XC := X0s + AP * DX;
    YC := Y0s + AP * DY;
  end;

var
  ch, zn: extended;
begin
  Result := NEVER;
  ch := SX * (Y0s - Y0) - SY * (X0s - X0);
  zn := (DX * SY - DY * SX);
  if (zn <> 0) then begin
    if not InRange(ch / zn, 0, 1) then
      Exit;
    Result := getT(ch / zn);
  end;
  if Result < 0 then
    Result := NEVER;
end;


function Model(const Act, Pas: TCar; out AP, PP: integer): extended;
var
  i, inext, j: integer;
  sp, sx, sy: extended;
  t, p, xc, yc: extended;
  bestT, bestP: extended;
  bestI, bestJ: integer;
  idxJ: array [1..2] of integer;
begin
  sx := Act.sx - Pas.sx;
  sy := Act.sy - Pas.sy;

  sp := sx * (Act.u - Act.x) + sy * (Act.v - Act.y);
  if (sp >= 0) then begin  // едем передом
    idxJ[1] := 2;
    idxJ[2] := 3;
  end
  else begin
    idxJ[1] := 1;  // задом
    idxJ[2] := 4;
  end;

  bestI := -1;
  bestJ := -1;
  bestP := 2;
  bestT := NEVER;
  for i := 1 to 4 do begin
    inext := i mod 4 + 1;
    for j := 1 to 2 do begin
      t :=
        CrossTime(
          Act.xx[idxJ[j]], Act.yy[idxJ[j]], sx, sy,
          Pas.xx[i], Pas.yy[i],
          Pas.xx[inext] - Pas.xx[i], Pas.yy[inext] - Pas.yy[i],
          p, xc, yc
        );
      if (t <> NEVER) and (t <= bestT) then begin
        if IsZero(t - bestT, 1e-7) then begin
          if (i = bestI) then
            if (i < 4) then
              bestP := Min(p, bestP)
            else
              bestP := Max(p, bestP);
        end
        else begin
          bestT := t;
          bestP := p;
          bestI := i;
          bestJ := j;
        end;
      end;
    end;
  end;
  Result := bestT;
  if Result <> NEVER then begin
    AP := idxJ[bestJ];
    if bestP <= 0.5 then
      PP := bestI
    else
      PP := bestI mod 4 + 1;
  end;
end;

var
  fi, fo: textfile;
  p11, p12, p21, p22: integer;
  t1, t2: extended;
begin
  with car1 do
    Read(x, y, u, v, w, s);
  with car2 do
    Read(x, y, u, v, w, s);

  CalcCar(car1);
  CalcCar(car2);

  t1 := Model(car1, car2, p11, p12);
  t2 := Model(car2, car1, p22, p21);

  if (t1 < t2) or (t2 = NEVER) then
    Write(p11, ' ', p12)
  else if (t2 < t1) or (t1 = NEVER) then
    Write(p21, ' ', p22)
  else if (p11 < p21) or ((p11 = p21) and (p12 < p22)) then
    Write(p11, ' ', p12)
  else
    Write(p21, ' ', p22);
end.
