We have a point A with coordinate x = n on OX-axis. We'd like to find an integer point B (also on OX-axis), such that the absolute difference between the distance from O to B and the distance from A to B is equal to k.

<image> The description of the first test case.

Since sometimes it's impossible to find such point B, we can, in one step, increase or decrease the coordinate of A by 1. What is the minimum number of steps we should do to make such point B exist?

Input

The first line contains one integer t (1 ≤ t ≤ 6000) — the number of test cases.

The only line of each test case contains two integers n and k (0 ≤ n, k ≤ 10^6) — the initial position of point A and desirable absolute difference.

Output

For each test case, print the minimum number of steps to make point B exist.

Example

Input


6
4 0
5 8
0 1000000
0 0
1 0
1000000 1000000


Output


0
3
1000000
0
1
0

Note

In the first test case (picture above), if we set the coordinate of B as 2 then the absolute difference will be equal to |(2 - 0) - (4 - 2)| = 0 and we don't have to move A. So the answer is 0.

In the second test case, we can increase the coordinate of A by 3 and set the coordinate of B as 0 or 8. The absolute difference will be equal to |8 - 0| = 8, so the answer is 3.

<image>
'''for i in range(int(input())):
    r,g,b,w=[int(i) for i in input().split()]
    k=r%2 + g%2 +b%2 +w%2
    al=all(i!=0 for i in [r,g,b])
    if al:
        print("Yes")
    else :
        if k==0 or k==1:
            print("Yes")
        else:
            print("No")'''
'''n,m,x,y=[int(i) for i in input().split()]
app=[]
app.append([x,y])
def up(x,y):
    while x>1:
        x-=1
        app.append([x,y])
def down(x,y):
    while x<n:
        x+=1
        app.append([x,y])
if y>1:
    for j in range(y-1,0,-1):
        app.append([x,j])
        up(x,j)
        down(x,j)

for i in range(y,m+1):
    if i!=y:
        app.append([x,i])
    up(x,i)
    down(x,i)



for i in app:
    print(*i)'''
'''n=int(input())
from collections import defaultdict
graph=defaultdict(list)
for i in range(n-1):
    a,b=[int(i) for i in input().split()]
    graph[a].append(b)
    graph[b].append(b)
arr=[i for i in input().split()]
visited=[0 for i in range(n+1)]
start=[0 for i in range(n+1)]
tot=[0 for i in range(n+1)]
def dfs(i):
    visited[i]=1
    temp=[]
    cnt=0
    for j in graph[i]:
        if not visited[j]:
            dfs(j)
            if arr[i-1]!=arr[j-1]:
                tot[i]+=1+tot[j]
                cnt+=1
                start[i]+=start[j]
                temp.append(start[j])
    using=0
    if cnt==0:
        start[i]=1
    else:  
        if len(temp)>1:
            using=(len(temp)-1)*sum(temp)
        tot[i]+=start[i]+using
dfs(1)
print(tot)'''
    
'''for i in range(int(input())):
    n=int(input())
    arr=[int(i) for i in input()]
    pre=[arr[0]]*(n)
    for i in range(1,n):
        pre[i]=arr[i]+pre[i-1]
    suff=[arr[-1]]*(n)
    for j in range(n-2,-1,-1):
        suff[j]=arr[j]+suff[j+1]
    dp=[0]*(n)
    dp[0]=1 if arr[0]==1 else 0
    for i in range(1,n):
        l=i-arr[i]+1
        if l>=0:
            sum_=pre[i]-(pre[l-1] if l>0 else 0)
            if sum_==arr[i]:
                dp[i]=1+dp[l-1] if l>0 else 0
    print(dp)'''

'''n=int(input())
from collections import defaultdict
graph=defaultdict(list)
def bfs(graph,start):
    stack=[]
    level=[0]*(n+1)
    visited=[0]*(n+1)
    visited[start]=1
    stack.append(start)
    while stack:
        s=stack.pop(0)
        for j in graph[s]:
            if not visited[j]:
                visited[j]=1
                level[j]=1+level[s]
                stack.append(j)
    return level



if n==1:
    print(0)
else:
    for i in range(n-1):
        a,b=[int(i) for i in input().split()]
        graph[a].append(b)
        graph[b].append(a)
    k=bfs(graph,1)
    t=max(k)
    for i in range(1,k):
        if i==1:
            print()'''
    


#Codeforces Round 665
for i in range(int(input())):
    a,k=[int(i) for i in input().split()]
    if a==k:
        print(0)
    elif k==0 and a%2==0:
        print(0)
    elif k==0 and a%2:
        print(1)
    else:
        if k<=a:
            if k%2:
                if a%2==0:
                    print(1)
                else:
                    print(0)
            else:
                if a%2==1:
                    print(1)
                else:
                    print(0)
        else:
            print(abs(a-k))




