tped, tsap = raw_input().split()
tped = int(tped)
tsap = int(tsap)
resp = []
def verifped(ped, total):
a = 0
while a < len(total):
if ped == total[a]:
return True
else:
a = a + 1
if a == len(total):
return False
while tsap > 0:
sap = raw_input().split()
sap[0] = int(sap[0])
sap[1] = int(sap[1])
if sap[0] + sap[1] <= tped:
resp.append(sap[0]+sap[1])
if sap[0] - sap[1] > 0:
resp.append(sap[0]-sap[1])
resp.append(sap[0])
tsap = tsap - 1
x = 1
while x <= tped:
if verifped(x, resp) == True:
print 1
else:
print 0
x = x + 1
dHBlZCwgdHNhcCA9IHJhd19pbnB1dCgpLnNwbGl0KCkKdHBlZCA9IGludCh0cGVkKQp0c2FwID0gaW50KHRzYXApCgpyZXNwID0gW10KCmRlZiB2ZXJpZnBlZChwZWQsIHRvdGFsKToKICAgIGEgPSAwCiAgICB3aGlsZSBhIDwgbGVuKHRvdGFsKToKICAgICAgICBpZiBwZWQgPT0gdG90YWxbYV06CiAgICAgICAgICAgIHJldHVybiBUcnVlCiAgICAgICAgZWxzZToKICAgICAgICAgICAgYSA9IGEgKyAxCiAgICBpZiBhID09IGxlbih0b3RhbCk6CiAgICAgICAgcmV0dXJuIEZhbHNlCgp3aGlsZSB0c2FwID4gMDoKCXNhcCA9IHJhd19pbnB1dCgpLnNwbGl0KCkKCXNhcFswXSA9IGludChzYXBbMF0pCglzYXBbMV0gPSBpbnQoc2FwWzFdKQoJaWYgc2FwWzBdICsgc2FwWzFdIDw9IHRwZWQ6CgkJcmVzcC5hcHBlbmQoc2FwWzBdK3NhcFsxXSkKCWlmIHNhcFswXSAtIHNhcFsxXSA+IDA6CgkJcmVzcC5hcHBlbmQoc2FwWzBdLXNhcFsxXSkKCXJlc3AuYXBwZW5kKHNhcFswXSkKCXRzYXAgPSB0c2FwIC0gMQoKeCA9IDEKd2hpbGUgeCA8PSB0cGVkOgoJaWYgdmVyaWZwZWQoeCwgcmVzcCkgPT0gVHJ1ZToKCQlwcmludCAxCgllbHNlOgoJCXByaW50IDAKCXggPSB4ICsgMQoK