The Sprague-Grundy function of graph (X, F) is a function g: X \rightarrow \mathbb{N} such that


g(x) = \min\{ n \geq 0 : n \neq g(y),\, y\, F(x) \}.
This formula can be written compactly using the concept of (minimal excludant). The minimal excludant of a set of non-negative integers is defined as the smallest non-negative number not belonging to this set. Then

g(x) = \textbf{mex}\{ g(y) : y\, F(x) \}.
Let consist only of non-negative integers. We define as the smallest element not in . Then the infinite matrix is defined as: A(0, 0) = 0, A(i, j) = \textbf{mex}(S), where is given by S = S_1 \cap S_2, S_1 = \{ A(k, j) : k < i \}, S_2 = \{ A(i, k) : k < j \}. Below are the first few values of this matrix:
Your task is to compute the specified elements of this matrix.
The input data contains a few test cases, each of which is a separate line containing the row number and column number for which to calculate the value of the matrix. Input values do not exceed 2 \cdot 10^9.
For each test case, output, on a separate line, the corresponding value of the matrix.
Example 1