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

var
    n, i, j: longint;
    t: int64;
    w, d, p, c, pa: array[1..1000] of int64;

begin
    n := inf.readLongint();
    t := inf.readLongint();
    for i := 1 to n do w[i] := inf.readLongint();
    for i := 1 to n do d[i] := inf.readLongint();
    for i := 1 to n do p[i] := inf.readLongint();
    for i := 1 to n do c[i] := p[i] - d[i] * t;

    for i := 1 to n do pa[i] := ouf.readLongint();

    for i := 1 to n do begin
      if (pa[i] < 1) or (pa[i] > n) then
        quit(_wa, format('%d-th number is not in range 1..n', [i]));
    end;
    for i := 1 to n do
      for j := i + 1 to n do if pa[i] = pa[j] then 
        quit(_wa, format('%d-th and %d-th numbers are same', [i, j]));

    for i := 1 to n do 
      for j := 1 to n do if (c[i] < c[j]) and (w[pa[i]] > w[pa[j]]) then
        quit(_wa, 'Not optimal solution.');

    quit(_ok, '');
end.