var
    i, t, s: longint;
begin
    reset(input, 'abcd.in');
    rewrite(output, 'abcd.out');

    read(t);
    for i := 1 to t do begin
        read(s);
        if (sqr(s div 100) + sqr(s mod 100)) mod 7 = 1 then
            writeln('YES')
        else
            writeln('NO');
    end;

    close(input);
    close(output);
end.