main(b,c,d){for(;~scanf("%d%c",&d,&c);c++&3?puts("-1"+b%2),b=1:1)b^=b>>d&1^(1<