for i in range (32): s=input() if s=="0123" or s=="1230" or s=="2301" or s=="3012": print(1) else : print(0)