Problem Description

Two people face two piles of stones and make a game. They take turns to take stones. As game rules, there are two different methods of taking stones: One scheme is that you can take any number of stones in any one pile while the alternative is to take the same amount of stones at the same time in two piles. In the end, the first person taking all the stones is winner. Now,giving the initial number of two stones, can you win this game if you are the first to take stones and both sides have taken the best strategy?

Input

Input contains multiple sets of test data. Each test data occupies one line,containing two non-negative integers aa and bb,representing the number of two stones. aa and bb are not more than 1010010^{100}.

Output

For each test data,output answer on one line. 11 means you are the winner,otherwise output 00.

Sample Input

1
2
3
2 1
8 4
4 7

Sample Output

1
2
3
0
1
0

Idea

威瑟夫博弈的奇异局势为 5+12(ba)=a\frac{\sqrt 5+1}{2}(b-a)=a,用 Java\text{Java} 大数模拟即可。

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Scanner;
public class Main{
static BigDecimal eps=new BigDecimal("0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001");
static BigDecimal two=BigDecimal.valueOf(2);
public static void main(String[] args){
BigDecimal a,b;
Scanner in=new Scanner(System.in);
while(in.hasNext()) {
a=in.nextBigDecimal();
b=in.nextBigDecimal();
if(a.compareTo(b)>0) {
BigDecimal t;
t=a;
a=b;
b=t;
}
BigDecimal sub=b.subtract(a);
BigDecimal F=sqrt(BigDecimal.valueOf(5.0));
F=F.add(BigDecimal.valueOf(1));
BigDecimal mul=F.divide(two);
BigInteger L=a.toBigInteger();
BigInteger R=mul.multiply(sub).toBigInteger();
if(L.compareTo(R)==0) {
System.out.println("0");
}else {
System.out.println("1");
}
}
}
static BigDecimal sqrt(BigDecimal x){
BigDecimal L=BigDecimal.ZERO,R=x;
while(R.subtract(L).compareTo(eps)>0){
BigDecimal mid=(L.add(R).divide(two));
BigDecimal p=mid.pow(2);
if(p.compareTo(x)>0)R=mid;
else L=mid;
}
return L;
}
}