n = 10
dp = [[-1 for i in xrange(n)] for j in xrange(n)]
dp[0][0] = 0
def stuff(i, j):
if dp[i][j] != -1:
return dp[i][j]
if i == j:
dp[i][j] = 1
return 1
for k in xrange(i):
if stuff(k, j) == 0:
dp[i][j] = 1
return 1
for k in xrange(j):
if stuff(i, k) == 0:
dp[i][j] = 1
return 1
for k in xrange(1, min(i, j) + 1):
if stuff(i - k, j - k) == 0:
dp[i][j] = 1
return 1
dp[i][j] = 0
return 0
for i in xrange(n):
for j in xrange(n):
print stuff(i, j),
print
biA9IDEwCmRwID0gW1stMSBmb3IgaSBpbiB4cmFuZ2UobildIGZvciBqIGluIHhyYW5nZShuKV0KZHBbMF1bMF0gPSAwCmRlZiBzdHVmZihpLCBqKToKICAgIGlmIGRwW2ldW2pdICE9IC0xOgogICAgICAgIHJldHVybiBkcFtpXVtqXQogICAgaWYgaSA9PSBqOgogICAgICAgIGRwW2ldW2pdID0gMQogICAgICAgIHJldHVybiAxCiAgICBmb3IgayBpbiB4cmFuZ2UoaSk6CiAgICAgICAgaWYgc3R1ZmYoaywgaikgPT0gMDoKICAgICAgICAgICAgZHBbaV1bal0gPSAxCiAgICAgICAgICAgIHJldHVybiAxCiAgICBmb3IgayBpbiB4cmFuZ2Uoaik6CiAgICAgICAgaWYgc3R1ZmYoaSwgaykgPT0gMDoKICAgICAgICAgICAgZHBbaV1bal0gPSAxCiAgICAgICAgICAgIHJldHVybiAxCiAgICBmb3IgayBpbiB4cmFuZ2UoMSwgbWluKGksIGopICsgMSk6CiAgICAgICAgaWYgc3R1ZmYoaSAtIGssIGogLSBrKSA9PSAwOgogICAgICAgICAgICBkcFtpXVtqXSA9IDEKICAgICAgICAgICAgcmV0dXJuIDEKICAgIGRwW2ldW2pdID0gMAogICAgcmV0dXJuIDAKCmZvciBpIGluIHhyYW5nZShuKToKICAgIGZvciBqIGluIHhyYW5nZShuKToKICAgICAgICBwcmludCBzdHVmZihpLCBqKSwKICAgIHByaW50Cg==