171_H. A polyline
<image>

Input

The input contains two integers a, b (1 ≤ a ≤ 10, 0 ≤ b ≤ 22·a - 1) separated by a single space.

Output

Output two integers separated by a single space.

Examples

Input

1 0


Output

0 0


Input

2 15


Output

3 0


Input

4 160


Output

12 12
```python
def coords(d, n):
    x,y = 0,0
    for i in range(n):
        sect = 2**i
        sx = (d>>1)&1
        sy = (d^sx)&1
        x,y = rotate(x,y,sx,sy,sect)
        x+=sect*sx
        y+=sect*sy
        d//=4
    return x,y
        
        
def rotate(x, y, sx, sy, n):
    if sy == 0:
        if sx == 1:
            x, y = n-1 - x, n-1 - y
        x,y = y,x
    return x,y
    
n, d = map(int, input().split())
print(*coords(d, n))
    
```