{ NOTE: it is recommended to use this even if you don't understand the following code }

const
    MAXN = 100000;
    MAXQ = 100000;

var
    N, P, Q, i : LongInt;
    F, S       : Array[0..MAXN-1] of LongInt;
    k, l, r    : Array[0..MAXQ-1] of LongInt;
    answer     : Array[0..MAXQ-1] of AnsiString;

begin
{
    uncomment the two following lines if you want to read/write from files
    assign(input,  'input.txt');  reset(input);
    assign(output, 'output.txt'); rewrite(output);
}

    ReadLn(N, P);

    for i:=0 to N-1 do
        Read(S[i]);
    ReadLn();

    for i:=0 to N-1 do
        Read(F[i]);
    ReadLn();

    ReadLn(Q);

    for i:=0 to Q-1 do
        ReadLn(l[i], r[i], k[i]);

    for i := 0 to MAXQ-1 do answer[i] := '';

    { INSERT YOUR CODE HERE }


    for i:=0 to Q-1 do
        WriteLn(answer[i]);

end.
