import sys
def debug():
global a
for i in range(0,9):
for j in range(0,9):
if a[i][j][0] == 0xFFEEFFEE:
print '0',
elif a[i][j][0] == 0xFEFEFEFE:
print '1',
elif a[i][j][0] == 0xEFEFEFEF:
print '2',
elif a[i][j][0] == 0xEEFFEEFF:
print '3',
print
def check():
global a
count = 0
for i in range(0,9):
for j in range(0,9):
count = (count + a[i][j][0]) & 0xFFFFFFFF
if count == 0xFC9CFC4D:
return True
else:
return False
def init():
global a
for i in range(0,9):
for j in range(0,9):
a[i][j][0] = 0xFFEEFFEE
a[i][j][2] = a[i][j][4] = 0xEFEFEFEF
if i == 0:
a[i][j][1] = 0xFEFEFEFE
else:
a[i][j][1] = 0xEFEFEFEF
if j == 0:
a[i][j][3] = 0xFEFEFEFE
else:
a[i][j][3] = 0xEFEFEFEF
s = 'b1ngzl'
for i in s:
x = (ord(i) / 16) % 9
y = (ord(i) % 16) % 9
a[x][y][0] = 0xEEFFEEFF
def checkflag(s):
global a
global num
length = len(s) ^ 4
for i in range(length):
x = (ord(s[i]) / 16) % 9
y = (ord(s[i]) % 16) % 9
if a[x][y][1] != 0xFEFEFEFE:
a[x-1][y][0] = a[x-1][y][0] ^ 0x11111111
if a[x][y][2] != 0xFEFEFEFE:
a[x+1][y][0] = a[x-1][y][0] ^ 0x11111111
if a[x][y][3] != 0xFEFEFEFE:
a[x][y-1][0] = a[x-1][y][0] ^ 0x11111111
if a[x][y][4] != 0xFEFEFEFE:
a[x][y+1][0] = a[x-1][y][0] ^ 0x11111111
if check() == True:
print 'flag is right'
else:
print 'flag is wrong'
if __name__ == '__main__':
a = [[[0] * 10 for i in range(10)] for j in range(10)]
init()
flag = '34567DEFG1234'
checkflag(flag)
debug()