{$q+,r+}
uses
    testlib, sysutils;

var
    n: longint;
    pa, pb, pc, ps: longint;
    ja, jb, jc, js: longint;
    d: extended;

begin
    n := inf.readLongint();

    pa := ouf.readLongint();
    pb := ouf.readLongint();
    pc := ouf.readLongint();

    ja := ans.readLongint();
    jb := ans.readLongint();
    jc := ans.readLongint();

    d := 1.0 * pa * pb * pc;

    if ((pa < 0) or (pb < 0) or (pc < 0)) then quit(_wa, 'Negative number');

    if (abs(d - n) > 0.5) then quit(_wa, format('n = %d, capacity is %.0f', [n, d]));

    ps := pa * pb + pa * pc + pb * pc;
    js := ja * jb + ja * jc + jb * jc;

    if (ps > js) then quit(_wa, format('Not optimal solution, expected: %d, found: %d', [js, ps]));
    if (ps < js) then quit(_fail, format('Jury solution is not optimal, expected: %d, found: %d', [js, ps]));

    quit(_ok, format('%d x %d x %d', [pa, pb, pc]));
end.