for z in open(0): for c in z*9:z=z.replace(c+c.swapcase(),'') print(+(z<'!'))