Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, Polycarp spends two diamonds and one stick.

Each tool can be sold for exactly one emerald. How many emeralds can Polycarp earn, if he has $a$ sticks and $b$ diamonds?


-----Input-----

The first line contains one integer $t$ ($1 \le t \le 1000$) — the number of test cases.

The only line of each test case contains two integers $a$ and $b$ ($0 \le a, b \le 10^9$) — the number of sticks and the number of diamonds, respectively.


-----Output-----

For each test case print one integer — the maximum number of emeralds Polycarp can earn.


-----Example-----
Input
4
4 4
1000000000 0
7 15
8 7

Output
2
0
7
5



-----Note-----

In the first test case Polycarp can earn two emeralds as follows: craft one sword and one shovel.

In the second test case Polycarp does not have any diamonds, so he cannot craft anything.

Difficulty: interview

Starter code:

Solutions:
t = int(input())
for _ in range(t):
    a, b = list(map(int, input().split()))
    print(min((a+b)//3,a,b))


from collections import defaultdict as dd
import math
import sys
import string
input=sys.stdin.readline
def nn():
	return int(input())

def li():
	return list(input())

def mi():
	return list(map(int, input().split()))

def lm():
	return list(map(int, input().split()))

q=nn()
for _ in range(q):

	d, s = mi()

	m = min(d,s)

	print(min(m,(d+s)//3))


t=int(input())
for _ in range(t):
    a,b=map(int,input().split())
    d=(a+b)//3
    while (d+1)*3<=a+b:
        d+=1
    print(min(min(d,a),b))

for _ in " "*int(input()):
    a,b=map(int,input().split())
    print(min(a,b,(a+b)//3))

from math import *
a = int(input())
for _ in range(a):
    b,c = map(int,input().split())
    if b >= 2*c:
        print(c)
    elif c >= 2*b:
        print(b)
    else:
        print(floor((b+c)/3))

t=int(input())
for you in range(t):
    l=input().split()
    a=int(l[0])
    b=int(l[1])
    x=max(a,b)
    y=min(a,b)
    if(x>2*y):
        print(y)
    else:
        print((x+y)//3)


t = int(input())
for _ in range(t):
    a, b = list(map(int, input().split()))
    l, r = 0, min(a, b) + 1
    while r - l > 1:
        m = (l + r) // 2
        if a - m + b - m >= m:
            l = m
        else:
            r = m
    print(l)


t=int(input())
for i in range(t):
     s=input().split()
     n=int(s[0])
     m=int(s[1])
     if n>m:
          n,m=m,n
     if (2*n>=m):
          print((n+m)//3)
     else:
          print(n)
 
 
     
  
          
          
     


from math import inf as inf
from math import *
from collections import *
import sys
input=sys.stdin.readline
t=int(input())
while(t):
    t-=1
    a,b=list(map(int,input().split()))
    z=(a+b)//3
    print(min(a,b,z))
        
    


for _ in range(int(input())):
    a,b = list(map(int, input().split()))
    if a < b:
        a, b = b, a
    ans = min(a - b, b)
    a -= ans * 2
    b -= ans
    if b != 0:
        ans += (a+b) // 3
    print(ans)


tests = int (input())
for test in range (tests):
  a, b = map (int, input().split())
  print (min (a, b, (a+b) // 3)) 

t = int(input())
for _ in range(t):
	a, b = map(int, input().split())
	print(min(a, b, (a+b)//3))

tests = int(input())
for _ in range(tests):
    x, y = map(int, input().split())
    if x == 0 or y == 0:
        print(0)
        continue
    if 2 * x <= y:
        print(x)
    elif 2 * y <= x:
        print(y)
    else:
        print((x + y) // 3)

import sys
INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br

def solve():
  a, b = I()
  if a > b:
    a, b = b, a
  print(min(a, (a + b) // 3))

t, = I()
while t:
  t -= 1
  solve()

for _ in range(int(input())):
	a,b=map(int, input().split())
	a,b=min(a,b),max(a,b)
	if(a*2>=b):
		print((a+b)//3)
	else:
		print(a)

for _ in range(int(input())):
    n, m = map(int, input().split())
    if m > n:
        n, m = m, n
    if n > 2 * m:
        n = 2 * m
    print((n + m) // 3)

T = int(input())
for __ in range(T):
    a, b = map(int, input().split())
    c = min((a + b) // 3, a, b)
    print(c)

def solve(a, b, mid):

    a -= mid
    b -= mid
    if a < 0 or b < 0:
        return False
    if a + b >= mid:
        return True
    else:
        return False
      
t = int(input())
for _ in range(t):
    a, b = map(int, input().split())
    ok = 0
    ng = 10 ** 10
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if solve(a, b, mid):
            ok = mid
        else:
            ng = mid
    print(ok)

for t in range(int(input())):
    a,b=map(int,input().split())
    print(min(a,b,(a+b)//3))

import sys
input = sys.stdin.readline
for f in range(int(input())):
    a,b=list(map(int,input().split()))
    print(min((a+b)//3,a,b))


for case in range(int(input())):
    a, b = [int(x) for x in input().split()]
    a, b = [min(a,b), max(a, b)]

    x = (a+b)//3
    print(min(x, a, b))

import sys

readline = sys.stdin.readline
read = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    a, b = nm()
    if a < b:
        a, b = b, a
    if a > b*2:
        print(b)
    else:
        res = a - b
        a -= 2 * res
        b -= res
        res += (b // 3) * 2
        a %= 3
        if a > 1: res += 1
        print(res)
    return


# solve()

T = ni()
for _ in range(T):
    solve()


for t in range(int(input())):
    n, k = list(map(int, input().split()))
    s = (n, k, (n+k)//3)
    print(min(s))


T=int(input())
for _ in range(T):
    a,b=input().split()
    a=int(a)
    b=int(b)
    if min(a,b)*2<=max(a,b):
        print(min(a,b))
    else:
        print(int((a+b)/3))

import sys
import bisect as b
import math
from collections import defaultdict as dd
input=sys.stdin.readline
mo=10**9+7
def cin():
    return list(map(int,sin().split()))
def ain():            
    return list(map(int,sin().split()))
def sin():
    return input()
def inin():
    return int(input())


    
for i in range(inin()):
    a,b=cin()
    print(min(a,b,(a+b)//3))
        
    


t = int(input())
for _ in range(t):
    a, b = map(int, input().split())
    print(min((a+b)//3, a, b))

t = int(input())
for i in range(t):
    a, b = [int(x) for x in input().split()]
    print(min((a + b) // 3, a, b))


t = int(input());
for _ in range(t):
    a,b = list(map(int,input().split()));
    if(max(a,b)>=2*min(a,b)):
        print((min(a,b)));
    else:
        print(((a+b)//3));


t = int(input())

for i in range(t):
    a,b = map(int,input().split())
    if a >= 2 * b:
        print(b)
    elif b >= 2 * a:
        print(a)
    else:
        print(int((a+b)/3))

T = int(input())
for _ in range(T):
    A,B = list(map(int,input().split()))
    def is_ok(k):
        a = A-k
        b = B-k
        if a < 0 or b < 0:
            return False
        return a+b >= k
    ok = 0
    ng = 10**9
    while ng-ok > 1:
        m = (ok+ng)//2
        if is_ok(m):
            ok = m
        else:
            ng = m
    print(ok)


T = int(input())
for cas in range(T):
    ans = 0
    a,b = map(int,input().split())
    if a * 2 <= b:
        ans = a
    elif b * 2 <= a:
        ans = b
    else:
        ans = (a + b) // 3
    print(ans)

import sys
def inp():
    return sys.stdin.readline().strip()
for _ in range(int(inp())):
    a,b=map(int,inp().split())
    print(min(a,b,(a+b)//3))

import sys
def input():return sys.stdin.readline()[:-1]
def N(): return int(input())
def NM():return list(map(int,input().split()))
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
t=N()
def f():
    a,b=NM()
    if a<b:
        a,b=b,a
    if a-b>=b:
        print(b)
    else:
        print((a+b)//3)

for i in range(t):
    f()