program checkg;

uses
    testlib, sysutils;

var
    i, n, m: longint;
    a, b: array [0..1000] of longint;
    ja, pa: string;

begin
    n := inf.readlongint;
    m := inf.readlongint;
    
    for i := 1 to n do
    begin
        a[i] := inf.readlongint;
    end;
    
    ja := uppercase(trim(ans.readstring));
    pa := uppercase(trim(ouf.readstring));
    if (ja <> pa) then
        quit(_wa, 'expected: ' + ja + ', found: ' + pa);
    if ja = 'NO' then
        quit(_ok, 'NO');
    for i := 1 to n do
    begin
        b[i] := ouf.readlongint;
        if (b[i] < 0) or (b[i] >= m) then
            quit(_wa, inttostr(b[i]) + ' in output file (m = ' + inttostr(m) + ')');
    end;
    
    for i := 1 to n do
        if (a[i] + b[i]) mod m <> b[i mod n + 1] then
            quit(_wa, 
                'm = ' + inttostr(m) + ', ' +
                'a[' + inttostr(i) + '] = ' + inttostr(a[i]) + ', ' +
                'b[' + inttostr(i) + '] = ' + inttostr(b[i]) + ', ' +
                'b[' + inttostr(i mod n + 1) + '] = ' + inttostr(b[i mod n + 1]) + 
                ', wrong crc');
                
    quit(_ok, 'YES');
end.