import sys
x=[]
o=[]
t=1
b=","
k=map
def m(c):
m=(o,x)[t];c=k(int,c.split(b))
if c in o+x:
print b;sys.exit()
m+=c;r=0
for p in m:r=w(p,m)
return r
def w(p,m):
r=0
for q in m:
d=max(k(lambda x,y:abs(x-y),p,q))
if d==u and e(pqm):r=1
return r
def e(p,q,m):
v=k(lambda p,q:(p-q)/u,q,p);l=p;
for i in range(1,n):
y=k(lambda j,h:j+h,l,v)
if y not in m:
return 0
l=y
return l==q
q=raw_input
d=q()
v=q()
z=d.split(b)
(n,d)=k(int,z)
a=v.split(";")
u=n-1
for c in a:
r=m(c)
if r:print t
t^=t
aW1wb3J0IHN5cwp4PVtdCm89W10KdD0xCmI9IiwiCms9bWFwCmRlZiBtKGMpOgogbT0obyx4KVt0XTtjPWsoaW50LGMuc3BsaXQoYikpCiBpZiBjIGluIG8reDoKICBwcmludCBiO3N5cy5leGl0KCkKIG0rPWM7cj0wCiBmb3IgcCBpbiBtOnI9dyhwLG0pCiByZXR1cm4gcgpkZWYgdyhwLG0pOgogcj0wCiBmb3IgcSBpbiBtOgogIGQ9bWF4KGsobGFtYmRhIHgseTphYnMoeC15KSxwLHEpKQogIGlmIGQ9PXUgYW5kIGUocHFtKTpyPTEKIHJldHVybiByCmRlZiBlKHAscSxtKToKIHY9ayhsYW1iZGEgcCxxOihwLXEpL3UscSxwKTtsPXA7CiBmb3IgaSBpbiByYW5nZSgxLG4pOgogIHk9ayhsYW1iZGEgaixoOmoraCxsLHYpCiAgaWYgeSBub3QgaW4gbToKICAgcmV0dXJuIDAKICBsPXkKIHJldHVybiBsPT1xCnE9cmF3X2lucHV0CmQ9cSgpCnY9cSgpCno9ZC5zcGxpdChiKQoobixkKT1rKGludCx6KQphPXYuc3BsaXQoIjsiKQp1PW4tMQpmb3IgYyBpbiBhOgogcj1tKGMpCiBpZiByOnByaW50IHQKIHRePXQ=