inf = open("abcd.in", "r")
ouf = open("abcd.out", "w")

n = int(inf.readline())
for test in range(n):
    s = int(inf.readline())
    print("YES" if ((s // 100) ** 2 + (s % 100) ** 2) % 7 == 1 else "NO", file = ouf)

inf.close()
ouf.close()

