p=print
i=input
p(3,3)
z=i()[0]=='3'
p(3-z,2+z)
p(*[3,"14"[i()[z-1]=='1'],3][z:2+z])