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.

Source: codeforces | Difficulty: EASY
Tags: Sorting

Mathematics

Greedy algorithms


Solutions:
import math
t = int(input())
cnt = 0
for cnt in range(t):
	(a, b) = map(int, input().split())
	c = max(a, b)
	d = min(a, b)
	ans = 0
	if c >= 2 * d:
		print(d)
	else:
		x = math.ceil((2 * d - c) / 3)
		d -= x * 2
		ans = x + d
		print(ans)


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


t = int(input())
for ingles in range(t):
	X = input()
	X1 = X.split()
	a = int(X1[0])
	b = int(X1[1])
	a1 = min(a, b)
	b1 = max(a, b)
	if a1 == 0:
		print(0)
	elif 2 * a1 <= b1:
		print(a1)
	else:
		x = int((2 * b1 - a1) / 3)
		y = int((a1 - x) / 2)
		print(x + y)


def main(a, b):
	minn = min(a, b)
	if minn == 0:
		return 0
	if minn == 1 and a == b:
		return 0
	if minn == 1:
		return 1
	diff = abs(a - b)
	if max(a, b) > 2 * minn:
		return minn
	a = minn - diff
	return diff + (2 * (a // 3) + a % 3 // 2)
for _ in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	print(main(a, b))


t = int(input())
while t:
	(a, b) = map(int, input().split())
	print(min(a, b, (a + b) // 3))
	t -= 1


def min(a, b):
	if a <= b:
		return a
	else:
		return b
test_case = int(input())
for __ in range(test_case):
	(a, b) = map(int, input().split())
	tot = min((a + b) // 3, min(a, b))
	print(tot)


def fun(a, b):
	ans = (a + b) // 3
	return min(ans, min(a, b))
for _ in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	print(fun(a, b))


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


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


for i in range(int(input())):
	(a, b) = [int(num) for num in input().split()]
	count = 0
	if a == 0 or b == 0:
		print('0')
	elif a > 2 * b:
		print(b)
	elif b > 2 * a:
		print(a)
	else:
		c = (a + b) // 3
		count = 1
	if count > 0:
		print(c)


import os
import sys
from io import BytesIO, IOBase
import math

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

def inputArray():
	return input().rstrip().split()

def inputVars():
	return map(int, input().rstrip().split())

def inputNum():
	return int(input())

def main():
	for _ in range(inputNum()):
		(sticks, diamonds) = inputVars()
		if sticks == 0 or diamonds == 0:
			print(0)
		elif max(sticks, diamonds) // 2 <= min(sticks, diamonds):
			print((sticks + diamonds) // 3)
		else:
			print(min(sticks, diamonds))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
pprint = lambda s: print(' '.join(map(str, s)))
input = lambda : sys.stdin.readline().strip()
ipnut = input
for i in range(int(input())):
	(n, k) = map(int, input().split())
	ans = 0
	(n, k) = (min(n, k), max(n, k))
	l = min(n, k // 2)
	(n1, k1) = (n - l, k - 2 * l)
	if n1 > 0:
		d = 0
		if n1 % 3 == 2 and k1 == 1:
			d = 1
		n1 //= 3
		print(l + min(n1, l) + d)
	else:
		print(l)


import sys
input = lambda : sys.stdin.readline().strip()
t = int(input())

def solve(a):
	ans = a // 3 * 2
	if a % 3 == 2:
		ans += 1
	return ans
while t:
	t -= 1
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
		continue
	if a == b:
		print(solve(a))
		continue
	if a < b:
		(a, b) = (b, a)
	x = a - b
	if x >= b:
		print(min(a // 2, b))
	else:
		print(x + solve(b - x))


for i in range(int(input())):
	(a, b) = map(int, input().split())
	ans = 0
	if a == 0 or b == 0:
		ans = 0
	else:
		x = max(a, b)
		y = min(a, b)
		if x > 2 * y:
			ans = y
		else:
			ans = (x + y) // 3
	print(ans)


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


from math import ceil, log, floor, sqrt

def mod_expo(n, p, m):
	result = 1
	while p != 0:
		if p % 2 == 1:
			result = result * n % m
		p //= 2
		n = n * n % m
	return result

def find_product(n, m, arr):
	product = 1
	if n <= m:
		for i in range(n):
			for j in range(i + 1, n):
				product = product * abs(arr[i] - arr[j]) % m
		return product
	return 0

def count_tables(l):
	count = 0
	l.sort()
	a = l[1] - l[0]
	b = l[2] - l[0]
	if a % 3 > 0 and a % 3 + (b - (a - a % 3)) >= 3:
		count += 1
	count += l[0] + 2 * a // 3
	return int(min(sum(l) / 3, l[0] + l[1]))

def find_possible_weight(W, arr):
	w = 0
	for i in range(8, 0, -1):
		count = min(arr[i - 1], W // i)
		w += count * i
		W -= count * i
	return w

def find_divisor(a):
	divisors = []
	divisors.append(1)
	for i in range(2, min(a, ceil(sqrt(a)) + 1)):
		if a % i == 0:
			if a / i == i:
				divisors.append(i)
			else:
				divisors.append(i)
				divisors.append(a / i)
	return int(max(divisors))

def count(a, b):
	if a == 0 or b == 0:
		return 0
	shovels = max(0, (2 * a - b) / 3)
	swords = max(0, (2 * b - a) / 3)
	return min(a, b, int(shovels + swords))

def find_max_gcd(a):
	degree = ceil(log(a) / log(2))
	m = pow(2, degree) - 1
	if a == m:
		return find_divisor(a)
	if a == m + 1:
		m = 2 * a - 1
	return m
t = 1
t = int(input())
while t:
	t = t - 1
	(a, b) = map(int, input().split())
	print(count(a, b))


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


t = int(input())
import math
for _ in range(t):
	(a, b) = map(int, input().split())
	if 2 * b <= a:
		print(b)
	elif a / 2 <= b <= 2 * a:
		x = (2 * a - b) / 3
		y = (a + b) / 3
		ans = max(-math.ceil(x) + a, -math.ceil(y) + b)
		print(ans)
	else:
		print(a)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	print(min(min(a, b), (a + b) // 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 k in range(t):
	(a, b) = map(int, input().split())
	x = min(a, b)
	y = max(a, b)
	ans = 0
	if y >= 2 * x:
		ans = x
	else:
		ans += y - x
		x -= y - x
		y = x
		ans += x // 3 * 2
		x = x % 3
		if x == 2:
			ans += 1
	print(ans)


T = int(input())
for t in range(T):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
	else:
		v1 = max(a, b)
		v2 = min(a, b)
		temp = int(v1 / 2)
		if temp >= v2:
			print(v2)
		else:
			temp = int(a / 3) + int(b / 3)
			if a % 3 >= 1 and b % 3 == 2 or (a % 3 == 2 and b % 3 >= 1):
				print(temp + 1)
			else:
				print(temp)


from sys import stdin, setrecursionlimit, stdout
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def si():
	return stdin.readline().rstrip()

def lsi():
	return list(si())
res = ['Yes', 'No']
test_case = ii()
while test_case:
	test_case -= 1
	(a, b) = mi()
	if a > b:
		(a, b) = (b, a)
	if b > 2 * a:
		b = 2 * a
	print((a + b) // 3)


t = int(input())
for i in range(t):
	c = 0
	(s, d) = map(int, input().split())
	if s == 0 or d == 0:
		print(0)
	elif s >= 1 and d >= 1:
		print(min((s + d) // 3, s, d))


t = int(input())
for _ in range(t):
	(a, b) = [int(s) for s in input().split()]
	cnt = abs(a - b)
	ma = max(a, b)
	mi = min(a, b)
	if ma >= 2 * mi:
		print(mi)
	else:
		ma -= 2 * cnt
		mi = ma
		cnt += 2 * (ma // 3)
		if ma % 3 == 2:
			cnt += 1
		print(cnt)


def solve():
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		return 0
	elif max(a, b) >= 2 * min(a, b):
		return min(a, b)
	return (a + b) // 3
t = int(input())
for loop in range(t):
	print(solve())


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


n = int(input())
for x in range(n):
	(a, b) = [int(x) for x in input().split()]
	if a == 0 or b == 0:
		print(0)
		continue
	ans1 = min(a, b)
	ans = min(ans1, (a + b) // 3)
	print(ans)


t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().split()))
	if a == 0 or b == 0:
		print(0)
	else:
		x = (a * 2 - b) / 3
		y = a - 2 * x
		mini = min(a, b)
		if int(x + y) > mini:
			print(mini)
		else:
			print(int(x + y))


from sys import stdin

def readline():
	return stdin.readline()
tests = int(readline())

def solve(a, b):
	if a == 0 or b == 0:
		return 0
	mx = max(a, b)
	mn = min(a, b)
	if mn * 2 <= mx:
		return mn
	return (a + b) // 3
for t in range(0, tests):
	(a, b) = list(map(int, readline().rstrip('\n').split(' ')))
	print(solve(a, b))


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))


ll = lambda : list(map(str, input().split()))
s = lambda : input()
v = lambda : map(int, input().split())
ii = lambda : int(input())
m = 1000000007
for _ in range(ii()):
	(a, b) = v()
	if a == 0 or b == 0:
		print(0)
	else:
		ans = min(min(a, b), (a + b) // 3)
		print(ans)


for _ in range(int(input())):
	(a, b) = [int(j) for j in input().split()]
	mini = min(a, b)
	maxi = max(a, b)
	if maxi >= 2 * mini:
		print(mini)
	elif a == 0 or b == 0:
		print(0)
	else:
		print((a + b) // 3)


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


T = int(input())

def main():
	(a, b) = tuple(map(int, input().split()))
	if a >= 2 * b or b >= 2 * a:
		result = min(a, b)
		return result
	if a == b:
		pairs = a // 3
		result = pairs * 2
		if a % 3 == 2:
			result = result + 1
		return result
	else:
		return (a + b) // 3
for _ in range(T):
	print(main())


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


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

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

def inputstring():
	return [x for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	(a, b) = inputnums()
	ans = min(min(a, b), (a + b) // 3)
	print(ans)


from math import ceil
from sys import stdin, stdout
int_in = lambda : int(stdin.readline())
arr_in = lambda : [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for y in range(rows)]
str_in = lambda : stdin.readline().strip()
out = lambda o: stdout.write('{}\n'.format(o))
arr_out = lambda o: out(' '.join(map(str, o)))
bool_out = lambda o: out('YES' if o else 'NO')
tests = lambda : range(1, int_in() + 1)
case_out = lambda i, o: out('Case #{}: {}'.format(i, o))

def solve(a, b):
	return min(a, b, (a + b) // 3)
for i in tests():
	(a, b) = arr_in()
	out(solve(a, b))


i = input
exec(int(i()) * 'a,b=map(int,i().split());print(min((a+b)//3,a,b));')


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
from decimal import Decimal
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	(a, b) = sp()
	(a, b) = (min(a, b), max(a, b))
	if b >= a * 2:
		out(a)
		continue
	answer = 0
	while a >= 2 and b > 0 or (b >= 2 and a > 0):
		(a, b) = (min(a, b), max(a, b))
		if b >= a * 2:
			answer += a
			break
		temp = b // 2
		if temp & 1:
			temp += 1
		answer += temp // 2
		b -= temp
		a -= temp // 2
	out(answer)


for testCases in range(int(input())):
	e = 0
	(s, d) = [int(inputNumber) for inputNumber in input().split()]
	diff = abs(d - s)
	if s >= diff and d >= diff:
		e += diff
		d -= diff
		s -= diff
		if s > d:
			s -= diff
		elif d > s:
			d -= diff
		e += s // 3 * 2
		s %= 3
		if s == 2:
			e += 1
	else:
		e = min(s, d)
	print(e)


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


def no_emralds(a, b):
	if a == 0 or b == 0:
		return 0
	if a >= 2 * b:
		return b
	if b >= 2 * a:
		return a
	return int((a + b) / 3)
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	print(no_emralds(a, b))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n == 0 or k == 0:
		print(0)
		continue
	max_p = (n + k) // 3
	print(min(n, k, max_p))


def solve(x, y):
	if x == 0:
		return 0
	if 2 * x <= y:
		return x
	if x == y:
		return (x + y) // 3
	else:
		z = y // 2
		l = x - z
		if y % 2 != 0:
			l += 1
		if l > 2:
			z += l // 3
		return z
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	(x, y) = (min(a, b), max(a, b))
	print(solve(x, y))


import os
import sys
from io import BytesIO, IOBase
import math
from fractions import Fraction
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a < b:
		raj = 'yff'
		(a, b) = (b, a)
	if a >= 2 * b:
		print(b)
	else:
		x = a - b
		y = (b - x) // 3 * 2 + (b - x) % 3 // 2
		print(x + y)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a < 1 or b < 1:
		print(0)
	elif a > (a + b) // 3 and b > (a + b) // 3:
		print((a + b) // 3)
	else:
		print(min(min(a, b), max(a, b) // 2))


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


import math

def solve(a, b):
	cost = 0
	if a == 0 or b == 0:
		return 0
	cost = 1 + max(solve(a - 2, b - 1), solve(a - 1, b - 2))
	return cost
try:
	t = int(input())
	while t:
		t -= 1
		(a, b) = map(int, input().split())
		cost = 0
		print(min(a, b, (a + b) // 3))
except:
	pass


for _ in range(int(input())):
	(l, r) = map(int, input().split())
	print(min(l, r, (l + r) // 3))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
		continue
	count = min((a + b) // 3, a, b)
	print(count)


for u in range(int(input())):
	(x, y) = map(int, input().split())
	if x == 0 or y == 0:
		print(0)
	else:
		m = max(x, y)
		n = min(x, y)
		if m / n >= 2:
			print(n)
		else:
			print((m + n) // 3)


import os
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 i in range(t):
	(a, b) = map(int, input().split())
	m = min(a, b)
	c = (a + b) // 3
	print(min(m, c))


def solve():
	(a, b) = map(int, input().split())
	if b < a:
		(a, b) = (b, a)
	if b > a * 2:
		print(a)
		return
	else:
		print((a + b) // 3)
		return
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
		continue
	(c, d) = (max(a, b), min(a, b))
	if d <= c // 2:
		print(d)
	else:
		print((c + d) // 3)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	if n > 0 and m > 0:
		s = n + m
		k = s // 3
		print(min(n, m, k))
	else:
		print(0)


from math import floor

def checker(a, b):
	x = floor((2 * a - b) / 3)
	y = floor((2 * b - a) / 3)
	if x < 0 and y < 0:
		return 0
	elif x < 0:
		return a
	elif y < 0:
		return b
	else:
		return (a + b) // 3
for _ in range(int(input())):
	(c, d) = [int(i) for i in input().split()]
	print(checker(c, d))


t = int(input())
while t:
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	if a >= 2 * b:
		print(b)
	elif b >= 2 * a:
		print(a)
	else:
		count = abs(a - b)
		if a >= b:
			a -= 2 * count
			if a % 3 == 2:
				print(count + a // 3 * 2 + 1)
			else:
				print(count + a // 3 * 2)
		else:
			b -= 2 * count
			if b % 3 == 2:
				print(count + b // 3 * 2 + 1)
			else:
				print(count + b // 3 * 2)
	t -= 1


t = int(input())
while t > 0:
	t -= 1
	(a, b) = map(int, input().split())
	if a * 2 <= b:
		print(a)
	elif b * 2 <= a:
		print(b)
	else:
		print((a + b) // 3)


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


numberOfCases = int(input())
testCases = []
for case in range(0, numberOfCases):
	(sticks, diamonds) = input().split(' ')
	testCases.append([int(sticks), int(diamonds)])
for [sticks, diamonds] in testCases:
	if 0 in [sticks, diamonds] or sum([sticks, diamonds]) < 3:
		print(0)
		continue
	if sum([sticks, diamonds]) < 6 or 1 in [sticks, diamonds]:
		print(1)
		continue
	if sticks < diamonds:
		(sticks, diamonds) = (diamonds, sticks)
	if sticks >= 2 * diamonds:
		print(diamonds)
		continue
	Emerland = 0
	Emerland = int(sticks / 3) + int(diamonds / 3)
	(sticks, diamonds) = (sticks % 3, diamonds % 3)
	if (sticks != 0 and diamonds != 0) and sticks + diamonds >= 3:
		print(Emerland + 1)
		continue
	print(Emerland)


import sys
import os
import heapq
import math
try:
	path = './file/input.txt'
	if os.path.exists(path):
		sys.stdin = open(path, 'r')
except:
	pass
t = int(input())

def printd(value):
	pass

def case():
	arr = list(map(int, input().split(' ')))
	(a, b) = (arr[0], arr[1])
	if a < b:
		(a, b) = (b, a)
	if a - b > b:
		print(b)
	else:
		c = a - b
		d = b - c
		count = d // 3 * 2
		count += c
		if d % 3 == 2:
			count += 1
		print(count)
for _ in range(t):
	case()


t = int(input())
for k in range(t):
	inp = [int(i) for i in input().split()]
	inp.sort()
	(a, b) = inp
	diff = b - a
	emeralds = 0
	if diff >= a:
		emeralds = a
	else:
		emeralds += diff
		a -= diff
		b -= 2 * diff
		if a % 3 == 0:
			emeralds += 2 * int(a / 3)
		elif a % 3 == 1:
			emeralds += 2 * int((a - 1) / 3)
		elif a % 3 == 2:
			emeralds += 2 * int((a - 2) / 3)
			emeralds += 1
	print(emeralds)


for _ in range(int(input())):
	l = list(map(int, input().split()))
	t = min(sum(l) // 3, min(l))
	print(t)


for i in range(int(input())):
	(sticks, diamonds) = list(map(int, input().split()))
	print(min((sticks + diamonds) // 3, sticks, diamonds))


n = int(input())
for i in range(n):
	(st, dm) = input().split()
	st = int(st)
	dm = int(dm)
	if st == 0 or dm == 0:
		print(0)
	elif 2 * st <= dm:
		print(st)
	elif 2 * dm <= st:
		print(dm)
	else:
		print((st + dm) // 3)


from math import floor
T = int(input())
for t in range(T):
	(a, b) = [int(x) for x in input().split()]
	if a > b:
		(a, b) = (b, a)
	if b - a > a:
		print(a)
	else:
		t = b - a
		a -= t
		b -= t * 2
		print(t + floor(a / 3 * 2))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	if n < k:
		(n, k) = (k, n)
	if 2 * k <= n:
		print(k)
	else:
		print((n + k) // 3)


import sys
import math
input = sys.stdin.readline
from collections import deque
from queue import LifoQueue

def binary_search(a, n):
	L = 0
	R = len(a) - 1
	while L <= R:
		mid = L + (R - L) // 2
		if a[mid] == n:
			return mid
		elif a[mid] < n:
			L = mid + 1
		else:
			R = mid - 1
	return -1
for _ in range(int(input())):
	(sti, dia) = map(int, input().split())
	if sti < dia:
		temp = dia
		dia = sti
		sti = temp
	aa = sti - 2 * dia
	if sti == 0 or dia == 0:
		print(0)
	elif aa >= 0:
		print(dia)
	else:
		print(min(dia, (sti + dia) // 3))


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
	elif a == 1 and b != 1:
		print(1)
	elif a != 1 and b == 1:
		print(1)
	else:
		print(min(a, b, int((a + b) / 3)))


from sys import stdin
t = int(input())
for _ in range(t):
	(a, b) = [int(x) for x in stdin.readline().split()]
	d = int((a + b) // 3)
	ans = min(d, a, b)
	print(ans)


t = int(input())
while t:
	(a, b) = map(int, input().split())
	x = max(a, b) // 2
	y = min(a, b)
	if x <= y:
		if a == 0 or b == 0:
			print('0')
		else:
			print((a + b) // 3 % 10 ** 9)
	else:
		print(min(a, b))
	t -= 1


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
	elif a < 2 and b < 2:
		print(0)
	else:
		x = min(a, b)
		y = max(a, b)
		e = (x + y) // 3
		if e <= x:
			print(e)
		else:
			print(x)


import math
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	if 2 * a <= b:
		print(a)
	else:
		ans = math.ceil((2 * b - a) / 3)
		ans += b - 2 * ans
		print(ans)


t = int(input())
for test in range(t):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
	elif 2 * min(a, b) < max(a, b):
		print(min(a, b))
	else:
		print((a + b) // 3)


t = int(input())
for i in range(t):
	arr = [int(i) for i in input().split()]
	arr.sort()
	a = arr[0]
	b = arr[1]
	s = a + b
	s = s // 3
	if a == 0 or b == 0:
		print(0)
	else:
		print(min(s, a))


from sys import stdin, stdout
LI = lambda : list(map(int, input().split()))
MAP = lambda : map(int, input().split())
IN = lambda : int(input())
S = lambda : input()
import math
from collections import Counter

def solve():
	(a, b) = MAP()
	x = max(a, b)
	y = min(a, b)
	if x // 2 >= y:
		print(y)
	else:
		print((x + y) // 3)
for i in range(IN()):
	solve()


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))


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	l.append((l[0] + l[1]) // 3)
	print(sorted(l)[0])


t = int(input())
cases = []
for i in range(t):
	cases.append(list(map(int, input().strip().split())))
for (a, b) in cases:
	ems = 0
	dif = abs(a - b)
	if dif >= min(a, b):
		if a > b:
			change = min(b, dif)
			print(change)
		else:
			change = min(a, dif)
			print(change)
	else:
		ems = dif
		if a > b:
			b -= dif
			a = b
		else:
			a -= dif
			b = a
		ems += a // 1.5
		print(int(ems))


def main():
	for _ in range(int(input())):
		(a, b) = sorted(map(int, input().split()))
		print(a if a * 2 < b else (a + b) // 3)
main()


t = int(input())
ans = []
for i in range(t):
	ab = input().split()
	a = int(ab[0])
	b = int(ab[1])
	ans.append(min(a, b, (a + b) // 3))
for i in range(t):
	print(ans[i])


for ttt in range(int(input())):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	d = b - a
	x = 0
	if d > a:
		x = a
	else:
		x = d + (a - d) // 3 * 2
		if (a - d) % 3 == 2:
			x += 1
	print(x)


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	(a, b) = map(int, sys.stdin.readline().split())
	if a < b:
		(a, b) = (b, a)
	gap = min(a - b, b)
	result = gap
	b -= gap
	a -= gap * 2
	gap = min(a // 3, b // 3)
	result += gap * 2
	a -= gap * 3
	b -= gap * 3
	if a > 1 and b > 1:
		result += 1
	print(result)


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split(' '))
	rem = max(a, b) - min(a, b)
	num = min(a, b) - rem
	if rem > min(a, b):
		print(min(a, b))
	else:
		print(2 * num // 3 + rem)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(a, b) = (max(a, b), min(a, b))
	init = min(a - b, b)
	ans = init
	a -= 2 * init
	b -= init
	if b == 0:
		print(ans)
		continue
	if a % 3 == 2:
		ans += 1
	print(a // 3 * 2 + ans)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(a, b) = (max(a, b), min(a, b))
	if b == 0:
		print(0)
		continue
	c = abs(a - b)
	if a < 2 * c:
		print(b)
		continue
	a = a - c * 2
	b = b - c
	if a == b:
		c += a // 3 * 2
		if a % 3 == 2:
			c += 1
	print(c)


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


for t in range(int(input())):
	(a, b) = [int(j) for j in input().split()]
	(a, b) = (max(a, b), min(a, b))
	if b == 0:
		ans = b
	if a >= 2 * b:
		ans = b
	else:
		ans = a - b + (2 * b - a) // 3 * 2
		if (2 * b - a) % 3 >= 2:
			ans += 1
	print(ans)


for x in range(int(input())):
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	if m == 0 or n == 0:
		print(0)
	elif m >= n * 2 or n >= m * 2:
		print(min(m, n))
	else:
		print((m + n) // 3)


def result(a, b):
	MIN = min(a, b)
	MAX = max(a, b)
	ans1 = 0
	if MAX >= 2 * MIN:
		return MIN
	ans = MIN // 3 * 2
	MAX -= 3 * (MIN // 3)
	MIN = MIN % 3
	MAX = max(MAX, MIN)
	MIN = min(MAX, MIN)
	if MIN == 1 and MAX >= 2:
		ans += 1
	elif MIN == 2 and MAX >= 6:
		ans += 2
	elif MIN == 2 and MIN <= MAX < 6:
		ans += 1
	return max(ans, ans1, (a + b) // 3)
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
	else:
		print(result(a, b))


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


t = int(input())
for _ in range(t):
	(a, b) = [int(x) for x in input().split()]
	ans = 0
	while True:
		(a, b) = (max(a, b), min(a, b))
		if a < 2 or b < 1:
			break
		if a < 10:
			a -= 2
			b -= 1
			ans += 1
		else:
			c = min(b, a // 4)
			ans += c
			a -= 2 * c
			b -= c
	print(ans)


t = int(input())
for i in range(0, t):
	a = [int(x) for x in input().split(' ')]
	if a[0] == 0 or a[1] == 0:
		print('0')
	elif a[0] > 2 * a[1]:
		print(a[1])
	elif a[1] > 2 * a[0]:
		print(a[0])
	else:
		print((a[0] + a[1]) // 3)


from math import *
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = n + m
	ans = a // 3
	p = min(n, m)
	if ans <= p:
		print(ans)
	else:
		print(p)


t = int(input())
for i in range(t):
	s = input().split()
	a = int(s[0])
	b = int(s[1])
	if a <= b // 2:
		print(a)
		continue
	elif b <= a // 2:
		print(b)
		continue
	else:
		print((a + b) // 3)


import math
t = int(input())
for p in range(0, t):
	(a, b) = map(int, input().split())
	x = ((a + b) / 3 + (a - b)) / 2
	if x < 1:
		x = 0
	else:
		x = min(math.floor(x), b)
	a -= 2 * x
	b -= x
	if b >= 2 * a:
		y = a
	else:
		y = b // 2
	print(x + y)


n = int(input())
for i in range(0, n):
	x = list(map(int, input().split()))
	x.sort()
	if x[0] == 0:
		print('0')
	elif x[0] < 2 and x[1] < 2:
		print('0')
	elif x[0] == 1 and x[1] >= 2:
		print('1')
	elif x[0] * 2 < x[1]:
		print(x[0])
	else:
		z = (x[0] + x[1]) / 3
		print(int(z))


import sys
import heapq
import random
import collections
import math

def solve(a, b):
	console('----- solving ------')
	console(a, b)
	(a, b) = sorted([a, b])
	if a * 2 <= b:
		return a
	res = b - a
	(a, b) = (a - (b - a), b - 2 * (b - a))
	res += a // 3 * 2
	console(a, b, '-')
	a = a - a // 3 * 3
	b = b - b // 3 * 3
	console(a, b, '*')
	if a == b == 2:
		res = res + 1
	return res

def console(*args):
	print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)
	return
for case_num in range(int(input())):
	(a, b) = list(map(int, input().split()))
	res = solve(a, b)
	print(res)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	if b > a:
		(a, b) = (b, a)
	if a > 2 * b:
		print(b)
	else:
		mul = a // 3
		a = a - 3 * mul
		ans = mul
		mul = b // 3
		b = b - 3 * mul
		ans += mul
		if a == 2 and b == 1 or (a == 1 and b == 2) or (a == 2 and b == 2):
			print(ans + 1)
		else:
			print(ans)


test = int(input())
while test > 0:
	test -= 1
	(a, b) = [int(x) for x in input().split()]
	print(min((a + b) // 3, a, b))


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((a + b) // 3)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	(a, b) = (max(a, b), min(a, b))
	diff = a - b
	if diff >= b:
		print(b)
	else:
		ans = diff
		rest = b - diff
		ans += 2 * (rest // 3)
		rest = rest % 3
		if rest == 2:
			print(ans + 1)
		else:
			print(ans)


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


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


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


for _ in range(int(input())):
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	print(min(n, m, (n + m) // 3))


import bisect
import decimal
from decimal import Decimal
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
decimal.getcontext().prec = 46

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	num = []
	for p in range(2, n + 1):
		if prime[p]:
			num.append(p)
	return num

def lcm(a, b):
	return a * b // math.gcd(a, b)

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]))

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

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binaryToDecimal(n):
	return int(n, 2)

def DFS(n, s, adj):
	visited = [False for i in range(n)]
	stack = []
	stack.append(s)
	while len(stack):
		s = stack[-1]
		stack.pop()
		if not visited[s]:
			visited[s] = True
		for node in adj[s]:
			if not visited[node]:
				stack.append(node)

def solve():
	(a, b) = num_input()
	if a == 0 or b == 0:
		print(0)
	else:
		ans = (a + b) // 3
		print(min(a, b, ans))
t = int(input())
for _ in range(t):
	solve()


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


import sys
input = sys.stdin.readline
from math import ceil, floor, factorial

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

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

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	(a, b) = sorted(int_array())
	if a == 0:
		print(0)
	elif b >= 2 * a:
		print(a)
	else:
		x = b - a
		a -= x
		b -= x * 2
		x += a // 3 * 2
		a = a % 3
		b = b % 3
		(a, b) = sorted([a, b])
		if a > 0 and b > 1:
			x += 1
		print(x)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	cnt = (x + y) // 3
	minn = min(x, y)
	minn2 = min(minn, cnt)
	print(minn2)


test = int(input())
test_arr = []
for _ in range(test):
	(a, b) = map(int, input().split())
	num = min(a, b, (a + b) // 3)
	test_arr.append(num)
for t in test_arr:
	print(t)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	ans = 0
	while a != b and a > 0 and (b > 0):
		(a, b) = (max(a, b), min(a, b))
		diff = max(1, min((a - b) // 2, b))
		a -= diff * 2
		b -= diff
		ans += diff
	if a == b:
		ans += a // 3 * 2
		a %= 3
		if a == 2:
			ans += 1
	print(ans)


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


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


import math
t = int(input())
for __ in range(t):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print('0')
	elif min(a, b) * 2 <= max(a, b):
		print(min(a, b))
	else:
		print((a + b) // 3)


import os
import heapq
import sys
import bisect
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase

def inar():
	return [int(k) for k in input().split()]

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		if min(n, k) * 2 <= max(n, k):
			print(min(n, k))
			continue
		if n == 0 or k == 0:
			print(0)
		else:
			mx = max(n, k)
			mn = min(n, k)
			diff = mx - mn
			if diff <= mn:
				ans = diff
				res = mx - diff * 2
				ans = ans + res // 3 * 2
				if res % 3 == 2:
					print(ans + 1)
				else:
					print(ans)
			else:
				print(min(n, k) * 2)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
for i in range(n):
	(s, d) = map(int, input().split())
	count = int((s + d) / 3)
	if s <= 0 or d <= 0:
		count = 0
	if min(s, d) * 2 <= max(s, d):
		count = min(s, d)
	print(count)


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


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	ans = 0
	if a > b:
		(a, b) = (b, a)
	if b >= 2 * a:
		print(a)
		continue
	x = b - a
	a -= x
	b -= 2 * x
	ans += x
	ans += 2 * (a // 3)
	if a % 3 == 2:
		ans += 1
	print(ans)


for i in range(int(input())):
	(a, b) = list(map(int, input().split()))
	z = 0
	if a > 0 and b > 0:
		z = (a + b) // 3
	if z > a:
		z = a
	elif z > b:
		z = b
	print(z)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	if min(a, b) == 0:
		print(0)
		continue
	c = 0
	(a, b) = (min(a, b), max(a, b))
	if a == b:
		c += b // 3 * 2
		if b % 3 == 2:
			c += 1
		print(c)
		continue
	d = b - a
	if b - (b - a) * 2 >= 0 and a - (b - a) >= 0:
		c += d
		a -= d
		b -= d * 2
	else:
		b -= a * 2
		c += a
		a = 0
	if a == b:
		c += b // 3 * 2
		if b % 3 == 2:
			c += 1
		print(c)
		continue
	if a == 1 and b >= 2 or (a >= 2 and b == 1):
		c += 1
	print(c)


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
import random
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
import sys
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	(a, b) = (max(a, b), min(a, b))
	print(min(a, b, (a + b) // 3))


for i in range(int(input())):
	(x, y) = map(int, input().split())
	if x * y == 0:
		print(0)
	else:
		print(min(x, y, (x + y) // 3))


query = int(input())
for i in range(query):
	(a, b) = list(map(int, input().split()))
	if a >= 1 and b >= 1 and ([a, b] != [1, 1]):
		x = int(max((2 * a - b) / 3, 0))
		y = int(max((2 * b - a) / 3, 0))
		if x < y:
			y = int(min(a - 2 * x, (b - x) / 2))
		else:
			x = int(min(b - 2 * y, (a - y) / 2))
		print(x + y)
	else:
		print(0)


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


def solve():
	temp = input()
	temp.strip()
	(a, b) = temp.split()
	a = int(a)
	b = int(b)
	ans = min(a, b, (a + b) // 3)
	print(ans)

def main():
	tt = int(input())
	while tt > 0:
		solve()
		tt -= 1
main()


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


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


from collections import Counter, defaultdict, deque
from math import *
import sys
input = sys.stdin.readline

def solve():
	(a, b) = sorted([int(x) for x in input().split()])
	if 2 * a <= b:
		print(a)
		return
	d = b - a
	a -= d
	r = a // 3 * 2
	a = a % 3
	ans = d + r
	if a == 2:
		ans += 1
	print(ans)
tt = int(input())
for test in range(tt):
	solve()


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


import sys
input = sys.stdin.readline
t = int(input())
ans = []
for kek in range(t):
	(a, b) = map(int, input().split())
	(a, b) = (max(a, b), min(a, b))
	if a >= 2 * b:
		ans.append(b)
	else:
		N = 0
		N += a - b
		d = a - b
		a -= 2 * d
		b -= d
		N += 2 * (a // 3)
		a -= 3 * (a // 3)
		b -= 3 * (b // 3)
		if a >= 2 and b >= 1:
			N += 1
		elif a >= 1 and b >= 2:
			N += 1
		ans.append(N)
print(*ans, sep='\n')


t = int(input())
for _ in range(t):
	inp = input().split()
	(a, b) = (int(inp[0]), int(inp[1]))
	if a == 0 or b == 0:
		print(0)
	elif a == 1 and b == 1:
		print(0)
	else:
		if a > b:
			if a - b > b:
				x = b
				y = 0
			else:
				x = a - b
				y = 2 * (b - x) // 3
		elif a == b:
			x = 0
			y = 2 * b // 3
		elif b - a > a:
			x = a
			y = 0
		else:
			x = b - a
			y = 2 * (a - x) // 3
		print(x + y)


def fun(a, b):
	if a // 2 >= b:
		return b
	else:
		return (a + b) // 3
for i in range(0, int(input())):
	(a, b) = [int(x) for x in input().split()]
	if a >= b:
		print(fun(a, b))
	if b > a:
		print(fun(b, a))


t = int(input())
results = []
for case in range(t):
	(sticks, diamonds) = map(int, input().split())
	count = min(sticks, diamonds, (sticks + diamonds) // 3)
	results.append(count)
for result in results:
	print(result)


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


t = int(input().strip())
for _ in range(t):
	(s, d) = map(int, input().strip().split(' '))
	diff = max(s, d) - min(s, d)
	if diff > min(s, d):
		ans = min(s, d)
	else:
		ans = diff
		tmp = min(s, d) - diff
		ans += tmp // 3 * 2 + (0, 1)[tmp % 3 == 2]
	print(ans)


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 998244353

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	(a, b) = sorted(li())
	ans = 0
	if (2 * a - b) // 3 >= 0:
		x = (2 * a - b) // 3
		ans += x
		a -= 2 * x
		b -= x
	ans += min(2 * a, b if b & 1 == 0 else b - 1) // 2
	print(ans)


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from collections import Counter
from bisect import bisect_left
import sys
from queue import PriorityQueue
mod = 1000000007

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())

def printIn(ob):
	return stdout.write(str(ob) + '\n')

def powerLL(n, p):
	result = 1
	while p:
		if p & 1:
			result = result * n % mod
		p = int(p / 2)
		n = n * n % mod
	return result

def myCode():
	(a, b) = In()
	ans = min((a + b) // 3, a, b)
	print(ans)

def main():
	for t in range(I()):
		myCode()
main()


def comparemin(a, b):
	if a < b:
		return a
	else:
		return b
sets_number = int(input())
sets = []
for i in range(sets_number):
	sets.append(list(map(int, input().split(' '))))
for i in sets:
	instruments_done = 0
	instruments_done = comparemin(i[0], i[1])
	instruments_done = comparemin(instruments_done, int((i[0] + i[1]) / 3))
	print(instruments_done)


def solve():
	(a, b) = [int(x) for x in input().split()]
	if a == 0 or b == 0:
		return 0
	return min((a + b) // 3, min(a, b))
t = int(input())
while t:
	print(solve())
	t -= 1


t = int(input())
for _ in range(t):
	inp = [int(x) for x in input().split(' ')]
	a = inp[0]
	b = inp[1]
	if a > 2 * b:
		e = b
	elif b > 2 * a:
		e = a
	elif a > b:
		diff = a - b
		e = diff // 2
		e += (a + b - 3 * e) // 3
	elif b > a:
		diff = b - a
		e = diff // 2
		e += (a + b - 3 * e) // 3
	else:
		e = (a + b) // 3
	print(e)


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


t = int(input())
while t > 0:
	ans = 0
	(a, b) = map(int, input().split())
	dif = min(max(a, b) - min(a, b), a, b)
	if a > b:
		tmp = a
		a = b
		b = tmp
	a -= dif
	b -= 2 * dif
	if a != b:
		print(dif)
	else:
		print(dif + (a + b) // 3)
	t -= 1


from sys import stdin
for _ in range(int(stdin.readline())):
	(a, b) = sorted(map(int, stdin.readline().split()))
	d = b - a
	t = min(a, d)
	a -= t
	b -= 2 * t
	res = t
	if a > 0:
		(x, y) = divmod(a, 3)
		res += 2 * x
		if y >= 2:
			res += 1
	print(res)


(T,) = map(int, input().split())
for _ in range(T):
	(a, b) = map(int, input().split())
	x = min(a, b)
	r = max(a, b) - x
	if r > x:
		print(x)
		continue
	x -= r
	if x % 3 != 2:
		r += x // 3 * 2
	else:
		r += x // 3 * 2 + 1
	print(r)


n = int(input())
v = [list(map(int, input().split())) for i in range(n)]
for (a, b) in v:
	if a >= 2 * b or 2 * a <= b:
		print(min(a, b))
	else:
		print((a + b) // 3)


def solve():
	(s, d) = list(map(int, input().split()))
	if s == 0 or d == 0:
		return 0
	ans = (s + d) // 3
	return min(ans, min(s, d))

def main():
	t = int(input())
	while t:
		print(solve())
		t -= 1
main()


import math
from collections import Counter
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
	else:
		print(min(min(a, b), (a + b) // 3))


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


from sys import stdin, stdout
from sys import maxsize
m = set({(1, 1), (0, 1), (1, 0), (0, 0)})

def predicate(m):
	if a >= m and b >= m:
		return True
	return False

def solve(a, b):
	left = 0
	right = (a + b) // 3
	while left < right:
		mid = left + (right - left) // 2 + 1
		if not predicate(mid):
			right = mid - 1
		else:
			left = mid
	return left
test = 0
test = int(input())
for t in range(0, test):
	(a, b) = list(map(int, input().split()))
	ans = solve(a, b)
	print(ans)


t = int(input())
for _ in range(t):
	res = 0
	(a, b) = map(int, input().split())
	c = min(a, b)
	d = max(a, b)
	if d == c:
		res = int((d + c) / 3)
	elif d >= 2 * c:
		res = c
	else:
		k = int((d + c) / 3)
		if k <= c:
			res = k
		else:
			res = c
	print(res)


for x in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	ans = 0
	if a == 0 or b == 0:
		print(ans)
	else:
		ans = min((a + b) // 3, min(a, b))
		print(ans)


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


from math import *

def r1(t):
	return t(input())

def r2(t):
	return [t(i) for i in input().split()]

def r3(t):
	return [t(i) for i in input()]
for _ in range(r1(int)):
	(a, b) = sorted(r2(int))
	ans = (a + b) // 3
	print(min(a, ans))


import math as ma
t = int(input())
for _ in range(t):
	(a, b) = list(map(int, input().split()))
	if a >= 2 * b:
		print(b)
	elif b >= 2 * a:
		print(a)
	else:
		if a < b:
			(b, a) = (a, b)
		c = a - b
		a = a - 2 * c
		b = b - c
		if a % 3 == 2:
			c += 1
		print(2 * (a // 3) + c)


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	(a, b) = map(int, input().split())
	(a1, b1) = (a, b)
	x = (2 * a - b) // 3
	if a < 2 * x or b < x or x < 0:
		x = 0
		y = min(b // 2, a)
	else:
		a = a - 2 * x
		b = b - x
		y = min(b // 2, a)
	y1 = (2 * b1 - a1) // 3
	if a1 < y1 or b1 < 2 * y1 or y1 < 0:
		y1 = 0
		x1 = min(b1, a1 // 2)
	else:
		a1 = a1 - y1
		b = b - 2 * y1
		x1 = min(a1 // 2, b1)
	print(max(x + y, x1 + y1))


tc = int(input())
while tc > 0:
	(a, b) = map(int, input().split())
	print(min((a + b) // 3, min(a, b)))
	tc -= 1


def solve(a, b):
	return min(a, b, (a + b) // 3)

def main():
	t = int(input())
	for i in range(t):
		(a, b) = map(int, input().split())
		print(solve(a, b))
main()


t = int(input())
for _ in range(t):
	m = input().split(' ')
	recursos = [int(m[0]), int(m[1])]
	recursos.append(int((recursos[0] + recursos[1]) / 3))
	print(min(recursos))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(maxm, minm) = (max(a, b), min(a, b))
	if a == 0 or b == 0:
		print(0)
	elif 2 * minm <= maxm:
		print(minm)
	else:
		print(int((a + b) / 3))


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	mini = min(a, b)
	maxi = max(a, b)
	if mini * 2 <= maxi:
		print(mini, end='\n')
		continue
	print((a + b) // 3, end='\n')


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


t = int(input())
for _ in range(t):
	(sticks, diamonds) = list(map(int, input().split()))
	if sticks * 2 <= diamonds:
		ans = sticks
	elif diamonds * 2 <= sticks:
		ans = diamonds
	else:
		ans = (sticks + diamonds) // 3
	print(ans)


def ans(a, b):
	w = min(a, b)
	x = max(a, b)
	if x >= 2 * w:
		return w
	return (x + w) // 3
m = int(input())
for i in range(m):
	aa = input().split()
	a = int(aa[0])
	b = int(aa[1])
	print(ans(a, b))


t = int(input())
for i in range(t):
	ans = 0
	(a, b) = map(int, input().split())
	ans = 0
	while a > 0 and b > 0 and (b + a > 2):
		d = max(a // 4, 1)
		if b > a:
			(a, b) = (b, a)
		s = min(d, b)
		ans += s
		a -= 2 * s
		b -= s
	print(ans)


t = int(input())
for r in range(t):
	(a, b) = list(map(int, input().split()))
	c = 0
	if a == 0 or b == 0:
		c = 0
	elif a == b:
		c = 2 * a // 3
	elif 2 * a < b:
		c = a
	elif 2 * b < a:
		c = b
	else:
		c = (a + b) // 3
	print(c)


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 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())

	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())
material = [list(map(int, input().split())) for _ in range(t)]
ans = []
for i in range(t):
	(gym, stick) = material[i]
	if gym < stick:
		(gym, stick) = (stick, gym)
	if gym == 0 or stick == 0:
		ans.append(0)
		continue
	ans.append(min(gym, stick, (gym + stick) // 3))
print('\n'.join(map(str, ans)))


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	ans = (a + b) // 3
	if a < (a + b) // 3:
		ans = a
	if b < (a + b) // 3:
		ans = b
	if a == 0 or b == 0:
		ans = 0
	print(ans)


t = int(input())
A = []
for i in range(t):
	(a, b) = map(int, input().split())
	if abs(a - b) <= (a + b) / 3:
		A.append((a + b) // 3)
	else:
		A.append(min(a, b))
for i in range(t):
	print(A[i])


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


import sys
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ans = 0
	if n == m:
		ans = (n + m) // 3
	elif n < m:
		d = m - n
		if n < d:
			ans = n
		else:
			n = n - d
			m = m - 2 * d
			ans = d
			ans += (n + m) // 3
	else:
		d = n - m
		if m < d:
			ans = m
		else:
			m = m - d
			n = n - 2 * d
			ans = d
			ans += (m + n) // 3
	print(ans)


a = int(input())
for i in range(0, a):
	(a, b) = map(int, input().split())
	arr = [a, b]
	arr.sort()
	ans = arr[1] - arr[0]
	arr[0] = arr[0] - ans
	arr[1] = arr[1] - 2 * ans
	if arr[0] < 0:
		print(min(max(a, b) // 2, min(a, b)))
	elif arr[0] % 3 == 0:
		print(2 * arr[0] // 3 + ans)
	elif arr[0] % 3 == 1:
		print(2 * arr[0] // 3 + ans)
	else:
		print(2 * arr[0] // 3 + ans)


import sys

def ii():
	return sys.stdin.readline().strip()

def idata():
	return [int(x) for x in ii().split()]

def solve_of_problem():
	(a, b) = idata()
	(a, b) = (min(a, b), max(a, b))
	c = b - a
	if c > a:
		print(a)
	else:
		a -= c
		ans = c
		ans += 2 * (a // 3)
		a %= 3
		if a == 2:
			print(ans + 1)
		else:
			print(ans)
	return
for ______ in range(int(ii())):
	solve_of_problem()


t = int(input())
for i in range(t):
	(a, b) = [int(item) for item in input().split()]
	if 2 * a - b > 0 and 2 * b - a > 0:
		out = int((a + b) / 3)
	else:
		out = min(a, b)
	print(out)


from math import *
from copy import *
from string import *
from random import *
from sys import stdin, stdout
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math
import math
import time
from queue import Queue

def seive(n):
	l = [True]
	l = l * (n + 1)
	for i in range(2, int(sqrt(n)) + 1):
		if l[i] == True:
			val = i * i
			while val < len(l):
				l[val] = False
				val += i
	prime = []
	for i in range(2, len(l)):
		if l[i] == True:
			prime.append(i)
	return prime

def dp(l, i, n, val, ans):
	if i >= n or val < 0:
		return 1000000
	elif val == 0:
		return 0
	else:
		if ans[i] == 1000000:
			ans[i] = min(min(1 + dp(l, i + 1, n, val - l[i], ans), 1 + dp(l, i, n, val - l[i], ans)), dp(l, i + 1, n, val, ans))
		return ans[i]
from queue import Queue
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split(' '))
	if a >= b * 2:
		print(b)
	elif b >= a * 2:
		print(a)
	else:
		print((a + b) // 3)


n = int(input())
for case in range(n):
	(a, b) = [int(_) for _ in input().split()]
	res = 0
	podmienka = True
	while podmienka:
		if a == b:
			res += 2 * (a // 3)
			a -= 2 * (a // 3) * (3 / 2)
			b -= 2 * (b // 3) * (3 / 2)
			if int(a) == 2 and int(b) == 2:
				print(res + 1)
			else:
				print(res)
			podmienka = False
		elif 2 * a <= b and a >= 1 and (b > 1):
			print(a)
			podmienka = False
		elif 2 * b <= a and a > 1 and (b >= 1):
			print(b)
			podmienka = False
		elif a > b and a >= 2 and (b >= 1):
			rozdiel = a - b
			rozdiel //= 2
			if rozdiel == 0:
				a -= 2
				b -= 1
				res += 1
			else:
				a -= 2 * rozdiel
				b -= rozdiel
				res += rozdiel
		elif a < b and a >= 1 and (b >= 2):
			rozdiel = b - a
			rozdiel //= 2
			if rozdiel == 0:
				a -= 1
				b -= 2
				res += 1
			else:
				b -= 2 * rozdiel
				a -= rozdiel
				res += rozdiel
		else:
			print(int(res))
			podmienka = False


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


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


for t in range(int(input())):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	b = min(b, 2 * a)

	def solve(a, b):
		c = (a + b) // 3
		return a - c + (2 * c - a) if a - c >= 0 and 2 * c - a >= 0 else 0
	print(max([solve(a, b), solve(a, b - 1), solve(a - 1, b), solve(a - 1, b - 1)]))


testCases = int(input())
for i in range(testCases):
	(a, b) = list(map(int, input().split()))
	x = abs(a - b)
	if x >= a or x >= b:
		print(min(a, b))
	else:
		print(x + 2 * (min(a, b) - x) // 3)


n = int(input())
for i in range(0, n):
	(sticks, diamonds) = [int(i) for i in input().split()]
	print(min(sticks, diamonds, (sticks + diamonds) // 3))


t = int(input())
while t > 0:
	(n, m) = map(int, input().split())
	a = max(n, m)
	b = min(n, m)
	diff = a - b
	if b > diff:
		eq = b - diff
		if eq % 3 == 2:
			diff += 1
		print(diff + eq // 3 * 2)
	else:
		print(b)
	t -= 1


from sys import stdin, stdout
t = int(stdin.readline())
for _ in range(t):
	(s, d) = map(int, stdin.readline().strip().split())
	print(min(min(s, d), (s + d) // 3))


for t in range(int(input())):
	(a, b) = list(map(int, input().split()))
	if a == 0 or b == 0:
		print(0)
	else:
		if (a + b) % 3 == 0:
			ans = (a + b) // 3
			if ans > min(a, b):
				ans = min(a, b)
		else:
			ans = (a + b) // 3
			if ans > min(a, b):
				ans = min(a, b)
		print(ans)


t = int(input())
for _ in range(t):
	s = list(map(int, input().split()))
	print(min(s[0], s[1], (s[0] + s[1]) // 3))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	rem = b - a
	if b >= 2 * a:
		print(a)
	else:
		x = a - rem
		an = x // 3 * 2 + max(0, x % 3 - 1)
		print(an + rem)


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


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	dif = b - a
	m = min(a, dif, b // 2)
	total = m
	a -= m
	b -= m * 2
	m = min(a // 3, b // 3)
	total += 2 * m
	a -= m * 3
	b -= m * 3
	(a, b) = (min(a, b), max(a, b))
	rest = min(b // 2, a)
	total += rest
	print(total)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	small = min(a, b)
	large = a + b - small
	if small == 0:
		print(0)
		continue
	if large >= 2 * small:
		print(small)
		continue
	else:
		qsmall = small // 3
		qlarge = large // 3
		rsmall = small % 3
		rlarge = large % 3
		ans = qsmall + qlarge
		if rsmall + rlarge >= 3:
			print(ans + 1)
			continue
		print(ans)


t = int(input())
for _ in range(t):
	(a, b) = list(map(int, input().split()))
	if a == b:
		if a == 2:
			print(1)
		elif a == 3:
			print(2)
		else:
			f = a // 3
			if a % 3 == 2:
				print(2 * f + 1)
			else:
				print(2 * f)
	else:
		m = min(a, b)
		n = max(a, b)
		if n >= 2 * m:
			print(m)
		elif m == 0:
			print(0)
		else:
			c = 0
			c = c + n - m
			m = m - c
			if m == 2:
				print(c + 1)
			elif m == 3:
				print(c + 2)
			else:
				f = m // 3
				if m % 3 == 2:
					c = c + f * 2 + 1
				else:
					c = c + f * 2
				print(c)


from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write
for _ in range(int(cin())):
	(a, b) = map(int, cin().split())
	if not a or not b:
		cout('0\n')
		continue
	elif a == b:
		cout(str(a * 2 // 3) + '\n')
		continue
	cout(str((min(a, b) + min(a + b - min(a, b), min(a, b) * 2)) // 3) + '\n')


def ques1(a, b):
	if a == 0 or b == 0:
		print(0)
		return
	p = min(a, b)
	sum1 = a + b
	ans = sum1 // 3
	if p == a:
		if p < 2 * b:
			print(min(p, ans))
			return
	if p == b:
		if p < 2 * a:
			print(min(p, ans))
			return
t = int(input())
for i in range(t):
	(a, b) = [int(i) for i in input().split()]
	ans = ques1(a, b)
	ans


from math import ceil
for _ in range(int(input())):
	(m, n) = map(int, input().split())
	a = min(m, n)
	b = max(m, n)
	if a * 2 <= b:
		print(a)
	else:
		c = 0
		while a != b and a > 1 and (b > 1):
			if b > a:
				d = a // 2
				a = a - d
				b = b - d * 2
				c += d
			else:
				d = b // 2
				b = b - d
				a = a - d * 2
				c += d
		c += (a + b) // 3
		print(c)


T = int(input())
for i in range(T):
	x = list(map(int, input().split()))
	a = x[0]
	b = x[1]
	if a >= b * 2 or b >= a * 2:
		print(min(a, b))
		continue
	if a == 0 or b == 0:
		print(0)
		continue
	d = abs(a - b)
	if a > b:
		b -= d
		a -= d * 2
	else:
		b -= d * 2
		a -= d
	if a > 2 and b > 2:
		temp = a // 3
		d += temp * 2
		a -= temp * 3
		b -= temp * 3
	if a == 2:
		print(d + 1)
	else:
		print(d)


import math
t = int(input())
for i in range(t):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	eme = 0
	run = True
	if a == 0 or b == 0:
		run = False
	elif a / b <= 0.5:
		eme = a
		run = False
	elif b / a <= 0.5:
		eme = b
		run = False
	while a > 0 and b > 0 and (a + b != 2) and run:
		if a == b:
			eme += a * 2 / 3
			eme = math.floor(eme)
			break
		elif a > b:
			n = a - b
			a -= 2 * n
			b -= n
			eme += n
		elif b > a:
			n = b - a
			a -= n
			b -= 2 * n
			eme += n
	print(eme)


def solve(a, b):
	if a == 0 or b == 0 or (a, b) == (1, 1):
		return 0
	if (a, b) in [(1, 2), (2, 1), (2, 2)]:
		return 1
	if a == b:
		return 2 * (a // 3) + solve(a % 3, a % 3)
	mx = max(a, b)
	mn = min(a, b)
	t = min(mx - mn, mn)
	return t + solve(mx - 2 * t, mn - t)
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	print(solve(a, b))


a = int(input())
h = []
for i in range(0, a):
	(x, y) = list(map(int, input().split()))
	if x == 0 or y == 0:
		h.append(0)
	else:
		s = x + y
		k = s // 3
		h.append(min(min(x, y), k))
print(*h, sep='\n')


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(t,) = I()
for i in range(t):
	(a, b) = I()
	if a > b:
		(a, b) = (b, a)
	x = (a + b) // 3
	print(min(a, x))


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


def func(a, b):
	n = a / 3
	if a < 3:
		if a == 1 or a == 0:
			return 0
		else:
			return 1
	elif n == int(n):
		n = int(n)
		return n * 2
	else:
		r = round(n)
		if r > int(n):
			n = int(n)
			return n * 2 + 1
		else:
			n = int(n)
			return n * 2
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a == b:
		print(func(a, b))
	elif a > b * 2 or b > a * 2:
		print(min(a, b))
	else:
		diff = abs(a - b)
		m = min(a, b)
		x = m - diff
		c = diff + func(x, x)
		print(c)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
	else:
		ab = (a + b) // 3
		if ab > b and b < a:
			print(b)
		elif ab > a and a < b:
			print(a)
		else:
			print(ab)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
testcases = int(input())
for j in range(testcases):
	(a, b) = map(int, input().split())
	outy = 0
	maxy = max(a, b)
	miny = min(a, b)
	diff = abs(maxy - miny)
	v1 = min(miny, diff)
	outy += v1
	maxy -= 2 * v1
	miny -= v1
	outy += 2 * (miny // 3)
	maxy -= 3 * (miny // 3)
	miny = miny % 3
	if miny == 1:
		if maxy >= 2:
			outy += 1
	elif miny == 2:
		if maxy >= 4:
			outy += 2
		elif maxy >= 2:
			outy += 1
	print(outy)


t = int(input())
for test in range(t):
	(n, m) = [int(x) for x in input().split()]
	a = max(n, m)
	b = min(n, m)
	if min == 0:
		print(0)
		continue
	if b * 2 <= a:
		print(b)
	else:
		ans = (a + b) // 3
		print(ans)


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)


def sas(a, b):
	if a == 0 or b == 0:
		print(0)
		return
	elif b > a:
		c = int((a + b) // 3)
		if a >= c:
			print(c)
		else:
			print(a)
	else:
		c = int((a + b) // 3)
		if b >= c:
			print(c)
		else:
			print(b)
	return
n = int(input())
for i in range(n):
	t = input()
	l = list(map(int, t.split(' ')))
	sas(l[0], l[1])


tests = int(input())
for i in range(tests):
	numbers = input().split(' ')
	a = int(numbers[0])
	b = int(numbers[1])
	res = 0
	if a < b:
		temp = a
		a = b
		b = temp
	if a >= 2 * b:
		print(b)
	else:
		res += a - b
		draw = b - res
		if draw % 3 <= 1:
			res += draw // 3 * 2
			print(res)
		else:
			res += draw // 3 * 2 + 1
			print(res)


test = int(input())

def solve():
	(a, b) = [int(i) for i in input().split()]
	print(min(min(a, b), (a + b) // 3))
while test:
	solve()
	test -= 1


inp = lambda : list(map(int, input().split()))
min_max = lambda x: (max(x), min(x))
for _ in range(int(input())):
	res = 0
	(m, n) = min_max(inp())
	res += min(m - n, n)
	c = n - res
	res += 2 * (c // 3) + (1 if c % 3 == 2 else 0)
	print(res)


from sys import stdin, stdout
import math
input = stdin.readline

def print(x):
	stdout.write(str(x) + '\n')

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


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)


import sys
import math
from sys import stdin, stdout

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()

def main():
	for t in range(int(input())):
		(a, b) = get_ints()
		if a == 0 or b == 0:
			print(0)
		else:
			fff = 0
			if a > b:
				(a, b) = (b, a)
			if b >= a and b <= 2 * a:
				d = b - a
				fff = 1
				tt = d
				a1 = a - d
				b1 = b - 2 * d
				a = a1
				b = b1
			c = 0
			g = min(a, b // 2)
			k = a - g
			if k >= 2 and b % 2 > 0:
				g += 1
			h = min(b, a // 2)
			k = b - h
			if k >= 2 and a % 2 > 0:
				h += 1
			f = min(a // 3, b // 3)
			c += f * 2
			a = a % 3
			b = b % 3
			if a >= 2 and b >= 1:
				c += 1
			elif b >= 2 and a >= 1:
				c += 1
			if fff == 1:
				print(max(c, g, h) + tt)
			else:
				print(max(c, g, h))
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


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


def solve(x, y):
	mx = max(x, y)
	mn = min(x, y)
	n1 = mn // 3
	r = mx - 3 * n1
	l = mn - 3 * n1
	n = max(min(n1, (r - 2 * l) // 3), 0)
	return n1 * 2 + min(l + n, (r - n) // 2)
t = int(input())
for i_t in range(t):
	[x, y] = list(map(int, input().split(' ')))
	print(solve(x, y))


n = int(input())
a = []
for i in range(n):
	b = list(map(int, input().split()))
	m = min(b)
	if sum(b) // 3 > m:
		a.append(m)
	else:
		a.append(sum(b) // 3)
for i in a:
	print(i)


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


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

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

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True
for i in range(ii()):
	(a, b) = mi()
	if a > 2 * b:
		print(b)
	elif b > a * 2:
		print(a)
	else:
		print((a + b) // 3)


T = int(input())
for _ in range(T):
	(a, b) = map(int, input().strip().split())
	if a < b:
		(a, b) = (b, a)
	diff = a - b
	crafted = min(diff, b)
	a -= 2 * crafted
	b -= crafted
	if a == b:
		crafted += a // 3 * 2
		a %= 3
		b %= 3
		if a == 2:
			crafted += 1
	print(crafted)


from sys import stdin, stdout
import math, queue, heapq
fastinput = stdin.readline
fastout = stdout.write
t = int(fastinput())
while t:
	t -= 1
	(n, m) = map(int, fastinput().split())
	(n, m) = (min(n, m), max(n, m))
	r = m - n
	if m >= 2 * n:
		print(n)
	else:
		n -= r
		print(r + 2 * n // 3)


import sys
import collections
t = int(sys.stdin.readline().strip())
for i in range(t):
	(a, b) = list(map(int, sys.stdin.readline().strip().split(' ')))
	if a < b:
		(a, b) = (b, a)
	if a >= 2 * b:
		print(b)
	else:
		cnt = 0
		while a >= 2 and b >= 1 or (a >= 1 and b >= 2):
			if a == b:
				if a == 2:
					cnt += 1
					a -= 2
					b -= 1
				else:
					m = a // 3
					a = a % 3
					b = b % 3
					cnt += m * 2
			elif a > b:
				m = a - b
				a -= 2 * m
				b -= 1 * m
				cnt += m
			else:
				m = b - a
				a -= 1 * m
				b -= 2 * m
				cnt += m
		print(cnt)


for _ in range(int(input())):
	(sticks, diamonds) = map(int, input().split())
	ans = 0
	if sticks < 2 and diamonds < 2 or not sticks or (not diamonds):
		pass
	elif sticks // 2 > diamonds:
		ans = diamonds
	elif diamonds // 2 > sticks:
		ans = sticks
	elif sticks >= diamonds:
		ans = max(sticks // 2, (sticks + diamonds) // 3)
	else:
		ans = max(diamonds // 2, (sticks + diamonds) // 3)
	print(ans)


R1 = lambda : list(map(int, input().split()))
R2 = lambda : int(input())
for _ in range(R2()):
	(l, r) = R1()
	print(min(l, r, (l + r) // 3))


def solve():
	(a, b) = map(int, input().split())
	k = (a + b) // 3
	print(min(a, b, k))

def main():
	for _ in range(int(input())):
		solve()
main()


T = int(input())
while T > 0:
	(a, b) = [int(el) for el in input().split(' ')]
	M = int((a + b) / 3)
	M1 = min(a, M)
	M2 = min(b, M)
	M = min(M1, M2)
	print(M)
	T -= 1


from collections import Counter
import math
import sys
from bisect import bisect, bisect_left, bisect_right

def input():
	return sys.stdin.readline().strip()

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def mod():
	return 10 ** 9 + 7
for _ in range(INT()):
	(a, b) = MAP()
	s = a + b
	s = s // 3
	x = min(s, min(a, b))
	print(x)


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


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


def f():
	(a, b) = [int(s) for s in input().split()]
	if a > b:
		(a, b) = (b, a)
	x = b - a
	if x >= a:
		print(a)
		return
	y = (b - 2 * x) // 3
	r = (b - 2 * x) % 3
	ans = x + 2 * y
	if r == 2:
		ans += 1
	print(ans)
	return
for t in range(int(input())):
	f()


import sys
input = sys.stdin.readline

def swap(a, b):
	return (b, a)
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if b > a:
		(a, b) = swap(a, b)
	if a == 0 or b == 0:
		count = 0
	elif a >= b * 2:
		count = b
	else:
		count = (a + b) // 3
	print(count)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	(mx, mn) = (max(a, b), min(a, b))
	if mn <= mx / 2:
		print(mn)
	else:
		print(int((mx + mn) / 3))


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
for _ in range(int(input())):
	(x, y) = ilele()
	print(min(x, y, (x + y) // 3))


for test in range(int(input())):
	(a, b) = map(int, input().split())
	if b > a:
		(a, b) = (b, a)
	count = min(a - b, b, a // 2)
	a -= 2 * count
	b -= count
	if a > 0 and b > 0:
		count += a // 3 * 2
		a = a % 3
		b = b % 3
		if a + b >= 3:
			count += 1
	print(count)


for _ in range(int(input())):
	(a, b) = sorted(map(int, input().split()))
	if a == 0:
		print(0)
		continue
	d = b - a
	if d > a:
		print(a)
		continue
	a -= d
	b -= 2 * d
	if a == 0:
		print(d)
		continue
	print(d + (a + b) // 3)


from sys import stdin, stdout
for test in range(int(stdin.readline())):
	arr = [int(x) for x in stdin.readline().split()]
	a = arr[0]
	b = arr[1]
	if a >= 2 * b or b >= 2 * a:
		stdout.write(str(min(a, b)) + '\n')
	else:
		ans1 = max(a, b) - min(a, b)
		a = min(a, b) - ans1
		ans = a // 3
		left = a - 3 * ans
		if left == 0 or left == 1:
			stdout.write(str(2 * ans + ans1) + '\n')
		else:
			stdout.write(str(2 * ans + 1 + ans1) + '\n')


def gns():
	return list(map(int, input().split()))
t = int(input())
for i in range(t):
	(a, b) = gns()
	(a, b) = (max(a, b), min(a, b))
	if a >= b * 2:
		print(b)
		continue
	ans = a - b
	b = b - (a - b)
	ans += b // 3 * 2
	b = b % 3
	if b == 2:
		ans += 1
	print(ans)


z = input
c = 0
for i in range(int(z())):
	(a, b) = list(map(int, z().split()))
	m = max(a, b)
	mi = min(a, b)
	print(min(mi, (m + mi) // 3))


t = input()
t = int(t)

def solve(a, b):
	k = 0
	if a == 0 or b == 0:
		print(0)
		return
	if a > b:
		(a, b) = (b, a)
	if b >= 2 * a:
		k += a
	else:
		k += b - a
		k += (2 * a - b) // 3 * 2
		if (2 * a - b) % 3 == 2:
			k += 1
	print(k)
for i in range(t):
	(a, b) = map(int, input().split())
	solve(a, b)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	if b >= 2 * a:
		print(a)
	else:
		k = 2 * a - b
		q = k // 3
		r = k % 3
		ans = b - a + 2 * q
		if r == 2:
			ans += 1
		print(ans)


import math
for w in range(int(input())):
	x = list(map(int, input().split()))
	x.sort()
	if x[0] > 0 and x[1] > 0:
		if x[1] - x[0] >= x[0]:
			print(x[0])
		else:
			print(int((x[0] + x[1]) / 3))
	else:
		print(0)


k = int(input())
for t in range(k):
	(l, r) = [int(i) for i in input().split(' ')]
	print(min(l, r, (l + r) // 3))


import sys
input = sys.stdin.readline

def main():
	for t in range(int(input())):
		(a, b) = map(int, input().split())
		if a > b:
			(a, b) = (b, a)
		if a <= b - a:
			s = a
		else:
			x = b - a
			a -= x
			b -= 2 * x
			s = x
			if a > 0:
				s += a // 3 * 2
				if a % 3 == 2:
					s += 1
		print(s)
main()


import sys
input = sys.stdin.buffer.readline

def solution():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		x = min(n, m)
		y = max(n, m)
		if x <= y // 2:
			print(x)
		else:
			print((n + m) // 3)
solution()


t = int(input())
while t > 0:
	t -= 1
	r = 0
	l = [int(x) for x in input().split()]
	a = l[0]
	b = l[1]
	if b > a:
		aux = a
		a = b
		b = aux
	if a - b > b:
		r = b
	else:
		r = a - b
		a -= 2 * r
		b -= r
		r += a // 3 * 2 + (a % 3 == 2 and 1 or 0)
	print(r)


a = int(input())
for i in range(a):
	(x, y) = map(int, input().split())
	print(min(x, y, (x + y) // 3))


t = int(input())
for i in range(t):
	(s, d) = map(int, input().split())
	p = (s + d) // 3
	if s != 0 and d != 0:
		print(min(s, d, p))
	else:
		print('0')


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

def solve():
	[a, b] = as_list()
	solutions = 0
	while True:
		if a == 0 or b == 0:
			return solutions
		if a == b:
			if a == 1:
				return solutions
			if a == 2:
				return 1 + solutions
			x = a // 3
			solutions += 2 * x
			a -= 3 * x
			b -= 3 * x
		if a < b:
			[a, b] = [b, a]
		if 2 * b <= a:
			return solutions + b
		x = (a - b) // 2
		if 2 * x < a - b:
			x += 1
		solutions += x
		a -= 2 * x
		b -= x
[tests] = as_list()
for _ in range(tests):
	print(solve())


for i in range(int(input())):
	(a, b) = list(map(int, input().split()))
	c = 0
	if b < a:
		(a, b) = (b, a)
	if a * 2 <= b:
		c = a
	else:
		c = b - a
		a -= c
		c += a * 2 // 3
	print(c)


t = int(input())
res = [None for i in range(t)]
for i in range(t):
	k = 0
	(a, b) = map(int, input().split())
	if a > b * 2 or b > a * 2:
		if a > 0 and b > 0:
			res[i] = min(a, b)
		else:
			res[i] = 0
	elif a > 0 and b > 0 and (not (a > b * 2 or b > a * 2)):
		k += a + b
		res[i] = k // 3
	else:
		res[i] = 0
for i in range(t):
	print(res[i])


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


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	diff = b - a
	pair = min(a, b)
	ret = min(diff, pair)
	pair -= diff
	if pair > 0:
		ret += pair // 3 * 2
		if pair % 3 == 2:
			ret += 1
	print(ret)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
	else:
		(a, b) = (max(a, b), min(a, b))
		if a >= 2 * b:
			print(b)
		else:
			diff = a - b
			a -= diff * 2
			count = diff + a // 3 * 2
			if a % 3 == 2:
				count += 1
			print(count)


def solve(a, b):
	if a == b:
		return (a + b) // 3
	elif a == 0 or b == 0:
		return 0
	else:
		p = b - a
		if p >= a:
			return a
		else:
			b = b - 2 * p
			a = a - p
			return p + (a + b) // 3
for _ in range(int(input())):
	(a, b) = sorted(list(map(int, input().split())))
	print(solve(a, b))


for _ in [0] * int(input()):
	(a, b) = list(map(int, input().split()))
	min1 = min(a, b)
	print(min(min1, (a + b) // 3))


from sys import stdin, stdout
test = int(stdin.readline())
for _ in range(test):
	(a, b) = map(int, stdin.readline().split())
	print(min((a + b) // 3, min(a, b)))


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def instr():
	return str(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
from collections import Counter

def main():
	t = inp()
	for _ in range(t):
		(a, b) = inlt()
		(a, b) = (max(a, b), min(a, b))
		if a >= 2 * b:
			print(b)
		else:
			print((a + b) // 3)
main()


import sys
fast_reader = sys.stdin.readline
fast_writer = sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i) for i in argv)) + '\n')

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

def sep_input():
	return map(int, input().split())
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)


import math
for ad in range(int(input())):
	(a, b) = list(map(int, input().split()))
	x = min(a, b)
	y = max(a, b)
	diff = y - x
	if y >= 2 * x:
		print(x)
	else:
		y -= diff * 2
		x -= diff
		count = diff
		count += 2 * (x // 3)
		x %= 3
		if x == 2:
			count += 1
		print(count)


tc = int(input())
for _ in range(tc):
	(stick, diamond) = list(map(int, input().split()))
	if stick >= 2 * diamond:
		print(diamond)
	elif diamond >= 2 * stick:
		print(stick)
	else:
		diff = abs(diamond - stick)
		Sum = diamond + stick
		pog = Sum // 3
		print(pog)


def ss(a, b):
	if a < 2 and b < 2 or (a <= 0 or b <= 0):
		return 0
	if a < b:
		(a, b) = (b, a)
	if b <= a // 2:
		return b
	elif a <= 5:
		x = a - 2
		y = b - 1
		return 1 + ss(x, y)
	else:
		e = a // 4
		x = a - 2 * (a // 4)
		y = b - e
		return e + ss(x, y)
t = int(input())
for k in range(t):
	(a, b) = map(int, input().split())
	print(ss(a, b))


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	if n == 0 or m == 0:
		print(0)
	else:
		print(min(min(n, m), (n + m) // 3))


import os
import sys
from io import BytesIO, IOBase

def readvars():
	k = map(int, input().split())
	return k

def readlist():
	li = list(map(int, input().split()))
	return li

def anslist(li):
	ans = ' '.join([str(v) for v in li])
	return ans

def main():
	t = 1
	t = int(input())
	for xx in range(t):
		(a, b) = readvars()
		(x, y) = (max(a, b), min(a, b))
		d = 2 * y - x
		if d <= 0:
			print(y)
		else:
			ans = d // 3 * 2
			x -= d // 3 * 3
			y -= d // 3 * 3
			ans += min(x // 2, y)
			print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def bc(a, b):
	if a == 0 or b == 0:
		return 0
	if a == 1 and b == 1:
		return 0
	if a > 1 and b > 1:
		return 1 + max(bc(a - 2, b - 1), bc(a - 1, b - 2))
	return 1

def abc(a, b):
	if a <= 0 or b <= 0:
		return 0
	if a <= 1 and b <= 1:
		return 0
	if a >= b:
		return 1 + abc(a - 2, b - 1)
	return 1 + abc(a - 1, b - 2)
from math import ceil
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	y = max(a, b)
	x = min(a, b)
	if y - x >= x:
		print(x)
	else:
		ans = y - x
		x = 2 * x - y
		if x != 1:
			m = ceil((x - 1) / 3)
			c = 2 * m - 1
			d = (x - 2) % 3
			if d == 0:
				ans += c
			else:
				ans += c + 1
		print(ans)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	m = b - a
	if m > a:
		m = a
	a -= m
	b -= 2 * m
	m += a // 3 * 2
	a %= 3
	if a == 2:
		m += 1
	print(m)


import sys

def input():
	return sys.stdin.readline().rstrip()

def input_split():
	return [int(i) for i in input().split()]
testCases = int(input())
answers = []
for _ in range(testCases):
	(a, b) = input_split()
	(a, b) = (max(a, b), min(a, b))
	if a / 2 <= b:
		x = (2 * a - b) // 3
		y = (2 * b - a) // 3
		if 2 * (x + 1) + y <= a and x + 1 + 2 * y <= b:
			ans = x + y + 1
		elif 2 * x + y + 1 <= a and x + 1 + 2 * (y + 1) <= b:
			ans = x + y + 1
		else:
			ans = x + y
	else:
		ans = b
	answers.append(ans)
print(*answers, sep='\n')


for _ in range(int(input())):
	(s, d) = map(int, input().split())
	if s == 0 or d == 0:
		ans = 0
	elif max(s, d) >= 2 * min(s, d):
		ans = min(s, d)
	else:
		ans = (s + d) // 3
	print(ans)


cases = int(input().split()[0])
for i in range(cases):
	currInput = input().split()
	numSticks = int(currInput[0])
	numDiamonds = int(currInput[1])
	if numSticks >= 2 * numDiamonds:
		print(numDiamonds)
	elif numDiamonds >= 2 * numSticks:
		print(numSticks)
	else:
		total = numDiamonds + numSticks
		if total % 3 == 0:
			print(int(total / 3))
		elif total % 3 == 1:
			print(int((total - 1) / 3))
		else:
			print(int((total - 2) / 3))


t = int(input())
while t > 0:
	(a, b) = map(int, input().split())
	if 2 * a <= b:
		print(a)
	elif 2 * b <= a:
		print(b)
	else:
		k = abs(a - b)
		ans = k
		a -= k
		b -= k
		if a > b:
			a -= k
		else:
			b -= k
		ans += a // 3 * 2 + (1 if a % 3 == 2 else 0)
		print(ans)
	t -= 1


for t in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	(a, b) = (min(a, b), max(a, b))
	c = b - a
	if c > a:
		print(a)
	else:
		a -= c
		ans = c
		ans += 2 * (a // 3)
		a %= 3
		if a == 2:
			print(ans + 1)
		else:
			print(ans)


from fractions import Fraction
import bisect
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
from queue import Queue

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
mod = int(1000000000.0) + 7
for _ in range(iinput()):
	(a, b) = get_ints()
	if a > b:
		(a, b) = (b, a)
	if b >= 2 * a:
		print(a)
	else:
		ans = b - a
		a -= ans
		ans += 2 * (a // 3)
		if a % 3 == 2:
			print(ans + 1)
		else:
			print(ans)


import math
for i in range(0, int(input())):
	(a, b) = map(int, input().split())
	y = (2 * b - a) // 3
	if y < 0:
		y = 0
	x1 = b - 2 * y
	x2 = (a - y) // 2
	x = min(x1, x2)
	if x < 0:
		x = 0
		y = a - 2 * x
	print(x + y)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
		continue
	c = min(a, b)
	d = (a + b) // 3
	print(min(c, d))


q = int(input())
for _ in range(q):
	(a, b) = map(int, input().split())
	(a, b) = (max(a, b), min(a, b))
	if b <= a // 2:
		print(b)
		continue
	d = a - b
	a -= d * 2
	b -= d
	ans = d
	ans += a // 3 * 2
	a %= 3
	b %= 3
	if a > 1 and b > 0 or (a > 0 and b > 1):
		ans += 1
	print(ans)


def emeralds(a, b):
	return min(a, b, (a + b) // 3)
t = int(input())
for i in range(t):
	x = list(map(int, input().rstrip().split()))
	print(emeralds(x[0], x[1]))


for i in range(int(input())):
	(n, m) = map(int, input().split())
	ans = 0
	if m > n:
		(m, n) = (n, m)
	if n != m:
		temp = min(n - m, m)
		m -= temp
		n -= temp * 2
		ans += temp
	if n >= 3 and m >= 3:
		temp = min(n // 3, m // 3)
		n -= temp * 3
		m -= temp * 3
		ans += temp * 2
	if n >= 1 and m >= 2:
		temp = min(n, m // 2)
		n -= temp
		m -= temp * 2
		ans += temp
	(n, m) = (m, n)
	if n >= 1 and m >= 2:
		temp = min(n, m // 2)
		n -= temp
		m -= temp * 2
		ans += temp
	print(ans)


from sys import stdin, stdout
import collections
import heapq
import itertools
import functools
import math
import operator
import string
ALPHABET = string.ascii_lowercase
DIGITS = string.digits

def read_line():
	return stdin.readline().strip()

def read_int():
	return int(read_line())

def read_arr():
	return read_line().split(' ')

def read_int_arr():
	return [int(x) for x in read_arr()]

def query_interactive(s):
	print(s)
	stdout.flush()

def solve():
	(a, b) = read_int_arr()
	if a > b:
		(a, b) = (b, a)
	num_singular = min(b - a, a, b // 2)
	a -= num_singular
	b -= 2 * num_singular
	if a > b:
		(a, b) = (b, a)
	num_both = min(a, b) // 3
	a -= num_both * 3
	b -= num_both * 3
	rem = 0
	if b >= 2 and a >= 1:
		rem = 1
	print(num_singular + num_both * 2 + rem)

def main():
	T = 1
	T = read_int()
	for _ in range(T):
		solve()
main()


from sys import *
input = stdin.readline
n = int(input())
for _ in range(n):
	(x, y) = map(int, input().split())
	a = max(x, y)
	b = min(x, y)
	if a >= b * 2:
		print(b)
	elif a == 0 or b == 0:
		print(0)
	else:
		x = (2 * b - a) // 3
		if a - x < (b - 2 * x) * 2:
			x += 1
		print(b - x)


t = int(input())
for tc in range(t):
	(s, d) = map(int, input().split())
	if s >= 2 * d or d >= 2 * s:
		print(min(s, d))
	else:
		m = (s % 3 + d % 3) // 3
		n = s // 3 + d // 3
		print(m + n)


import sys
input = sys.stdin.readline

def calc_items(num_shovels, sticks, diamonds):
	if num_shovels * 2 < sticks or num_shovels < diamonds:
		return

def get_shovels(sticks, diamonds):
	return min(sticks // 2, diamonds)

def get_swords(sticks, diamonds):
	return min(sticks, diamonds // 2)
from math import floor

def solve(sticks, diamonds):
	if sticks < 2 or diamonds < 2:
		if sticks >= 1 and diamonds >= 2 or (diamonds >= 1 and sticks >= 2):
			return 1
		else:
			return 0
	if sticks > diamonds:
		diff = sticks - diamonds
		turns = min(diamonds, diff)
		return turns + solve(sticks - turns * 2, diamonds - turns)
	elif diamonds > sticks:
		diff = diamonds - sticks
		turns = min(sticks, diff)
		return turns + solve(sticks - turns, diamonds - turns * 2)
	if sticks == diamonds:
		return (sticks + diamonds) // 3
	num_shovels = get_shovels(sticks, diamonds)
	num_swords = get_swords(sticks, diamonds)
	a1 = num_shovels + get_swords(sticks - num_shovels * 2, diamonds - num_shovels)
	a2 = num_swords + get_shovels(sticks - num_swords, diamonds - num_swords * 2)
	a3 = 0
	if num_shovels > 0:
		num_shovels -= 1
		a3 = num_shovels + get_swords(sticks - num_shovels * 2, diamonds - num_shovels)
	a4 = 0
	if num_swords > 0:
		num_swords -= 1
		a4 = num_swords + get_shovels(sticks - num_swords, diamonds - num_swords * 2)
	return max(a1, a2, a3, a4)
t = int(input())
for _ in range(t):
	(sticks, diamonds) = map(int, input().split())
	print(solve(sticks, diamonds))


for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
	else:
		print(min(a, b, (a + b) // 3))


t = int(input())
while t:
	(a, b) = tuple(map(int, input().split()))
	k = 0
	if a > b:
		max = a
		min = b
	else:
		max = b
		min = a
	if min > 0 and max / min >= 2:
		print(min)
	elif a == 0 or b == 0:
		print(0)
	else:
		k = (a + b) // 3
		print(k)
	t -= 1


try:
	t = int(input())
	for _ in range(t):
		(a, b) = map(int, input().split(' '))
		d = (a + b) // 3
		ans = min(a, b)
		ans = min(ans, d)
		print(ans)
except:
	pass


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if True else 1):
	(a, b) = map(int, input().split())
	print(0 if a * b == 0 else min(min(a, b), (a + b) // 3))


tll = int(input())
while tll > 0:
	tll -= 1
	(a, b) = map(int, input().split())
	ans = 0
	while a + b >= 3:
		if a == 0 or b == 0:
			break
		if a == 1 or b == 1:
			ans += 1
			break
		if a == 2 and b == 2:
			ans += 1
			break
		if a > b:
			temp = b
			b = max(b - (a - b), 0)
			a = b
			ans += temp - b
		elif b > a:
			temp = a
			a = max(0, a - (b - a))
			b = a
			ans += temp - a
		else:
			sub = a // 3 * 2
			ans += sub
			a = a % 3
			b = b % 3
	print(ans)


t = int(input())
while t:
	(s, d) = map(int, input().split())
	if s == 0 or d == 0:
		print(0)
	elif min(s, d) * 2 <= max(s, d):
		print(min(s, d))
	else:
		s1 = s // 3
		s2 = s % 3
		d1 = d // 3
		d2 = d % 3
		if s2 == 2 and d2 == 1 or (s2 == 1 and d2 == 2) or (s2 == 2 and d2 == 2):
			print(s1 + d1 + 1)
		else:
			print(s1 + d1)
	t = t - 1


t = int(input())
list_ans = []
for i in range(t):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	if b >= 2 * a:
		list_ans.append(a)
	else:
		c = b - a
		a = a - c
		list_ans.append(a // 3 * 2 + c + min(a % 3, 2) // 2)
for item in list_ans:
	print(item)


for _ in range(int(input())):
	(a, b) = [int(s) for s in input().split()]
	m = min(a, b)
	ma = max(a, b)
	if ma > m * 2:
		ans = m
	else:
		ans = int((m + ma) / 3)
	print(ans)


from sys import stdin
import math

def inp():
	return stdin.readline().strip()
t = int(inp())
for _ in range(t):
	(a, b) = [int(x) for x in inp().split()]
	print(min((a + b) // 3, a, b))


from sys import stdin, stdout
from collections import Counter

def ai():
	return list(map(int, stdin.readline().split()))

def ei():
	return map(int, stdin.readline().split())

def ip():
	return int(stdin.readline().strip())

def op(ans):
	return stdout.write(str(ans) + '\n')
for i in range(ip()):
	(s, d) = ei()
	if s == 0 or d == 0:
		print(0)
	elif max(s, d) >= 2 * min(s, d):
		print(min(s, d))
	else:
		print((s + d) // 3)


import sys
input = sys.stdin.readline
for T in range(int(input())):
	(n, m) = list(map(int, input().split()))
	mn = min(n, m)
	mx = max(n, m)
	if 2 * mn <= mx:
		print(mn)
	else:
		print((mn + mx) // 3)


def countEmerald(a, b):
	count = -1
	mi = min(a, b)
	ma = max(a, b)
	if mi == 0 or ma == 0:
		count = 0
		return count
	elif ma >= 2 * mi:
		count = mi
		return count
	else:
		count = (mi + ma) // 3
		return count
n = int(input())
for i in range(n):
	(a, b) = list(map(int, input().split()))
	numofEmerald = countEmerald(a, b)
	print(numofEmerald)


def inp_n():
	return int(input())

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

def inp_mul_num():
	return map(int, input().split())

def is_odd(n):
	if n & 1:
		return True
	return False

def is_prime(n):
	i = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += 1
	return True
from collections import defaultdict
import math
for _ in range(inp_n()):
	(a, b) = inp_mul_num()
	print(min(a, b, (a + b) // 3))


for tt in range(int(input())):
	(a, b) = map(int, input().split())
	if a > b:
		(maxi, mini) = (a, b)
	else:
		(maxi, mini) = (b, a)
	if maxi >= 2 * mini:
		ans = mini
	else:
		ans = (maxi + mini) // 3
	print(ans)


t = int(input())
for _ in range(t):
	(a, b) = [int(x) for x in input().split()]
	if max(a, b) >= 2 * min(a, b):
		print(min(a, b))
		continue
	x = min(a, b)
	y = max(a, b)
	p = max(2 * x - y, 0)
	ans = p // 3 * 2
	x -= 3 * (p // 3)
	y -= 3 * (p // 3)
	ans += min(x, y // 2)
	print(ans)


t = int(input())
for i in range(0, t):
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	ans = 0
	if a > b:
		max = a
		min = b
	else:
		max = b
		min = a
	c = int((a + b) / 3)
	if c < min:
		ans = c
	else:
		ans = min
	print(ans)


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


import sys
t = int(input())
while t:
	t = t - 1
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	ans = 0
	if b >= 2 * a:
		print(a)
	else:
		print(int((a + b) / 3))


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if a != 0 and b != 0:
		if a / b >= 2 or b / a >= 2:
			print(min(a, b))
		else:
			print((a + b) // 3)
	else:
		print(0)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	(a, b) = (max(b, a), min(b, a))
	c = 0
	if a == 0 or b == 0:
		c = 0
	elif 2 * b < a:
		c = b
	else:
		d = a + b
		c = int(d / 3)
	print(c)


import sys
sys.setrecursionlimit(1000000)

def answer(a, b):
	if a == 0 or b == 0 or (a < 2 and b < 2):
		return 0
	elif a == b:
		if a % 3 == 2:
			return a // 3 * 2 + 1
		else:
			return a // 3 * 2
	elif abs(a - b) == 1:
		return 1 + answer(max(a, b) - 2, min(a, b) - 1)
	else:
		a1 = max(a, b)
		b1 = min(a, b)
		minNum = min((a1 - b1) // 2, b1)
		return minNum + answer(a1 - 2 * minNum, b1 - minNum)
t = int(input())
for T in range(t):
	[a, b] = list(map(int, input().split(' ')))
	print(answer(a, b))


from sys import stdin, stdout
import math, sys
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import bisect as bi
import heapq

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_right(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		(a, b) = In()
		print(min(a, b, (a + b) // 3))
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(I()):
	main()


import math
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	(a, b) = sorted([a, b])
	x = max(0, math.ceil((2 * a - b) / 3))
	print(x + (a - 2 * x))


n = int(input(''))
x = 0
for i in range(n):
	(a, b) = input('').split()
	a = int(a)
	b = int(b)
	if a == 0 or b == 0:
		print('0')
	elif min(a, b) * 2 <= max(a, b):
		print(min(a, b))
	else:
		x = (a + b) // 3
		print(x)
exit()


def craft(a, b):
	if a == 0 or b == 0:
		return 0
	ans = (a + b) // 3
	m = min(a, b)
	if ans <= m:
		return ans
	else:
		return m
T = int(input())
for i in range(T):
	(a, b) = [int(i) for i in input().split()]
	print(craft(a, b))


z = input
mod = 10 ** 9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0:
			return 0
	return 1
num = int(z())
for _ in range(num):
	(a, b) = map(int, z().split())
	print(min(a, b, (a + b) // 3))


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


T = int(input())
for t in range(T):
	(a, b) = map(int, input().split())
	t = min(a, b)
	a = max(a, b)
	b = t
	ans = 0
	rem = a - b
	ans += min(rem, b)
	a = max(a - 2 * rem, 0)
	b = max(b - rem, 0)
	rem = a
	if rem % 3 == 2:
		ans += 1
	rem = rem // 3
	ans += rem * 2
	print(ans)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def solve(a, b):
	(a, b) = (max(a, b), min(a, b))
	if a > 2 * b:
		return b
	ans = a - b
	(a, b) = (b - ans, b - ans)
	return ans + (a + b) // 3
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	print(solve(a, b))


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	c = min(a, b)
	d = max(a, b)
	if 2 * c <= d:
		print(int(c))
	else:
		print(int((c + d) / 3))


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


N = int(input())
for _ in range(N):
	(a, b) = map(int, input().split())
	res = 0
	sim = 0
	if a == 0 or b == 0:
		print(0)
		continue
	if a > b:
		if 2 * b <= a:
			print(b)
			sim = 1
	elif 2 * a <= b:
		print(a)
		sim = 1
	if sim:
		continue
	if a > b:
		aux = a - b
		print(aux + 2 * (b - aux) // 3)
	else:
		aux = b - a
		print(aux + 2 * (a - aux) // 3)


tc = int(input())
for _ in range(tc):
	(sticks, diamonds) = map(int, input().split())
	if sticks >= 2 * diamonds:
		print(diamonds)
	elif diamonds >= 2 * sticks:
		print(sticks)
	else:
		diff = abs(sticks - diamonds)
		bigger = max(sticks, diamonds)
		smaller = min(sticks, diamonds)
		emeralds = diff
		bigger -= diff * 2
		smaller -= diff
		pairs = bigger // 3 * 2
		emeralds += pairs
		smaller -= pairs // 2 * 3
		bigger -= pairs // 2 * 3
		if (bigger >= 1 and smaller >= 1) and (bigger >= 2 * smaller or smaller >= 2 * bigger or (bigger >= smaller + 1 or smaller >= bigger + 1) or (bigger >= 2 and smaller <= 2)):
			emeralds += 1
		print(emeralds)


def aa(a, b):
	mx = max(a, b)
	mi = min(a, b)
	diff = mx - mi
	x = min(diff, mi)
	out = x
	mx = mx - 2 * x
	mi = mi - x
	if mi >= 1 and mx >= 2 or (mi >= 2 and mx >= 2):
		out += 2 * (mi // 3)
		mi %= 3
		mx %= 3
	if mi >= 1 and mx >= 2:
		out += 1
		mx -= 2
		mi -= 1
	return out
t = int(input())
while t:
	t = t - 1
	(a, b) = map(int, input().split())
	print(aa(a, b))


from sys import stdin
input = iter(stdin.readlines()).__next__

def em(a, b):
	if b == 0:
		return 0
	if b == 1:
		return int(a > 1)
	if b == 2:
		return 2 if a >= 4 else 1
	if a >= 2 * b:
		return b
	if a == b:
		e = a // 3 * 2
		res = e // 2 * 3
		return e + em(a - res, b - res)
	diff = a - b
	e = diff
	a -= diff * 2
	b -= diff
	return e + em(max(a, b), min(a, b))
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	print(em(max(a, b), min(a, b)))


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	(n, m) = (max(n, m), min(n, m))
	x = n - m
	if x > m:
		answer = m
	else:
		answer = x
		n = m - x
		if n % 3 == 0 or n % 3 == 1:
			answer += n // 3 * 2
		else:
			answer += n // 3 * 2 + 1
	print(answer)


def read_ints():
	temp = input().split()
	ints = [int(t) for t in temp]
	return ints

def max_emeralds(a, b):
	if not a or not b:
		return 0
	if a >= 2 * b or b >= 2 * a:
		return min(a, b)
	return (a + b) // 3
t = int(input())
for _ in range(t):
	result = 0
	(a, b) = read_ints()
	result = max_emeralds(a, b)
	print(result)


T = int(input())
while T:
	(a, b) = map(int, input().split())
	print(min(a, b, (a + b) // 3))
	T = T - 1


MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
from collections import *
for _ in range(ii()):
	(a, b) = f()
	l = (a + b) // 3
	if min(a, b) >= l:
		print(l)
	else:
		print(min(a, b))


for cas in range(int(input())):
	(s, d) = map(int, input().split())
	(mx, mn) = (max(s, d), min(s, d))
	tem = mx // 2
	mn -= tem
	if mn <= 0:
		print(min(s, d))
	elif mn > 0:
		tem2 = mn // 3
		if mn % 3 == 2 and mx & 1:
			tem2 += 1
		print(tem + tem2)


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


t = int(input())
for _ in range(t):
	inp = input().split()
	a = int(inp[0])
	b = int(inp[1])
	ans = 0
	dif = abs(a - b)
	if a > b:
		fr = min(dif, b)
		a -= fr * 2
		b -= fr
		ans += fr
	else:
		fr = min(dif, a)
		a -= fr
		b -= fr * 2
		ans += fr
	sc = min(a // 3, b // 3) * 2
	ans += sc
	a -= sc * 3 / 2
	b -= sc * 3 / 2
	if a + b > 2 and a and b:
		ans += 1
	print(ans)


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
for _ in range(INT()):
	(a, b) = MAP()
	if b < a:
		(a, b) = (b, a)
	x = min(b - a, a)
	a -= x
	b -= x * 2
	ans = x
	(d1, a) = divmod(a, 3)
	(d2, b) = divmod(b, 3)
	ans += min(d1, d2) * 2
	if a >= 2 and b >= 1 or (a >= 1 and b >= 2):
		ans += 1
	print(ans)


t = int(input())
while t != 0:
	emer = 0
	(a, b) = map(int, input().split())
	while a + b >= 3 and a != 0 and (b != 0):
		if a > b:
			k = min(a - b, b)
			emer += k
			a = a - k * 2
			b = b - k
		if a < b:
			m = min(b - a, a)
			emer += m
			a = a - m
			b = b - m * 2
		if a == b:
			emer += a // 3 * 2
			if a % 3 == 2:
				emer += 1
			break
	print(emer)
	t = t - 1


def solve():
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
		return
	else:
		print(min(a, b, (a + b) // 3))
t = int(input())
while t > 0:
	solve()
	t -= 1


t = int(input())
while t > 0:
	(a, b) = [int(i) for i in input().split()]
	mini = min(a, b)
	ans = min((a + b) // 3, mini)
	print(ans)
	t -= 1


def main():
	import sys
	sys.setrecursionlimit(10 ** 6)
	input = sys.stdin.readline
	t = int(input())
	for _ in range(t):
		(a, b) = [int(x) for x in input().strip().split()]
		if b < a:
			(a, b) = (b, a)
		ans = 0
		ans += min(a, b - a)
		a -= ans
		b -= 2 * ans
		if a >= 3 and b >= 3:
			t = min(a, b) // 3
			ans += 2 * t
			a -= 3 * t
			b -= 3 * t
		if a >= 2 and b >= 1:
			ans += 1
			a -= 2
			b -= 1
		if b >= 2 and a >= 1:
			ans += 1
		print(ans)
main()


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


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


import os
import sys
import io
import math
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	(n, k) = (max(n, k), min(n, k))
	answer = 0
	if k < n - k:
		print(k)
		continue
	answer += n - k
	k = 2 * k - n
	n = k
	answer += 2 * (k // 3)
	k = k % 3
	if k == 2:
		answer += 1
	print(answer)


def result(min, max):
	if max >= 2 * min:
		print(min)
	else:
		print((min + max) // 3)
n = int(input())
for i in range(n):
	(stick, diamonds) = list(map(int, input().split()))
	if stick >= diamonds:
		max = stick
		min = diamonds
	elif stick < diamonds:
		max = diamonds
		min = stick
	result(min, max)


import sys, math
from collections import deque

def solve():
	(a, b) = map(int, input().split())
	if a >= 2 * b or b >= 2 * a:
		print(min(a, b))
	else:
		A = max(a, b)
		B = min(a, b)
		cnt = A - B
		cnt += (2 * B - A) // 3 * 2 + (2 * B - A) % 3 // 2
		print(cnt)
	return
for _ in range(int(input())):
	solve()


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
T = ni()
for _ in range(T):
	solve()


from sys import stdin, stdout

def main():
	tests = []
	N = int(stdin.readline())
	tests = [[int(l[0]), int(l[1])] for l in [stdin.readline().rstrip('\n').split(' ') for i in range(N)]]
	answers = []
	for test in tests:
		(a, b) = test
		if a == 0 or b == 0:
			answers.append(0)
		else:
			sols = []
			sols.append(min(a, b // 2))
			sols.append(min(a // 2, b))
			x = (2 * a - b) // 3
			y = (2 * b - a) // 3
			if x >= 0 and y >= 0:
				sols.append((a + b) // 3)
			answers.append(max(sols))
	for answer in answers:
		stdout.write(str(answer) + '\n')
	return 0
main()


for i in range(int(input())):
	(m, n) = map(int, input().split())
	print(min(m, n, (m + n) // 3))


for _ in range(int(input())):
	(s, d) = map(int, input().split())
	ans = 0
	if s == d:
		if s % 3 == 0:
			ans = s // 3 * 2
		elif s % 3 == 1:
			ans = s // 3 * 2
		else:
			ans = s // 3 * 2 + 1
	elif s > d:
		if s >= 2 * d:
			ans = d
		else:
			ans = s - d
			d -= ans
			if d % 3 == 0:
				ans += d // 3 * 2
			elif d % 3 == 1:
				ans += d // 3 * 2
			elif d % 3 == 2:
				ans += d // 3 * 2 + 1
	elif d >= 2 * s:
		ans = s
	else:
		ans = d - s
		s -= ans
		if s % 3 == 0:
			ans += s // 3 * 2
		elif s % 3 == 1:
			ans += s // 3 * 2
		elif s % 3 == 2:
			ans += s // 3 * 2 + 1
	print(ans)


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(a, b) = map(int, sys.stdin.readline().split())
	high = max(a, b)
	low = min(a, b)
	diff = high - low
	until_equal = min(low, diff)
	high -= until_equal * 2
	low -= until_equal
	if high != low:
		print(until_equal)
		continue
	(div, mod) = divmod(low, 3)
	print(until_equal + 2 * div + (mod == 2))


def main():
	n = int(input())
	while n:
		n -= 1
		(a, b) = map(int, input().split())
		print(min((a + b) // 3, min(a, b)))
	return
main()


for _ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	x = a // 2
	y = b // 2
	m = x + y
	p = (3 * m - a - b) // 3
	pot = m - p
	if pot > a:
		pot = a
	if pot > b:
		pot = b
	if a + b - pot * 3 < 0:
		pot -= 1
	print(pot)


t = int(input())
for q in range(t):
	(m, n) = input().split()
	(m, n) = (int(m), int(n))
	print(min(m, n, (max(m, n) + min(m, n)) // 3))


import sys
import math
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
t = int(input())
for case in range(t):
	(a, b) = map(int, input().split())
	print(min(a, b, (a + b) // 3))


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
sys.setrecursionlimit(int(pow(10, 6)))
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(l()[0]):
	(a, b) = l()
	print(min(a, b, (a + b) // 3))


t = int(input())
for _ in range(t):
	(a, b) = [int(x) for x in input().split()]
	if a == 0 or b == 0:
		print(0)
	else:
		c = (a + b) // 3
		c = min(a, b, c)
		print(c)


for _ in range(int(input())):
	(sticks, diamonds) = list(map(int, input().split()))
	emeralds = 0
	if sticks > diamonds:
		emeralds += min(diamonds, sticks - diamonds)
		sticks -= 2 * emeralds
		diamonds -= emeralds
	elif diamonds > sticks:
		emeralds += min(sticks, diamonds - sticks)
		sticks -= emeralds
		diamonds -= 2 * emeralds
	if sticks != 0 and diamonds != 0:
		emeralds += (sticks + diamonds) // 3
	print(emeralds)


import math
t = int(input())
for i in range(t):
	inp = list(map(int, input().split()))
	a = inp[0]
	b = inp[1]
	if a < b:
		(a, b) = (b, a)
	if a >= 2 * b:
		print(b)
	else:
		print(math.ceil((a + b - 2) / 3))


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)


test = int(input())
while test > 0:
	test -= 1
	(a, b) = map(int, input().split())
	if a > b:
		temp = b
		b = a
		a = temp
	x = b - a
	if x > a:
		print(a)
	else:
		ans = x
		a -= x
		b -= 2 * x
		ans += a // 3 * 2
		a = a % 3
		if a > 1:
			ans += 1
		print(ans)
	print('\n')


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


g = divmod
for _ in range(int(input())):
	(a, b) = sorted(map(int, input().split()))
	t = min(a, b - a)
	((c, d), (e, f)) = (g(a - t, 3), g(b - t * 2, 3))
	print(t + min(c, e) * 2 + (d + f > 2))


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


def main():
	t = int(input())
	for _ in range(t):
		(a, b) = map(int, input().split())
		if a >= 2 * b:
			print(b)
			continue
		if b >= 2 * a:
			print(a)
			continue
		print((a + b) // 3)
main()


from fractions import Fraction
import sys
import bisect
import heapq
from math import *
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
mod = 1000000007

def inp():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def solve():
	(a, b) = sep()
	x = ((a + b) / 3 + (a - b)) / 2
	if x < 1:
		x = 0
	else:
		x = min(b, floor(x))
	a -= 2 * x
	b -= x
	if b >= 2 * a:
		y = a
	else:
		y = b // 2
	print(x + y)
testcase(int(inp()))


import math
t = int(input())
while t > 0:
	t -= 1
	inp = list(map(int, input().split()))
	a = inp[0]
	b = inp[1]
	if a < 1 or b < 1:
		print(0)
	elif min(a, b) * 2 <= max(a, b):
		print(min(a, b))
	else:
		ans = math.floor((a + b) / 3)
		print(ans)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	num = (n + m) // 3
	if num > min(n, m):
		print(min(n, m))
	else:
		print(num)


for _ in range(int(input())):
	(a, b) = sorted(list(map(int, input().split())))
	if a == 0 or b == 0:
		print(0)
	elif b // a >= 2:
		print(a)
	else:
		c = b - a
		a -= c
		c += 2 * (a // 3)
		print(c + a % 3 // 2)


from sys import stdin, stdout

def main():
	for t in range(int(stdin.readline())):
		(s, d) = map(int, stdin.readline().split())
		if s == 0 or d == 0:
			print(0)
		else:
			flag = 0
			a = 0
			if 2 * s - d > 0 and 2 * d - s > 0:
				a = (s + d) // 3
				flag = 1
			if flag == 1:
				b = max(d // 2, s // 2)
				print(max(a, b))
			elif 2 * s - d <= 0:
				print(s)
			else:
				print(d)
main()


import bisect, math

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


t = int(input())
result = []
for _ in range(0, t):
	imp = input()
	imp = imp.split()
	a = int(imp[0])
	b = int(imp[1])
	if a == 0 or b == 0:
		result.append(0)
	else:
		res1 = (a + b) // 3
		res = min(a, b, res1)
		result.append(res)
for i in result:
	print(i)


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


from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

def input():
	return sys.stdin.readline()

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
for _ in range(int(input())):
	(a, b) = mapi()
	(a, b) = (min(a, b), max(a, b))
	print(min(a, (a + b) // 3))


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	(a, b) = [int(x) for x in input().split()]
	G = max(a, b)
	L = min(a, b)
	if G >= 2 * L:
		print(L)
	else:
		print(G - L + (2 * L - G) * 2 // 3)


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


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	if n == 0 or m == 0:
		print(0)
		continue
	if n > m:
		(n, m) = (m, n)
	total = n + m
	hb = total // 3
	if n - hb < 0:
		print(n)
	else:
		print(hb)


import math
from collections import Counter

def i():
	return int(input())

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

def lis():
	return list(map(int, list(input())))
t = i()
for _ in range(t):
	(a, b) = list(map(int, input().split()))
	if min(a, b) <= max(a, b) // 2:
		print(min(a, b))
	else:
		diff = max(a, b) - min(a, b)
		ans = diff + (min(a, b) - diff) // 3 * 2
		if (min(a, b) - diff) % 3 == 2:
			ans += 1
		print(ans)


import io
import os
t = int(input())
while t:
	t -= 1
	(a, b) = [int(x) for x in input().split()]
	(a, b) = (min(a, b), max(a, b))
	b = min(b, a << 1)
	print((a + b) // 3)


import sys

def get():
	return int(sys.stdin.readline().strip())

def geti():
	return map(int, sys.stdin.readline().strip().split())

def getli():
	return list(map(int, sys.stdin.readline().strip().split()))

def fun(a, b):
	if a < b:
		(a, b) = (b, a)
	if a >= 2 * b:
		return b
	return (a + b) // 3
for _ in range(get()):
	(a, b) = geti()
	print(fun(a, b))


from sys import stdin, stdout
t = int(stdin.readline().strip())
for _ in range(t):
	(a, b) = map(int, stdin.readline().split())
	d = min(abs(a - b), a, b)
	c = d + 2 * (min(a, b) - d) // 3
	stdout.write('{}\n'.format(c))


import sys
input = sys.stdin.readline
Q = int(input())
Query = [list(map(int, input().split())) for _ in range(Q)]
for (a, b) in Query:
	ans = 0
	if a > b:
		d = a - b
		c = min(d, b)
		a -= 2 * c
		b -= c
		ans += c
	else:
		d = b - a
		c = min(d, a)
		a -= c
		b -= 2 * c
		ans += c
	p = min(a, b)
	ans += p // 3 * 2
	if p % 3 > 0 and max(a, b) % 3 > 1:
		ans += 1
	print(ans)


from os import path
import sys
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

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

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')

def f(m, a, b):
	if m > b or 2 * m > a or m < 0:
		return 0
	ans = m
	a -= 2 * m
	b -= m
	if a > b:
		(a, b) = (b, a)
	ans += min(a, b // 2)
	a -= b // 2
	b %= 2
	ans += min(b, a // 2)
	return ans

def solve():
	for _ in range(ii()):
		(a, b) = mi()
		if a < b:
			(a, b) = (b, a)
		if a >= 2 * b:
			print(b)
			continue
		x = (a + b) // 3
		print(min(x, b))
solve()


for _ in range(0, int(input())):
	(a, b) = sorted(map(int, input().split()))
	if b >= 2 * a:
		print(a)
	else:
		print(b // 2 + (a - b // 2) // 3 + ((a - b // 2) % 3 == 2 and b % 2 == 1))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a * 2 <= b:
		print(a)
	elif b * 2 <= a:
		print(b)
	else:
		mid = min(a, b) - abs(a - b)
		div = 0
		if mid % 3 == 2:
			div = 1
		print(abs(a - b) + mid // 3 * 2 + div)


ncases = int(input())
for i in range(ncases):
	take = input().split(' ')
	sticks = int(take[0])
	diamonds = int(take[1])
	greedy = int((sticks + diamonds) / 3)
	maxi = min(sticks, diamonds, greedy)
	print(maxi)


def f2(inp):
	a = int(inp[0])
	b = int(inp[1])
	return min([a, b, (a + b) // 3])
test = input()
for e in range(int(test)):
	print(f2(input().split(' ')))


def solve(a, b):
	if a < b:
		(a, b) = (b, a)
	k = a - b
	if k >= b:
		return b
	left = 2 * b - a
	res = left // 3
	res *= 2
	if left % 3 == 2:
		res += 1
	res += k
	return res
t = int(input())
l = list()
i = 0
for i in range(int(t)):
	n = input().split(' ')
	print(solve(int(n[0]), int(n[1])))


for i in range(int(input())):
	(n, m) = map(int, input().split())
	if max(m, n) >= 2 * min(n, m):
		print(min(n, m))
	else:
		print(abs(m - n) + 2 * (min(m, n) - abs(m - n)) // 3)


t = int(input())
k = t
a = list()
ans = list()
while k > 0:
	q = input()
	a = q.split()
	x = int(a[0])
	y = int(a[1])
	if x < y:
		if 2 * x < y:
			ans.append(x)
		else:
			ans.append(int((x + y) / 3))
	elif 2 * y < x:
		ans.append(y)
	else:
		ans.append(int((x + y) / 3))
	k = k - 1
for r in ans:
	print(r)


from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
	return int(input())

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

def solve():
	(a, b) = rl()
	opt = (a + b) // 3
	ans = min(a, b, opt)
	print(ans)
mode = 'T'
if mode == 'T':
	t = ri()
	for i in range(t):
		solve()
else:
	solve()


import math
t = int(input())
for g in range(t):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
		continue
	if a > b:
		(a, b) = (b, a)
	if b > 2 * a:
		print(a)
		continue
	print((a + b) // 3)


for i1 in range(int(input())):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	if a == 0:
		print(0)
		continue
	elif a == 1 and b == 1:
		print(0)
		continue
	elif a == 1:
		print(1)
		continue
	elif a == 2 and (b == 2 or b == 3):
		print(1)
		continue
	elif a == 2:
		print(2)
		continue
	elif b > 2 * a:
		print(a)
		continue
	else:
		t = 2 * a - b
		while True:
			if t / 3 == t // 3:
				break
			t += 1
		ans = t // 3 * 2 + (a - t)
		print(ans)


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


test_cases = int(input())
for _ in range(test_cases):
	arr = [int(x) for x in input().split()]
	print(min(*arr, sum(arr) // 3))


t = int(input())
while t > 0:
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	(a, b) = (min(a, b), max(a, b))
	if 2 * a <= b:
		print(a)
	else:
		print((a + b) // 3)
	t -= 1


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


import sys
input = sys.stdin.readline
import heapq
import copy
import math
import decimal

class Node:

	def _init_(self, val):
		self.data = val
		self.left = None
		self.right = None

def pre_sum(arr):
	p = [0]
	for i in arr:
		p.append(p[-1] + i)
	p.pop(0)
	return p

def pre_back(arr):
	p = [0]
	for i in arr:
		p.append(p[-1] + i)
	p.pop(0)
	return p

def bin_search(arr, l, r, val):
	if arr[r] <= val:
		return r + 1
	if r - l < 2:
		if arr[l] > val:
			return l
		else:
			return r
	mid = int((l + r) / 2)
	if arr[mid] <= val:
		return bin_search(arr, mid, r, val)
	else:
		return bin_search(arr, l, mid, val)

def search_leftmost(arr, val):

	def helper(arr, l, r, val):
		print(l, r)
		if arr[l] == val:
			return l
		if r - l <= 1:
			if arr[r] == val:
				return r
			else:
				print('not found')
				return
		mid = int((r + l) / 2)
		if arr[mid] >= val:
			return helper(arr, l, mid, val)
		else:
			return helper(arr, mid, r, val)
	return helper(arr, 0, len(arr) - 1, val)

def search_rightmost(arr, val):

	def helper(arr, l, r, val):
		print(l, r)
		if arr[r] == val:
			return r
		if r - l <= 1:
			if arr[l] == val:
				return r
			else:
				print('not found')
				return
		mid = int((r + l) / 2)
		if arr[mid] > val:
			return helper(arr, l, mid, val)
		else:
			return helper(arr, mid, r, val)
	return helper(arr, 0, len(arr) - 1, val)

def preorder_postorder(root, paths, parent, left, level):
	l = 0
	queue = [root]
	while queue != []:
		node = queue[-1]
		flag = 0
		for i in paths[node]:
			if i != parent[node] and level[i] == sys.maxsize:
				parent[i] = node
				level[i] = level[node] + 1
				flag = 1
				queue.append(i)
		if flag == 0:
			left[parent[node]] += 1 + left[node]
			queue.pop()
	return [parent, left, level]

def nCr(n, r, p):
	if r == 0:
		return 1
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def f_exp(p, k0, k1, l):
	ans = 1
	k = k0 - k1
	while k != 0:
		if k % 2 == 0:
			k = k // 2
			p = p * p
		else:
			ans = ans * p
			k = (k - 1) // 2
			p = p * p
		if ans > l:
			ans = -1
			break
	return ans

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def insr2():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())

def pr_list(a):
	print(*a, sep=' ')

def main():
	tests = inp()
	mod = 1000000007
	limit = 10 ** 18
	ans = 0
	for test in range(tests):
		[s, d] = inlt()
		if d > s:
			temp = d
			d = s
			s = temp
		if s > 2 * d:
			print(d)
			continue
		ans = s - d
		s = s - 2 * ans
		d = d - ans
		ans = ans + d // 3 * 2
		if d % 3 == 2:
			ans = ans + 1
		print(ans)
main()


T = int(input())
while T > 0:
	(a, b) = map(int, input().split())
	if a < b:
		(a, b) = (b, a)
	diff = a - b
	res = 0
	if diff >= b:
		print(b)
	else:
		res += diff
		start = b - diff
		times = start // 3
		re = start % 3
		res += times * 2
		if re == 2:
			res += 1
		print(res)
	T -= 1


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


ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
for _ in range(ii()):
	(a, b) = f()
	l = (a + b) // 3
	if min(a, b) >= l:
		print(l)
	else:
		print(min(a, b))


import sys
from math import ceil as ce
cont = sys.stdin.readlines()
cont = [i.strip('\n').split() for i in cont]
numTests = int(cont.pop(0)[0])
for i in cont:
	i[0] = int(i[0])
	i[1] = int(i[1])

def little(a, b, count=0):
	while a * b >= 2:
		m = max(a, b)
		n = min(a, b)
		m -= 2
		n -= 1
		count += 1
		(a, b) = (m, n)
	print(count)
for i in cont:
	(a, b) = (i[0], i[1])
	m = max(a, b)
	n = min(a, b)
	count = 0
	t = m - n
	if n - t >= 0:
		m -= t * 2
		n -= t
		count += t
		t2 = min(m // 3, n // 3)
		m -= t2 * 3
		n -= t2 * 3
		count += t2 * 2
		if m * n >= 2:
			count += 1
		print(count)
	elif m - 2 * n >= 0:
		print(count + n)
	else:
		count += (m - n) // 2
		if m * n >= 2:
			count += 1
		print(count)


x = int(input())
for z in range(x):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
	elif b >= 2 * a:
		print(a)
	elif a > 2 * b:
		print(b)
	elif a < b:
		diff = 2 * a - b
		sub = diff // 3
		if diff % 3 == 0:
			sub -= 1
		sub += 1
		print(a - sub)
	else:
		diff = 2 * b - a
		sub = diff // 3
		if diff % 3 == 0:
			sub -= 1
		sub += 1
		print(b - sub)


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


import sys
import heapq

def main():
	t = int(input())
	for _ in range(t):
		(a, b) = map(int, sys.stdin.readline().split())
		ans = 0
		if a > b:
			(a, b) = (b, a)
		if 2 * a <= b:
			print(a)
			continue
		div = (2 * a - b) // 3
		ans = div * 2
		a -= div * 3
		b -= div * 3
		if a >= 1:
			ans += b // 2
		print(ans)
	return
main()


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


def diamond_sticks(diamond, sticks):
	return min(diamond, sticks, (diamond + sticks) // 3)
t = int(input())
for x in range(t):
	(diamond, sticks) = list(map(int, input().split()))
	print(diamond_sticks(diamond, sticks))


for _ in range(int(input())):
	(A, B) = map(int, input().split())
	print(min(A, B, (A + B) // 3))


def solve():
	(a, b) = map(int, input().split())
	if a < b:
		(a, b) = (b, a)
	ans = min((a + b) // 3, b)
	print(ans)
t = int(input())
while t > 0:
	t -= 1
	solve()


def shovels(sticks, diamonds):
	ans = 0
	while sticks >= 2:
		sticks -= 2
		diamonds -= 1
		ans += 1
	return (ans, sticks, diamonds)

def swords(sticks, diamonds):
	ans = 0
	while diamonds >= 2:
		diamonds -= 2
		sticks -= 1
		ans += 1
	return (ans, sticks, diamonds)

def solve():
	[sticks, diamonds] = [int(x) for x in input().split()]
	if sticks == 0 or diamonds == 0:
		return 0
	if sticks <= diamonds:
		small = sticks
		big = diamonds
	else:
		big = sticks
		small = diamonds
	if small <= big // 2:
		return small
	return (small + big) // 3

def main():
	t = int(input())
	while t > 0:
		ans = solve()
		print(ans)
		t -= 1
main()


t = int(input())
for loop in range(t):
	(a, b) = map(int, input().split())
	if a < b:
		tmp = a
		a = b
		b = tmp
	ans = 0
	x = a - b
	now = min(a // 2, b, x)
	a -= now * 2
	b -= now
	ans += now
	if a == b:
		n2 = a // 3
		ans += n2 * 2
		a -= n2 * 3
		b -= n2 * 3
	if max(a, b) >= 2 and min(a, b) >= 1:
		n3 = 1
	else:
		n3 = 0
	ans += n3
	print(ans)


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


for lo in range(int(input())):
	(n, m) = map(int, input().split())
	if m > n:
		(n, m) = (m, n)
	x = n // 2
	if m <= x:
		print(m)
	else:
		print((m + n) // 3)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	s = a + b
	c = s // 3
	if a >= c and b >= c:
		print(c)
	else:
		print(min(a, b))


import os
import sys
from io import BytesIO, IOBase
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def main():
	for _ in range(inp()):
		(a, b) = invr()
		print(min(a, b, (a + b) // 3))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


num_case = int(input())
for case in range(num_case):
	tmp = input().split()
	stick = int(tmp[0])
	diamond = int(tmp[1])
	if 2 * stick < diamond:
		print(stick)
	elif 2 * diamond < stick:
		print(diamond)
	else:
		print((stick + diamond) // 3)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
	else:
		d = abs(a - b)
		if d > a or d > b:
			print(min(a, b))
		else:
			print((a + b) // 3)


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


t = int(input())
for x in range(0, t):
	a1 = input()
	l = a1.split(' ')
	a = int(l[0])
	b = int(l[1])
	c = int((a + b) / 3)
	d = min(a, b, c)
	print(d)


ni = int(input())
for ti in range(ni):
	(a, b) = map(int, input().split())
	if (a == 0 or b == 0) or (a == 1 and b == 1):
		print('0')
	elif a == 1 or b == 1 or (a == 2 and b == 2):
		print('1')
	elif a == b:
		if a % 3 == 1 or a % 3 == 0:
			print(a // 3 * 2)
		else:
			print(a // 3 * 2 + 1)
	elif a >= 2 * b:
		print(b)
	elif b >= 2 * a:
		print(a)
	else:
		if b > a:
			x = b - a
			a = a - x
			b = b - 2 * x
		else:
			x = a - b
			b = b - x
			a = a - 2 * x
		if a % 3 == 1 or a % 3 == 0:
			print(x + a // 3 * 2)
		else:
			print(x + a // 3 * 2 + 1)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
	else:
		x = max(0, min(a, b) - abs(a - b))
		ans = min(min(a, b), abs(a - b))
		ans += (x - x % 3) // 3 * 2
		if x % 3 >= 2:
			ans += 1
		print(ans)


from sys import stdin
input = stdin.readline
for Ti in range(int(input().strip())):
	(a, b) = [int(x) for x in input().strip().split()]
	print(min(a, b, (a + b) // 3))


t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().split()))
	out = 0
	while a >= 2 and b >= 1 or (a >= 1 and b >= 2):
		x = max(a, b)
		y = min(a, b)
		divisor = 4
		while y - x // divisor < 0:
			divisor *= 2
		if x >= divisor:
			rem = x % divisor
			div = x // divisor
			x = (divisor - 2) * div + rem
			y -= div
			out += div
		else:
			x -= 2
			y -= 1
			out += 1
		if a >= b:
			(a, b) = (x, y)
		else:
			(b, a) = (x, y)
	print(out)


import math
import sys
import collections
from collections import defaultdict
from sys import stdin, stdout
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	if n == 0 or m == 0:
		print(0)
	else:
		ele = (n + m) // 3
		if n == m:
			print(ele)
		elif min(n, m) < ele:
			print(min(n, m))
		else:
			print(ele)


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


t = int(input())
l = []
for i in range(t):
	n = list(map(int, input().split()))
	l.append(n)
for j in l:
	if j[0] == 0 or j[1] == 0:
		print(0)
	elif j[1] >= 2 * j[0]:
		print(j[0])
	elif j[0] >= 2 * j[1]:
		print(j[1])
	else:
		print((j[1] + j[0]) // 3)


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


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	if x == 0 or y == 0:
		print(0)
	else:
		print(min(x, y, (x + y) // 3))


for _ in range(int(input())):
	(s, d) = map(int, input().split())
	if s == 0 or d == 0:
		print(0)
	elif s < 2 and d < 2:
		print(0)
	elif d // s >= 2:
		print(s)
	elif s // d >= 2:
		print(d)
	else:
		print((s + d) // 3)


import sys
import math
from collections import defaultdict, deque
import heapq
t = int(sys.stdin.readline())
for _ in range(t):
	(a, b) = map(int, sys.stdin.readline().split())
	ans = 0
	if b > a:
		x = b - a
		if x > a:
			print(a)
			continue
		ans = x
		b -= 2 * x
		a -= x
	elif a > b:
		x = a - b
		if x > b:
			print(b)
			continue
		ans = x
		b -= x
		a -= 2 * x
	add = a // 3 * 2
	a = a % 3
	b = b % 3
	if a >= 2 and b >= 1 or (b >= 2 and a >= 1):
		ans += 1
	ans += add
	print(ans)


import math
t = int(input())
while t != 0:
	(s, d) = map(int, input().split())
	if s == 0 or d == 0:
		print(0)
	elif s == d:
		print((s + d) // 3)
	else:
		print(min(s, d, (s + d) // 3))
	t = t - 1


c = []
for i in range(int(input())):
	z = [int(X) for X in input().split()]
	a = z[0]
	b = z[1]
	em = 0
	if a > b:
		d = a - b
		if b <= d:
			em += b
		else:
			b -= d
			em += d
			if b != 1:
				k = 2 * b
				em += k // 3
	elif b > a:
		d = b - a
		if a <= d:
			em += a
		else:
			a -= d
			em += d
			if a != 1:
				k = 2 * a
				em += k // 3
	elif b != 1:
		em += 2 * b // 3
	c.append(em)
for i in c:
	print(i)


import sys

def solve(s, d):
	if s > d:
		t = s
		s = d
		d = t
	if s < d:
		if d >= 2 * s:
			return s
		else:
			diff = d - s
			em = diff
			d -= em
			s -= em
			em += 2 * (s // 3) + (1 if s % 3 == 2 else 0)
			return em
	else:
		return 2 * (s // 3) + (1 if s % 3 == 2 else 0)
IN = [x.strip() for x in sys.stdin.readlines()]
T = int(IN[0])
for ti in range(T):
	(s, d) = [int(x) for x in IN[1 + ti].split(' ')]
	result = solve(s, d)
	print(result)


t = int(input().strip())
for i in range(t):
	l = list(map(int, input().split()))
	a = l[0]
	b = l[1]
	p = 2 * a - b
	q = 2 * b - a
	if a >= 2 * b or b >= 2 * a:
		print(min(a, b))
	else:
		x = (a + b) / 3
		if p > 0 and q > 0:
			print(int(x))
		else:
			print(0)


t = int(input())
for q in range(t):
	(a, b) = list(map(int, input().split(' ')))
	sticks = max(a, b)
	diamonds = min(a, b)
	if sticks == 0 or diamonds == 0:
		print(0)
	elif sticks >= diamonds * 2:
		print(diamonds)
	else:
		print((sticks + diamonds) // 3)


n = int(input())
for i in range(n):
	a = list(map(int, input().strip().split()))
	x = (a[0] + a[1]) // 3
	print(min(a[0], a[1], x))


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


from sys import stdin, stdout
import math
t = int(stdin.readline())
for _ in range(t):
	(n, k) = map(int, stdin.readline().split())
	(b, s) = (max(n, k), min(n, k))
	if b >= 2 * s:
		print(s)
	else:
		print((b + s) // 3)


for i in range(int(input())):
	(a, b) = [int(i) for i in input().split()]
	if max(a, b) >= min(a, b) * 2:
		print(min(a, b))
	else:
		print(sum([a, b]) // 3)


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


t = int(input())
for j in range(t):
	n = input().split()
	a = int(n[0])
	b = int(n[1])
	if a == 0 or b == 0:
		print(0)
	elif 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())
	big = max(a, b)
	small = min(a, b)
	diff = min(big - small, small)
	if (small - diff) % 3 == 2:
		left = (small - diff) // 3 * 2 + 1
	else:
		left = (small - diff) // 3 * 2
	print(int(diff + left))


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	if a * 2 <= b:
		print(a)
	elif a == b:
		print(a // 3 * 2 + a % 3 // 2)
	else:
		x = b - a
		print((a - x) // 3 * 2 + (a - x) % 3 // 2 + x)


n = int(input())
for _ in range(n):
	(a, b) = map(int, input().split())
	count = 0
	(a, b) = (min(a, b), max(a, b))
	if a <= b // 2:
		count += a
	else:
		t = b - a
		count += t
		a -= t
		b -= t * 2
		if a > 2:
			count += a // 3 * 2
			if a % 3 == 2:
				count += 1
		elif a == 2 and b == 2:
			count += 1
	print(count)


import sys
input = lambda : sys.stdin.readline().rstrip()
inp = sys.stdin.buffer.readline

def I():
	return list(map(int, inp().split()))
for _ in range(int(input())):
	(m, g) = map(int, input().split())
	if m > g:
		(m, g) = (g, m)
	ans = min(g - m, m)
	m -= ans
	g = m
	ans += g // 3 * 2
	if g % 3 == 2:
		ans += 1
	print(ans)


from math import *
for i in range(int(input())):
	(n, m) = map(int, input().split())
	tmp = 0
	min1 = min(n, m)
	max1 = max(n, m)
	if min1 >= 1 and max1 >= 2:
		t1 = max1 - min1
		if t1 > min1:
			tmp = min1
		else:
			min1 -= t1
			max1 -= 2 * t1
			tmp += t1
			if max1 >= 1 and min1 >= 2:
				tmp += int((min1 + max1) / 3)
	print(tmp)


t = int(input())
for z in range(t):
	(a, b) = [int(i) for i in input().split()]
	c = 0
	if a < 1 or b < 1:
		print(c)
	else:
		print(min(min(a, b), (a + b) // 3))


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	ans = min(abs(a - b), min(a, b))
	if a > b:
		a -= ans * 2
		b -= ans
	else:
		a -= ans
		b -= ans * 2
	ans += min(a, b) // 3 * 2
	a %= 3
	b %= 3
	if a == 2 and b or (b == 2 and a):
		ans += 1
	print(ans)


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


def f(l):
	(a, b) = l
	return min(a, b, (a + b) // 3)
q = int(input())
[print(f(list(map(int, input().split())))) for _ in range(q)]


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		(a, b) = list(map(int, input().split()))
		c = min(a, b)
		d = max(a, b)
		if d >= 2 * c:
			yield c
		else:
			yield ((c + d) // 3)
t = int(input())
ans = gift()
print(*ans, sep='\n')


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().rstrip().split(' '))
	(n, k) = (min(n, k), max(n, k))
	if k in range(n, 2 * n):
		print((n + k) // 3)
	else:
		print(n)


def read_int():
	return int(input())

def read_ints():
	return map(int, input().split(' '))
t = read_int()
for case_num in range(t):
	(a, b) = read_ints()
	print(min((a + b) // 3, min(a, b)))


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))


import math
for test in range(int(input())):
	(n, m) = map(int, input().split())
	if n == 0 or m == 0:
		print('0')
	else:
		valor = min(n, m)
		print(min(math.floor((n + m) / 3), valor))


import sys
from sys import stdin
input = sys.stdin.readline
for _ in range(int(input())):
	(a, b) = [int(j) for j in input().split()]
	mini = min(a, b)
	maxi = max(a, b)
	if maxi >= 2 * mini:
		print(mini)
	elif a == 0 or b == 0:
		print(0)
	else:
		print((a + b) // 3)


import collections

def read():
	return input().strip()

def readInt():
	return int(input().strip())

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

def solve(a, b):
	return min(a, b, (a + b) // 3)
t = readInt()
for i in range(t):
	[a, b] = readList()
	print(solve(a, b))


for _ in [0] * int(input()):
	(a, b) = list(map(int, input().split()))
	min1 = min(a, b)
	max1 = max(a, b)
	r = min(min1, max1 // 2)
	min1 -= r
	max1 -= 2 * r
	if max1 == 1 and min1 > 1:
		r += 1
		min1 -= 2
		max1 -= 1
	r += min1 // 3
	print(r)


def ans(a, b):
	if b / 2 > a:
		return a
	if a / 2 > b:
		return b
	return (a + b) // 3
T = int(input())
for t in range(T):
	(a, b) = input().split(' ')
	a = int(a)
	b = int(b)
	print(ans(a, b))


t = int(input())
for _ in range(t):
	(a, b) = list(map(int, input().strip().split()))
	a1 = min(a, b)
	a2 = min(2 * a1, max(a, b))
	print((a1 + a2) // 3)


import sys
input = lambda : sys.stdin.readline().rstrip()
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	tmp = min(a, b - a)
	if tmp == a:
		print(a)
		continue
	a -= tmp
	if a % 3 == 2:
		tmp += 1
	tmp += a // 3 * 2
	print(tmp)


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a < b:
		(a, b) = (b, a)
	x = min(a // 2, b)
	a -= 2 * x
	b -= x
	cnt = x
	if a and b >= 2:
		b -= 2
		cnt += 1
	cnt += b // 3
	print(cnt)


def lcm(a, b):
	return a * b // gcd(a, b)

def inin():
	return int(input())

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

def ar(element, size):
	return [element for i in range(size)]

def yes():
	print('Yes')

def no():
	print('No')
Testcase = inin()
for _ in range(Testcase):
	(a, b) = inar()
	print(min(a, b, (a + b) // 3))


N = int(input())
for i in range(N):
	(a, b) = [int(x) for x in input().split()]
	if a < b:
		(a, b) = (b, a)
	sw = a // 2
	if b <= sw:
		sw = b
		sp = 0
	else:
		t = (b - sw) // 3
		sp = 2 * t
		sw -= t
	a1 = a - sw * 2 - sp
	b1 = b - sw - sp * 2
	t = 1 if a1 >= 2 and b1 >= 1 or (a1 >= 1 and b1 >= 2) else 0
	print(sw + sp + t)


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


def solve_test_case(t):
	(a, b) = parse_array(int)

	def f(a, b):
		diff = b - a
		v = a - diff
		if v < 0:
			print(a)
		else:
			d = v // 3 * 2
			v = v % 3
			if v == 2:
				d += 1
			print(d + diff)
	f(min(a, b), max(a, b))

def parse_array(f):
	return list(map(f, input().split()))

def solve():
	T = int(input())
	for t in range(T):
		solve_test_case(t)
solve()


t = int(input())
for _ in range(t):
	(sticks, dimonds) = map(int, input().split())
	n = min(sticks, dimonds)
	m = max(sticks, dimonds)
	if n <= m // 2:
		print(n)
	else:
		print((sticks + dimonds) // 3)


a = int(input())
for i in range(a):
	(l, r) = input().split()
	l = int(l)
	r = int(r)
	print(min(l, r, int((l + r) / 3)))


cases = int(input())
for case in range(cases):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0 or (a == 1 and b == 1):
		print(0)
		continue
	elif a == 1 or b == 1:
		print(1)
		continue
	elif a >= 2 * b:
		print(b)
		continue
	elif b >= 2 * a:
		print(a)
		continue
	else:
		x = max(a, b) - min(a, b)
		a = b = min(a, b) - x
		y = 2 * (a // 3)
		if a % 3 == 2:
			print(x + y + 1)
		else:
			print(x + y)


from collections import defaultdict
for _ in range(int(input())):
	l = list(map(int, input().split()))
	if l[0] == 0 or l[1] == 0:
		print(0)
	elif l[0] >= l[1] * 2:
		print(l[1])
	elif l[0] * 2 <= l[1]:
		print(l[0])
	else:
		print((l[0] + l[1]) // 3)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(s1, s2) = (2, 1)
	(p1, p2) = (1, 2)
	(d, e) = (a // s1, b // p2)
	if a == 0 or b == 0:
		print(0)
	else:
		print(min(a, b, (a + b) // 3))


from sys import stdin as sin
kk = int(input())
for _ in range(kk):
	data = sin.readline().rstrip()
	(a, b) = (int(i) for i in data.split(' '))
	if b > a:
		tmp = b
		b = a
		a = tmp
	if a > 2 * b:
		print(int(b))
		continue
	cu = a // 2
	b_left = b - cu
	if a % 2:
		if b_left >= 2:
			cu += 1
			b_left -= 2
	cu += b_left // 3
	print(cu)


from math import ceil
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	x = max(a, b)
	y = min(a, b)
	print(min(y, (x + y) // 3))


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


import math

def shrey():
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
	elif max(a, b) > min(a, b) * 2:
		print(min(a, b))
	else:
		print((a + b) // 3)
T = input()
T = int(T)
for q in range(1, T + 1):
	shrey()


test_cases = int(input())

def testCase():
	(a, b) = [int(x) for x in input().strip().split()]
	print(min(a, b, (a + b) // 3))
for test_case in range(test_cases):
	testCase()


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	x = 2 / 3 * b - 1 / 3 * a
	y = 2 / 3 * a - 1 / 3 * b
	if x >= 0 and y >= 0:
		print((a + b) // 3)
	elif a < b:
		print(a)
	else:
		print(b)


test = int(input())
while test != 0:
	(x, y) = map(int, input().split())
	if min(x, y) * 2 < max(x, y):
		print(min(x, y))
	elif min(x, y) * 2 >= max(x, y) and x != 0 and (y != 0):
		print(int((x + y) / 3))
	else:
		print(0)
	test = test - 1


for _ in range(int(input())):
	(m, n) = map(int, input().split())
	ans = 0
	if m == 2 and n == 2:
		ans = 1
	elif m == 2 and n == 3:
		ans = 1
	elif m == 3 and n == 2:
		ans = 1
	elif m == 0 or n == 0:
		ans = 0
	elif m >= 2 * n:
		ans = n
	elif n >= 2 * m:
		ans = m
	else:
		if n > m:
			(m, n) = (n, m)
		ans = 0
		temp = 0
		while m > 0 and n > 0:
			if m == 1 and n == 1:
				break
			temp = m // 2
			if temp % 2 == 1:
				temp += 1
			if m > n:
				m -= temp
				n -= temp // 2
			else:
				m -= temp // 2
				n -= temp
			ans += temp // 2
	print(ans)


tc = int(input().strip())
while tc:
	(n, m) = map(int, input().strip().split())
	ans = min(min(n, m), (n + m) // 3)
	print(ans)
	tc -= 1


for test_case in range(int(input())):
	(sticks, diamonds) = map(int, input().split())
	(high, low) = (max(sticks, diamonds), min(sticks, diamonds))
	money = 0
	if sticks > 1 or diamonds > 1:
		difference = high - low
		money = difference
		high -= difference * 2
		low -= difference * 1
		if min(high, low) < 0:
			money += min(high, low)
		if high == low and high > 1 and (low > 1):
			money += 2 * high // 3
	print(money)


t = int(input())
for q in range(t):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	z = b - a
	z = min(z, a)
	a -= z
	b -= z * 2
	if a == 0:
		print(z)
	else:
		z += a // 3 * 2
		a %= 3
		b %= 3
		if a >= 2:
			print(z + 1)
		else:
			print(z)


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


t = int(input())
i = 0
while i < t:
	summer = 0
	(n, m) = list(map(int, input().split()))
	mini = min(n, m)
	maxi = max(n, m)

	def spl(n):
		return 2 * (n // 3) + n % 3 // 2
	if maxi >= 2 * mini:
		print(mini)
	else:
		print(maxi - mini + spl(2 * mini - maxi))
	i += 1


def work():
	result = []
	init = []
	t = int(input())
	while t != 0:
		(a, b) = map(int, input().split())
		init.append((a, b))
		t -= 1
	for (a, b) in init:
		if 2 * a <= b:
			result.append(int(a))
		elif 2 * b <= a:
			result.append(int(b))
		elif a == 0 or b == 0:
			result.append(0)
		else:
			result.append(int((a + b) / 3))
	for r in result:
		print(r)
work()


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


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
from bisect import bisect_right

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())
P = 1000000007

def main():
	for t in range(I()):
		(a, b) = In()
		print(min(a, b, (a + b) // 3))
main()


t = int(input())
for x in range(t):
	arr = list(input().split(' '))
	a = int(arr[0])
	b = int(arr[1])
	sum = 0
	u = max(a, b) - min(a, b)
	c = max(a, b)
	d = min(a, b)
	c = c - 2 * u
	d = d - u
	if d <= 0:
		sum = min(a, b)
	else:
		sum = sum + u
		e = int(c / 3)
		sum = sum + 2 * e
		f = c % 3
		g = c % 3
		if f + g >= 3:
			sum = sum + 1
	print(sum)


import sys

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')

def solve(a, b):
	return min((a + b) // 3, a, b)

def main():
	for _ in range(ri()):
		(a, b) = ria()
		wi(solve(a, b))
main()


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if 2 * a - b < 0:
		print(a)
	elif 2 * b - a < 0:
		print(b)
	else:
		(x, y) = (2 * a - b, 2 * b - a)
		if x % 3 == 0 and y % 3 == 0:
			print((2 * a - b) // 3 + (2 * b - a) // 3)
		else:
			lu = 2 * (x // 3) + y // 3 + 1 <= a and x // 3 + 2 * (y // 3 + 1) <= b
			ru = 2 * (x // 3 + 1) + y // 3 + 1 <= a and x // 3 + 1 + 2 * (y // 3 + 1) <= b
			ld = 2 * (x // 3) + y // 3 <= a and x // 3 + 2 * (y // 3) <= b
			rd = 2 * (x // 3 + 1) + y // 3 <= a and x // 3 + 1 + 2 * (y // 3) <= b
			if ru:
				print(x // 3 + 1 + (y // 3 + 1))
			elif lu or ru:
				print(x // 3 + (y // 3 + 1))
			else:
				print(x // 3 + y // 3)


import sys, math, cmath, time
start_time = time.time()

def solve():
	(a, b) = invr()
	print(min(a, b, (a + b) // 3))

def main():
	global tt
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = inp()
	for tt in range(t):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
		sys.stdout.close()

def inp():
	return int(input())

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

def insr():
	return input().strip()

def invr():
	return map(int, input().split())

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q

def power_two(n):
	if n == 1:
		return True
	sttr = str(n)
	len_str = len(sttr)
	sttr = list(sttr)
	num = 0
	if len_str == 1 and sttr[len_str - 1] == '1':
		return False
	while len_str != 1 or sttr[len_str - 1] != '1':
		if (ord(sttr[len_str - 1]) - ord('0')) % 2 == 1:
			return False
		j = 0
		for i in range(len_str):
			num = num * 10 + (ord(sttr[i]) - ord('0'))
			if num < 2:
				if i != 0:
					sttr[j] = '0'
					j += 1
				continue
			sttr[j] = chr(num // 2 + ord('0'))
			j += 1
			num = num - num // 2 * 2
		len_str = j
	return True

def log_two(n):
	return math.log(n) / math.log(2)
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


from collections import Counter as ctr
from collections import defaultdict as dd
from sys import stdin, stdout
for t in range(int(stdin.readline().strip())):
	(a, b) = map(int, stdin.readline().strip().split())
	(a, b) = (max(a, b), min(a, b))
	if b <= a / 2:
		stdout.write(str(b) + '\n')
		continue
	stdout.write(str((a + b) // 3) + '\n')


import math
t = int(input())
a = []
for i in range(1, t + 1):
	(m, n) = input().split()
	m = int(m)
	n = int(n)
	if m == 0 or n == 0:
		a.append(0)
	elif m <= math.floor(n / 2):
		a.append(m)
	elif n <= math.floor(m / 2):
		a.append(n)
	else:
		a.append(math.floor((m + n) / 3))
for i in range(0, t):
	print(a[i])


from sys import stdin
A = int(stdin.readline())
for k in range(0, A):
	B = list(map(int, stdin.readline().split()))
	C = min(min(B[0], B[1]), int((B[0] + B[1]) // 3))
	print(C)


rr = lambda : input().strip()
rri = lambda : int(rr())
rrm = lambda : [int(x) for x in rr().split()]
from sys import stdin, stdout

def sol():
	(x, y) = rrm()
	res = 0
	while x > 4 and y > 4:
		if x < y:
			a = x // 4
			res += a
			x -= a
			y -= 2 * a
		else:
			a = y // 4
			res += a
			y -= a
			x -= 2 * a
	while x > 0 and y > 1 or (y > 0 and x > 1):
		if x < y:
			if x == 1:
				res += 1
				break
			a = x // 2
			res += a
			x -= a
			y -= 2 * a
		else:
			if y == 1:
				res += 1
				break
			a = y // 2
			res += a
			y -= a
			x -= 2 * a
	print(res)
	return
T = rri()
for t in range(1, T + 1):
	ans = sol()


from sys import stdin, exit
input = stdin.readline

def i():
	return input()

def ii():
	return int(input())

def iis():
	return map(int, input().split())

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

def print_array(a):
	print(' '.join(map(str, a)))
t = ii()
for _ in range(t):
	(a, b) = iis()
	count = 0
	first = min(a // 2, b)
	second = min(a, b // 2)
	maxi = min((a + b) // 3, a, b)
	print(max(first, second, maxi))


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


import sys
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def foo():
	(a, b) = invr()
	ans = min(a, b, (a + b) // 3)
	print(ans)
t = inp()
for i in range(t):
	foo()


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def solve():
	(n, m) = li()
	(n, m) = (min(n, m), max(n, m))
	if n * 2 <= m:
		print(n)
	else:
		print((n + m) // 3)
for _ in range(I()):
	solve()


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	(a, b) = sorted(value(), reverse=True)
	dif = a - b
	ans = min(a - b, b)
	a -= 2 * ans
	b -= ans
	ans1 = ans
	ans = 0
	k1 = a // 3
	k2 = b // 3
	ans = min(k1, k2) * 2
	a -= min(k1, k2) * 3
	b -= min(k1, k2) * 3
	if a > 1 and b > 0:
		a -= 2
		b -= 1
		ans += 1
	if a > 0 and b > 1:
		ans += 1
	print(ans + ans1)


t = int(input())
for i in range(t):
	c = input().split()
	a = int(c[0])
	b = int(c[1])
	ans = a
	if b < ans:
		ans = b
	if (a + b) // 3 < ans:
		ans = (a + b) // 3
	print(ans)


testcases = int(input())
for i in range(testcases):
	(d, s) = map(int, input().strip().split(' '))
	count = 0
	x = int((s + d) / 3)
	if d > s:
		if 2 * s <= d:
			print(s)
		else:
			print(int((s + d) / 3))
	elif 2 * d <= s:
		print(d)
	else:
		print(int((s + d) / 3))


for s in [*open(0)][1:]:
	a = (*map(int, s.split()),)
	print(min(*a, sum(a) // 3))


t = int(input())
compt_tot = []
for k in range(t):
	(a, b) = map(str, input().split())
	a = int(a)
	b = int(b)
	compt = 0
	if 2 * a <= b:
		compt = a
	elif 2 * b <= a:
		compt = b
	else:
		compt = int((a + b) / 3)
	compt_tot.append(compt)
for i in range(t):
	print(compt_tot[i])


class Solution(object):

	def shovels_and_swords(self, a: int, b: int) -> int:
		return min(a, b, (a + b) // 3)
for _ in range(int(input())):
	(l, r) = map(int, input().split())
	print(Solution().shovels_and_swords(l, r))


from sys import stdin
for _ in range(int(stdin.readline())):
	(a, b) = map(int, stdin.readline().split())
	j = max(min(a // 2, b), min(a, b // 2))
	if b // 2 < a and a // 2 < b:
		x = (2 * a - b) // 3 + (2 * b - a) // 3
		if (2 * a - b) % 3 == 2 and (2 * a - b) % 3 >= 1 or ((2 * a - b) % 3 >= 1 and (2 * a - b) % 3 == 2):
			x += 1
		j = max(j, x)
	print(j)


from collections import defaultdict as dd
import sys
input = sys.stdin.readline
t = int(input())
while t:
	(n, m) = map(int, input().split())
	if n > m:
		(n, m) = (m, n)
	if 2 * n <= m:
		print(n)
	else:
		ans = 0
		while abs(m - n) > 1:
			d = m - n
			ans += d
			m -= 2 * d
			n -= d
		if n != m:
			ans += 1
			n -= 1
			m -= 2
		ans += 2 * min(n // 3, m // 3)
		n = n % 3
		m = m % 3
		if n >= 1 and m == 2 or (m >= 1 and n == 2):
			ans += 1
		print(ans)
	t -= 1


from math import ceil
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	y = max(a, b)
	x = min(a, b)
	if x == 0:
		print(0)
		continue
	if y >= 2 * x:
		print(x)
		continue
	c = 0
	while x != y and x != 0:
		d = y - x
		s = ceil(d / 2)
		x = x - s
		y = y - 2 * s
		c = c + s
	w = x // 3
	c = c + 2 * w
	w = x % 3
	if w == 2:
		c = c + 1
	print(c)


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


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


for _ in range(int(input())):
	x = input().split(' ')
	a = int(x[0])
	b = int(x[1])
	if a >= 2 * b:
		print(b)
	elif b >= 2 * a:
		print(a)
	else:
		val = (a + b) // 3
		print(val)


t = int(input())
for k in range(t):
	ab = list(map(int, input().split()))
	a = min(ab)
	b = max(ab)
	count = 0
	if b > 2 * a:
		count = a
	else:
		am = b - a
		count = am
		bm = a - am
		rem = bm % 3
		div = bm // 3
		div = div * 2
		count = count + div
		if rem == 2:
			count = count + 1
	print(count)


t = int(input())
result = []
for i in range(t):
	a = [int(x) for x in input().split(' ')]
	kc = min(abs(a[0] - a[1]), a[0], a[1])
	if a[1] > a[0]:
		a[1] = a[1] - 2 * kc
		a[0] = a[0] - kc
	else:
		a[1] = a[1] - kc
		a[0] = a[0] - 2 * kc
	if a[0] > 0 and a[1] > 0:
		du = a[0] % 3
		chia = int(a[0] / 3)
		if du == 2:
			result.append(kc + chia * 2 + 1)
		else:
			result.append(kc + chia * 2)
	else:
		result.append(kc)
for i in result:
	print(i)


for i in range(int(input())):
	(s1, s2) = map(int, input().split())
	if s1 == 0 or s2 == 0:
		print(0)
	else:
		print(min(s1, s2, (s1 + s2) // 3))


import sys
import math
input = sys.stdin.readline
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	ans = 0
	while a and b:
		(a, b) = (min(a, b), max(a, b))
		v = min(b - a, a, b)
		ans += v
		a -= v
		b -= v * 2
		if a == b:
			ans += a // 3 * 2
			a %= 3
			if a == 2:
				ans += 1
			break
	print(ans)


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


import math

def fact(n):
	ans = 1
	for i in range(2, n + 1):
		ans *= i
	return ans

def comb(n, c):
	return fact(n) // (fact(n - c) * c)
for _ in range(int(input())):
	(a, b) = sorted(list(map(int, input().split())))
	ans = min(a, b, (a + b) // 3)
	print(ans)


its = int(input())
total = []
for a in range(its):
	(s, d) = [int(x) for x in input().split()]
	small = min(s, d)
	big = max(s, d)
	if small == big:
		tot = (small + big) // 3
	elif small * 2 <= big:
		tot = small
	else:
		dif = big - small
		tot = dif + (small - dif) * 2 // 3
	total.append(tot)
for x in total:
	print(x)


n = int(input())
a = list()
b = list()
for i in range(n):
	(au, bu) = input().split()
	a.append(int(au))
	b.append(int(bu))
for i in range(n):
	m = (a[i] + b[i]) // 3
	print(min(a[i], m, b[i]))


def ans(a, b):
	if a == 0 or b == 0 or max(a, b) < 2:
		return 0
	if a > b:
		n = min(b, a - b)
		return n + ans(b - n, a - 2 * n)
	elif b > a:
		n = min(a, b - a)
		return n + ans(a - n, b - 2 * n)
	elif a != 2:
		x = a // 3
		return 2 * x + ans(a - 3 * x, b - 3 * x)
	else:
		return 1
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	print(ans(a, b))


import sys, math
import io, os

def data():
	return sys.stdin.buffer.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
mod = int(1000000000.0) + 7
for i in range(int(data())):
	(a, b) = mdata()
	if b > a:
		(a, b) = (b, a)
	k = a // 2
	if k > b:
		out(b)
	else:
		t = b - k
		if t >= 2 and a % 2 != 0:
			a -= 1
			t -= 2
			k += 1
		ans = k
		while t // 4 > 0:
			ans += t // 4
			t = t % 4 + t // 4
			k -= 1
		if t == 3 and k > 0:
			ans += 1
		out(ans)


from math import ceil
for _ in range(int(input())):
	X = sorted(list(map(int, input().split())))
	RoundToEqual = min(X[0], X[-1] - X[0])
	print(int((X[0] - RoundToEqual) // 1.5) + RoundToEqual)


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


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(a, b) = sorted([a, b])
	res = (a + b) // 3
	if res > a:
		print(a)
	else:
		print(res)


import sys
input = sys.stdin.buffer.readline
t = int(input())
while t:
	t -= 1
	(a, b) = map(int, input().split())
	c = max(a, b)
	d = min(a, b)
	if c >= 2 * d:
		print(d)
	else:
		print((c + d) // 3)


t = int(input())
for s in range(t):
	(m, n) = map(int, input().split())
	if m > 0 and n > 0:
		(a, b) = (max(m, n), min(m, n))
		if b < a // 2:
			print(b)
		else:
			print((a + b) // 3)
	else:
		print(0)


import sys
readline = sys.stdin.readline

def solve():
	(A, B) = map(int, readline().split())
	if A > B:
		(A, B) = (B, A)
	if A * 2 <= B:
		print(A)
		return
	c = B - A
	ans = c
	(A, B) = (A - c, B - 2 * c)
	d = A % 3
	ans += A // 3 * 2
	if d == 2:
		ans += 1
	print(ans)
T = int(readline())
for t in range(T):
	solve()


def solve():
	global A, B
	S = 0
	(A, B) = (max(A, B), min(A, B))
	D = A - B
	S = min(D, B)
	B -= S
	A = B
	S += 2 * (A // 3)
	A = A % 3
	B = B % 3
	(A, B) = (max(A, B), min(A, B))
	S += int(A == 2 and B >= 1)
	return S
import os
for _ in range(int(input())):
	(A, B) = map(int, input().split())
	sol = solve()
	print(sol)


test = int(input())
while test:
	list = input()
	l = list.split()
	a = int(l[0])
	b = int(l[1])
	c = int((a + b) / 3)
	print(min(a, b, c))
	test = test - 1


t = input()
for _ in range(int(t)):
	(a, b) = map(int, input().split())
	if a < b:
		(a, b) = (b, a)
	d = a - b
	if d >= b:
		print(b)
	else:
		result = d
		a = a - 2 * d
		b = b - d
		if a % 3 == 2:
			result += 2 * (a - 2) / 3 + 1
		else:
			result += 2 * int(a / 3)
		print(int(result))


def calc(i, j):
	if i == 0 or j == 0:
		return 0
	if 2 * j < i or 2 * i < j:
		return min(i, j)
	if i == 2 and j == 1 or (i == 1 and j == 2) or (i == 2 and j == 2):
		return 1
	elif i == 0 and j == 1 or (i == 0 and j == 2) or (i == 1 and j == 0) or (i == 1 and j == 1) or (i == 2 and j == 0):
		return 0
	h = int(i / 3) + int(j / 3)
	return h + calc(i % 3, j % 3)
t = int(input())
while t:
	(a, b) = map(int, input().split())
	print(calc(a, b))
	t = t - 1


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def main():
	t = I()
	rr = []
	for _ in range(t):
		(n, m) = LI()
		if n > m:
			(n, m) = (m, n)
		t = m - n
		r = min(t, m // 2)
		if n <= r:
			rr.append(n)
		else:
			m -= r * 2
			r += m // 3 * 2
			m %= 3
			if m == 2:
				r += 1
			rr.append(r)
	return JA(rr, '\n')
print(main())


T = int(input())
for t_itr in range(T):
	(A, B) = map(int, input().rstrip().split())
	result = 0
	if A < B:
		(A, B) = (B, A)
	delta = A - B
	if delta >= B:
		result = B
	else:
		A -= delta * 2
		result = 2 * (A // 3) + delta
		if A % 3 > 1:
			result += 1
	print(result)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	counter = 0
	while a > 0 and b > 0:
		if a >= 2 * b:
			counter = b
			break
		elif b >= 2 * a:
			counter = a
			break
		elif a == b:
			if a % 3 == 0:
				counter += a // 3 * 2
			if a % 3 == 1:
				counter += a // 3 * 2
			if a % 3 == 2:
				counter += a // 3 * 2 + 1
			break
		elif a > b:
			nexus = a - b
			if nexus * 2 <= a:
				counter += nexus
				a -= nexus * 2
				b -= nexus
			else:
				counter += a // 2
				break
		elif a < b:
			nexus = b - a
			if nexus * 2 <= b:
				counter += nexus
				b -= nexus * 2
				a -= nexus
			else:
				counter += b // 2
				break
		if a == 1 and b == 1:
			break
	print(counter)


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)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	mi = min(a, b)
	ma = max(a, b)
	if a == 0 or b == 0:
		ans = 0
	elif mi <= ma // 2:
		ans = mi
	else:
		ans = (a + b) // 3
	print(ans)


import math
import sys
sys.setrecursionlimit(10 ** 4)

def Divisors(n):
	l = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
		i = i + 1
	return l

def SieveOfEratosthenes(n):
	l = []
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			l.append(p)
	return l

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(n)
	return l

def Factors(n):
	result = []
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			if i == n / i:
				result.append(i)
			else:
				result.append(i)
				result.append(n // i)
	result.append(1)
	result.append(n)
	return result

def maxSubArraySum(a):
	max_so_far = 0
	max_ending_here = 0
	size = len(a)
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far

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


def big(a, b):
	return a >= b

def inp():
	ls = list(map(int, input().split()))
	return ls
t = int(input())
for ii in range(t):
	(a, b) = map(int, input().split())
	if a and b == 0:
		print(0)
		continue
	if big(max(a, b), min(a, b) * 2):
		print(min(a, b))
		continue
	print((a + b) // 3)


w = int(input())
for x in range(w):
	d = [int(x) for x in input().split(' ')]
	if d[0] > 0 and d[1] > 0:
		if max(d) // min(d) < 2:
			print(sum(d) // 3)
		else:
			print(min(d))
	else:
		print(0)


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


def count_z(S, a, b):
	a -= S
	b -= 2 * S
	return S + min(b, a // 2)

def ternary_search(a, b):
	left = 0
	right = min(a, b // 2)
	while right > left + 2:
		p1 = left + (right - left) // 3
		p2 = left + 2 * (right - left) // 3
		if count_z(p1, a, b) > count_z(p2, a, b):
			right = p2
		else:
			left = p1
	res = 0
	for i in range(left, right + 1):
		res = max(res, count_z(i, a, b))
	return res

def main():
	t = int(input())
	for _ in range(t):
		(a, b) = tuple(map(int, input().split()))
		res = ternary_search(a, b)
		print(res)
main()


for _ in range(int(input())):
	(a, b) = tuple(map(int, input().split()))
	if a >= b * 2:
		print(b)
		continue
	elif b >= a * 2:
		print(a)
		continue
	(smaller, larger) = (a, b) if a < b else (b, a)
	if smaller == larger:
		print(2 * (smaller // 3) + smaller % 3 // 2)
	else:
		n = 2 * smaller - larger
		print(larger - smaller + 2 * (n // 3) + n % 3 // 2)


from sys import *
input = stdin.readline
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a < b:
		(a, b) = (b, a)
	sn = 0
	sn += min(a // 2, b)
	(a, b) = (a - 2 * sn, b - sn)
	if a >= 1 and b > 1:
		sn += 1
		b -= 2
		a -= 1
	sn += b // 3
	stdout.write(str(sn) + '\n')


n = int(input())
for i in range(0, n):
	l = input().split()
	b = int(l[0])
	a = int(l[1])
	t = a + b
	ans = int(t / 3)
	if ans > b:
		print(b)
	elif ans > a:
		print(a)
	else:
		print(ans)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if a and b:
		temp = (a + b) // 3
		res = min(a, b, temp)
		print(res)
	else:
		print(0)


t = int(input())
rez = []
for i in range(t):
	A = input().split(' ')
	m = int(A[0])
	l = int(A[1])
	if l == 0 or m == 0:
		rez.append(0)
	elif min(l, m) * 2 <= max(l, m):
		rez.append(min(l, m))
	elif m == l:
		rez.append(int(2 * l // 3))
	else:
		n = max(l, m) - min(l, m)
		rez.append(int((l + m) // 3))
for i in range(len(rez)):
	print(rez[i])


import sys
from math import *
from collections import defaultdict
from queue import deque
from heapq import heappush, heappop
lines = [line.strip() for line in sys.stdin.readlines()]
for (a, b) in [map(int, line.split()) for line in lines[1:]]:
	(a, b) = (min(a, b), max(a, b))
	print(min(a, (a + b) // 3))


import sys, bisect, string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby
rep = range

def Golf():
	(n, *t) = map(int, open(0).read().split())

def I():
	return int(input())

def S_():
	return input()

def IS():
	return input().split()

def LS():
	return [i for i in input().split()]

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def RA():
	return map(int, open(0).read().split())

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in range(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def accum(ls):
	rt = [0]
	for i in ls:
		rt += [rt[-1] + i]
	return rt

def bit_combination(n, base=2):
	rt = []
	for tb in range(base ** n):
		s = [tb // base ** bt % base for bt in range(n)]
		rt += [s]
	return rt

def gcd(x, y):
	if y == 0:
		return x
	if x % y == 0:
		return y
	while x % y != 0:
		(x, y) = (y, x % y)
	return y

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
YN = ['YES', 'NO']
Yn = ['Yes', 'No']
mo = 10 ** 9 + 7
inf = float('inf')
FourNb = [(-1, 0), (1, 0), (0, 1), (0, -1)]
EightNb = [(-1, 0), (1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('WENS', FourNb))
cursol = dict(zip('LRUD', FourNb))
l_alp = string.ascii_lowercase
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
input = lambda : sys.stdin.readline().rstrip()

class Tree:

	def __init__(self, inp_size=None, ls=None, init=True, index=1):
		self.LCA_init_stat = False
		self.ETtable = []
		if init:
			if ls == None:
				self.stdin(inp_size, index=index)
			else:
				self.size = len(ls) + 1
				(self.edges, _) = GI(self.size, self.size - 1, ls, index=index)
		return

	def stdin(self, inp_size=None, index=1):
		if inp_size == None:
			self.size = int(input())
		else:
			self.size = inp_size
		(self.edges, _) = GI(self.size, self.size - 1, index=index)
		return

	def listin(self, ls, index=0):
		self.size = len(ls) + 1
		(self.edges, _) = GI(self.size, self.size - 1, ls, index=index)
		return

	def dfs(self, x, func=lambda pr, prv, nx, dist: prv + dist, root_v=0):
		q = deque([x])
		v = [None] * self.size
		v[x] = root_v
		while q:
			c = q.pop()
			for (nb, d) in self.edges[c]:
				if v[nb] == None:
					q.append(nb)
					v[nb] = func(c, v[c], nb, d)
		return v

	def bfs(self, x, func=lambda pr, prv, nx, dist: prv + dist, root_v=0):
		q = deque([x])
		v = [None] * self.size
		v[x] = root_v
		while q:
			c = q.popleft()
			for (nb, d) in self.edges[c]:
				if v[nb] == None:
					q.append(nb)
					v[nb] = func(c, v[c], nb, d)
		return v

	def parent(self, x):
		return self.dfs(0, func=lambda pr, prv, nx, dist: pr, root_v=-1)

	def topological_sort(self, x):
		tps = []
		q = deque([x])
		v = [None] * self.size
		v[x] = 0
		while q:
			c = q.popleft()
			tps.append(c)
			for (nb, d) in self.edges[c]:
				if v[nb] == None:
					q.append(nb)
					v[nb] = 0
		return tps

	def EulerTour(self, x):
		q = deque()
		q.append(x)
		self.depth = [None] * self.size
		self.depth[x] = 0
		self.ETtable = []
		self.ETdepth = []
		self.ETin = [-1] * self.size
		self.ETout = [-1] * self.size
		cnt = 0
		while q:
			c = q.pop()
			if c < 0:
				ce = ~c
			else:
				ce = c
				for (nb, d) in self.edges[ce]:
					if self.depth[nb] == None:
						q.append(~ce)
						q.append(nb)
						self.depth[nb] = self.depth[ce] + 1
			self.ETtable.append(ce)
			self.ETdepth.append(self.depth[ce])
			if self.ETin[ce] == -1:
				self.ETin[ce] = cnt
			else:
				self.ETout[ce] = cnt
			cnt += 1
		return

	def LCA_init(self, root):
		self.EulerTour(root)
		self.st = SparseTable(self.ETdepth, init_func=min, init_idl=inf)
		self.LCA_init_stat = True
		return

	def LCA(self, root, x, y):
		if self.LCA_init_stat == False:
			self.LCA_init(root)
		(xin, xout) = (self.ETin[x], self.ETout[x])
		(yin, yout) = (self.ETin[y], self.ETout[y])
		a = min(xin, yin)
		b = max(xout, yout, xin, yin)
		id_of_min_dep_in_et = self.st.query_id(a, b + 1)
		return self.ETtable[id_of_min_dep_in_et]

	def __str__(self):
		return str(self.edges)

	def show(self):
		if all([all([d == 1 for (nd, d) in edge]) for edge in self.edges]):
			print([[nd for (nd, d) in edge] for edge in self.edges])
		else:
			print(self)

class SparseTable:

	def __init__(self, ls, init_func=min, init_idl=float('inf')):
		self.func = init_func
		self.idl = init_idl
		self.size = len(ls)
		self.N0 = self.size.bit_length()
		self.table = [ls[:]]
		self.index = [list(range(self.size))]
		self.lg = [0] * (self.size + 1)
		for i in range(2, self.size + 1):
			self.lg[i] = self.lg[i >> 1] + 1
		for i in range(self.N0):
			tmp = [self.func(self.table[i][j], self.table[i][min(j + (1 << i), self.size - 1)]) for j in range(self.size)]
			tmp_id = [self.index[i][j] if self.table[i][j] == self.func(self.table[i][j], self.table[i][min(j + (1 << i), self.size - 1)]) else self.index[i][min(j + (1 << i), self.size - 1)] for j in range(self.size)]
			self.table += [tmp]
			self.index += [tmp_id]

	def query(self, l, r):
		if r > self.size:
			r = self.size
		N = self.lg[r - l]
		return self.func(self.table[N][l], self.table[N][max(0, r - (1 << N))])

	def query_id(self, l, r):
		if r > self.size:
			r = self.size
		N = self.lg[r - l]
		(a, b) = (self.index[N][l], self.index[N][max(0, r - (1 << N))])
		if self.table[0][a] == self.func(self.table[N][l], self.table[N][max(0, r - (1 << N))]):
			b = a
		return b

	def right_bound(self, pos, x):
		k = (self.size - pos).bit_length()
		for j in range(k)[::-1]:
			nx = pos + (1 << j)
			if nx < n and self.query(pos, nx + 1) <= x:
				pos += 1 << j
		return pos

	def left_bound(self, pos, x):
		k = pos.bit_length()
		for j in range(k)[::-1]:
			nx = pos - (1 << j)
			if 0 <= nx and self.query(nx, pos + 1) <= x:
				pos -= 1 << j
		return pos

	def __str__(self):
		return str(self.table[0])

	def print(self):
		for i in self.table:
			print(*i)

class UnionFind:

	def __init__(self, n):
		self.table = [-1] * n

	def _root(self, x):
		if self.table[x] < 0:
			return x
		else:
			self.table[x] = self._root(self.table[x])
			return self.table[x]

	def find(self, x, y):
		return self._root(x) == self._root(y)

	def union(self, x, y):
		r1 = self._root(x)
		r2 = self._root(y)
		if r1 == r2:
			return
		d1 = self.table[r1]
		d2 = self.table[r2]
		if d1 <= d2:
			self.table[r2] = r1
			if d1 == d2:
				self.table[r1] -= 1
		else:
			self.table[r1] = r2

	def __str__(self):
		rt = [i if j < 0 else j for (i, j) in enumerate(self.table)]
		return str(rt)
show_flg = False
show_flg = True
ans = 0
from math import ceil, floor
import sys

def solve(R, B):
	(R, B)
	(x, y) = (2, 2)

	def check(k):
		if min(R, B) < k:
			return False
		t = (R - k) // (x - 1)
		t += (B - k) // (y - 1)
		if t >= k:
			return True
		else:
			return False
	mi = 0
	ma = 10 ** 20 + 1
	while ma - mi > 1:
		mid = (ma + mi) // 2
		if check(mid):
			mi = mid
		else:
			ma = mid
	return mi
for _ in range(I()):
	ans = 0
	print(solve(*LI()))


def result(a, b):
	MIN = min(a, b)
	MAX = max(a, b)
	if MAX >= 2 * MIN:
		return MIN
	return (a + b) // 3
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
	else:
		print(result(a, b))


for i in range(int(input())):
	(gravetos, diamante) = input().split()
	gravetos = int(gravetos)
	diamante = int(diamante)
	if gravetos == 0 or diamante == 0:
		print(0)
	elif gravetos >= 2 * diamante:
		print(diamante)
	elif diamante >= 2 * gravetos:
		print(gravetos)
	else:
		aux = (diamante + gravetos) // 3
		print(aux)


for ii in range(int(input())):
	(n, m) = map(int, input().split())
	x = min(n, m)
	y = max(n, m)
	print(min(x, y, (x + y) // 3))


for xyz in range(0, int(input())):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	if b >= 2 * a:
		print(a)
	else:
		ans = b - a
		a = 2 * a - b
		ans += 2 * (a // 3)
		a = a % 3
		if a == 1 or a == 0:
			print(ans)
		else:
			print(ans + 1)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	print(max(min(max(n, k) // 2, min(n, k)), min((n + k) // 3, min(n, k))))


n = int(input())
for i in range(n):
	(s, d) = map(int, input().split())
	if 2 * s <= d:
		print(s)
	elif 2 * d <= s:
		print(d)
	else:
		print((s + d) // 3)


import sys, math, bisect
from collections import Counter, defaultdict as dd

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def l():
	return list(sp())

def strl():
	return list(strsp())

def sp():
	return map(int, data().split())

def strsp():
	return map(str, data().split())
for _ in range(int(data())):
	(a, b) = l()
	if a == 0 or b == 0:
		print(0)
	else:
		print(min((a + b) // 3, a, b))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(a, b) = map(int, input().split())

	def f(x):
		rema = a - 2 * x
		remb = b - x
		return x + min(rema, remb // 2)
	lo = 0
	hi = min(a // 2, b)
	while hi - lo >= 5:
		mid = (lo + hi) // 2
		if f(mid) <= f(mid + 1):
			lo = mid
		else:
			hi = mid + 1
	for i in range(lo + 1, hi + 1):
		if f(lo) < f(i):
			lo = i
	print(f(lo))


t = int(input())
count = 0
while count < t:
	count += 1
	l = list(map(int, input().split(' ')))
	a = l[0]
	b = l[1]
	c = max(a, b)
	d = min(a, b)
	if c >= 2 * d:
		print(d)
	else:
		ans = c - d
		d -= ans
		c -= 2 * ans
		ans += 2 * (c // 3)
		c = c % 3
		d = d % 3
		if c + d > 2:
			ans += 1
		print(ans)


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	(a, b) = map(int, stdin.readline().split())
	if a > b:
		(a, b) = (b, a)
	if b >= 2 * a:
		print(a)
	else:
		print((a + b) // 3)


def solve(a, b):
	Ps = [(0, 0), (a, 0), (b, 0), (a // 2, 0), (b // 2, 0), ((2 * b - a) // 3, (2 * a - b) // 3)]
	max_res = 0
	for (ll, mm) in Ps:
		for (lll, mmm) in [(ll, mm), (mm, ll)]:
			for dl in range(-1, 2):
				for dm in range(-1, 2):
					l = lll + dl
					m = mmm + dm
					if 0 <= l and 0 <= m and (2 * l + m <= a) and (2 * m + l <= b):
						max_res = max(l + m, max_res)
	return max_res
T = int(input())
for _ in range(T):
	(A, B) = [int(x) for x in input().split()]
	print(solve(A, B))


import collections

def read():
	return input().strip()

def readInt():
	return int(input().strip())

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

def solve(a, b):
	ans = 0
	while a and b:
		[a, b] = sorted([a, b])
		res = b - a
		if res == 0:
			ans += (a + b) // 3
			a -= a
			b -= b
		elif res > a:
			ans += a
			a -= a
			b -= 2 * a
		else:
			ans += res
			a -= res
			b -= 2 * res
	return ans
t = readInt()
for i in range(t):
	[a, b] = readList()
	print(solve(a, b))


for _ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	if x < y:
		(x, y) = (y, x)
	r = min(y, x - y)
	x -= 2 * r
	y -= r
	m = min(x, y) - min(x, y) % 3
	x -= m
	y -= m
	if x >= 2 and y >= 1 or (x >= 1 and y >= 2):
		r += 1
	print(r + m // 3 * 2)


T = int(input())
for t in range(T):
	(a, b) = list(map(int, input().split()))
	(mini, maxi) = (min([a, b]), max([a, b]))
	diff = maxi - mini
	first_item = min(diff, mini)
	res = first_item
	mini -= first_item
	maxi -= 2 * first_item
	(mini, maxi) = (min(mini, maxi), max(mini, maxi))
	if mini != 0:
		r = mini // 3
		res += 2 * r
		mini -= 3 * r
		maxi -= 3 * r
		while mini > 0:
			if maxi >= 2 * mini:
				res += mini
				break
			mini -= 1
	print(res)


t = int(input())
for _ in range(t):
	(a, b) = tuple(map(int, input().split()))
	ans = 0
	if a < b:
		(a, b) = (b, a)
	x = a - b
	if x > b:
		ans = b
	else:
		b -= x
		a -= 2 * x
		ans += x
	if a > 0 and a == b:
		ans += a * 2 / 3
	print(int(ans))


test_cases = int(input())
for z in range(test_cases):
	(a, b) = list(map(int, input().split()))
	ans = (a + b) // 3
	if ans <= min(a, b):
		print(ans)
	else:
		print(min(a, b))


t = int(input())
for i in range(t):
	(m, n) = list(map(int, input().split(' ')))
	_sum = m + n
	m = min(m, n)
	n = _sum - m
	if 2 * m <= n:
		print(m)
	else:
		print((m + n) // 3)


from sys import stdin
from collections import defaultdict as dd
from collections import deque as dq
import itertools as it
from math import sqrt, log, log2, ceil
from fractions import Fraction
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
		continue
	if b > a:
		(a, b) = (b, a)
	if a >= 2 * b:
		print(b)
		continue
	else:
		ans = 0
		diff = a - b
		ans += diff
		a = a - 2 * diff
		b = b - diff
		ans += 2 * (a // 3) + (1 if a % 3 == 2 else 0)
		print(ans)


t = int(input())
while t > 0:
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	if a < b:
		temp = a
		a = b
		b = temp
	x = (a + b) // 3
	if x < b:
		print(x)
	else:
		print(b)
	t -= 1


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def sieve_of_eratosthenes(n):
	ans = []
	arr = [1] * (n + 1)
	(arr[0], arr[1], i) = (0, 0, 2)
	while i * i <= n:
		if arr[i] == 1:
			j = i + i
			while j <= n:
				arr[j] = 0
				j += i
		i += 1
	for k in range(n):
		if arr[k] == 1:
			ans.append(k)
	return ans

def nc2(x):
	if x == 1:
		return 0
	else:
		return x * (x - 1) // 2
for _ in range(int(input()) if True else 1):
	(o, z) = map(int, input().split())
	print(min(o, z, (o + z) // 3))


import sys
input = sys.stdin.readline
import math

def inp():
	return int(input())

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

def insr():
	s = input().strip()
	return list(s[:len(s)])

def invr():
	return map(int, input().strip().split())

def from_file(f):
	return f.readline

def solve(a, b):
	if a < b:
		(a, b) = (b, a)
	k = a - b
	if k >= b:
		return b
	left = 2 * b - a
	res = left // 3
	res *= 2
	if left % 3 == 2:
		res += 1
	res += k
	return res
t = inp()
for _ in range(t):
	(a, b) = invr()
	print(solve(a, b))


from math import *
from random import *
for t in range(int(input())):
	(a, b) = map(int, input().split())
	if a < b:
		(a, b) = (b, a)
	otv = 0
	if a > b:
		if a - b >= b:
			print(b)
			continue
		else:
			p = a - b
			a -= p * 2
			b -= p
			otv += p
	otv += a // 3 * 2
	a %= 3
	b %= 3
	if a == 2 and b == 1 or (a == 1 and b == 2) or (a == 2 and b == 2):
		otv += 1
	print(otv)


def tran(arr):
	a = arr[0]
	b = arr[1]
	if a > b:
		(a, b) = (b, a)
	if a == 0 or b == 0:
		return 0
	elif a == b:
		return int(2 * a / 3)
	elif b >= 2 * a:
		return a
	else:
		s = b - a
		a = a - s
		return s + int(2 * a / 3)
t = int(input())
ans = []
for i in range(t):
	arr = list(map(int, input().rstrip().split()))
	r = tran(arr)
	ans.append(r)
for i in ans:
	print(i)


from sys import stdin, stdout
from collections import defaultdict
import heapq

def get_int():
	return int(stdin.readline().strip())

def get_ints():
	return map(int, stdin.readline().strip().split())

def get_array():
	return list(map(int, stdin.readline().strip().split()))

def get_string():
	return stdin.readline().strip()
INF = 10000000000.0
for _ in range(int(stdin.readline())):
	(a, b) = get_ints()
	print(min(min(a, b), (a + b) // 3))


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


import sys
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
tc = int(input())
for zz in range(tc):
	(a, b) = map(int, input().split())
	if b < a:
		(a, b) = (b, a)
	m = b - a
	if m >= a:
		print(a)
	else:
		a -= m
		n = 2 * a // 3
		print(m + n)


for s in [*open(0)][1:]:
	(a, b) = sorted(map(int, s.split()))
	r = min(a, b - a)
	x = max(0, 2 * a - b)
	print(r + x // 3 * 2 + (x % 3 > 1))


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


import math
from collections import defaultdict
ml = lambda : map(int, input().split())
ll = lambda : list(map(int, input().split()))
ii = lambda : int(input())
ip = lambda : input()
ips = lambda : input().split()
t = 1
t = ii()
for _ in range(t):
	(a, b) = ml()
	if a > b:
		(a, b) = (b, a)
	ans = 0
	if b > 2 * a:
		print(a)
	else:
		if b > a:
			c = min(a, b // 2)
			ans += c
			a -= c
			b -= c * 2
		print(ans + (a + b) // 3)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	l = 0
	r = 10 ** 9
	while r - l > 1:
		m = l + (r - l) // 2
		A = a
		B = b
		A -= m
		B -= m
		flag = 1
		if A >= 0 and B >= 0:
			if A + B < m:
				flag = 0
		else:
			flag = 0
		if flag == 1:
			l = m
		else:
			r = m
	print(l)


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


import math
import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	if a * 2 <= b:
		print(a)
		continue
	k = 0
	if a != b:
		k = b - a
	a -= k
	if a == 2:
		k += 1
		print(k)
	elif a == 1:
		print(k)
	else:
		q = a // 3
		if a % 3 == 2:
			print(k + q * 2 + 1)
		else:
			print(k + q * 2)


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


for i in range(int(input())):
	(a, b) = map(int, input().split())
	e = min(a, b)
	f = max(a, b)
	if e == 0 or f == 0:
		print(0)
	else:
		c = (e + f) // 3
		if c > e:
			print(e)
		else:
			print(c)


import sys
inp = sys.stdin.readline
for i in range(int(inp())):
	(a, b) = map(int, inp().split())
	(a, b) = (max(a, b), min(a, b))
	if (a + b) // 3 <= b:
		print((a + b) // 3)
	else:
		print(b)


t = int(input())
while t:
	t = t - 1
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	if a == 0 or b == 0:
		print(0)
	elif a >= 2 * b or b >= 2 * a:
		print(min(a, b))
	else:
		print((a + b) // 3)


import math
t = int(input())
for j in range(t):
	temp = input()
	(a, b) = temp.split(' ')
	a = int(a)
	b = int(b)
	if a == 0 or b == 0:
		print(0)
	elif a >= 2 * b or b >= 2 * a:
		print(min(a, b))
	else:
		print(int((a + b) / 3))


tt = int(input())
ans = []
for T in range(tt):
	(a, b) = [int(i) for i in input().split()]
	ans.append(min([a, b, (a + b) // 3]))
for aa in ans:
	print(aa)


import sys
ip = lambda : sys.stdin.readline().rstrip()
for _ in range(int(ip())):
	(a, b) = map(int, ip().split())
	(a, b) = sorted([a, b])
	if a == 0 or b == 0:
		print(0)
	elif b >= 2 * a:
		print(a)
	else:
		print((a + b) // 3)


import time, math, bisect
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IO():
	return stdin.readline()

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def readTree():
	v = int(input())
	adj = [set() for i in range(v + 1)]
	for i in range(v - 1):
		(u1, u2) = In()
		adj[u1].add(u2)
		adj[u2].add(u1)
	return (adj, v)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def solve():
	(n, k) = IP()
	(mx, mn) = (max(n, k), min(n, k))
	x = mx // 2
	if x >= mn:
		print(mn)
	else:
		print((n + k) // 3)
t = II()
for i in range(t):
	solve()


n = int(input())
for q in range(n):
	(a, b) = map(int, input().split())
	c = max(a, b)
	d = a + b - c
	m = c - d
	cnt = m
	d -= m
	c -= 2 * m
	if d < 0:
		cnt += d
	elif c < 0:
		cnt += c
	else:
		cnt += (c + d) // 3
	print(cnt)


import sys
import random
strInp = lambda : input().strip().split()
intInp = lambda : list(map(int, strInp()))
for t in range(int(input())):
	(a, b) = intInp()
	print(min((a + b) // 3, min(a, b)))


from fractions import Fraction
from collections import defaultdict
import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
t = int(input())
for _ in range(t):
	(a, b) = [int(x) for x in input().split()]
	if a == 0 or b == 0:
		print('0')
	else:
		na = max(a, b)
		nb = min(a, b)
		if na >= 2 * nb:
			print(nb)
		else:
			c = a - b
			l = b - c
			d = l // 3 * 2 + l % 3 // 2
			print(c + d)


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


import sys
read = sys.stdin.buffer.readline
cin = lambda : int(read())
mi = lambda : map(int, read().split())
for _ in range(cin()):
	(a, b) = mi()
	(a, b) = (min(a, b), max(a, b))
	ans = min(min(a, b), max(a, b) // 2)
	ct = 0
	d = a - ans
	while d > 1:
		tmp = d // 2
		ct += tmp
		b -= tmp
		a -= 2 * tmp
		(a, b) = (min(a, b), max(a, b))
		d = a - min(a, b // 2)
	print(ct + min(a, b // 2))


t = int(input())
while t:
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
	elif a == 1 and b == 1:
		print(0)
	elif a >= 2 * b:
		print(b)
	elif b >= 2 * a:
		print(a)
	elif a >= b:
		n1 = a // 2
		n2 = (a + b) // 3
		if n2 <= min(a, b):
			print(max(n1, n2))
		else:
			print(n1)
	else:
		n1 = b // 2
		n2 = (a + b) // 3
		if n2 <= min(a, b):
			print(max(n1, n2))
		else:
			print(n1)
	t -= 1


for _ in range(int(input())):
	(st, di) = map(int, input().split())
	if st >= 2 * di or di >= 2 * st:
		print(min(st, di))
	else:
		y = (st % 3 + di % 3) // 3
		x = st // 3 + di // 3
		print(x + y)


import math
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
	elif a > b * 2:
		print(b)
	elif b > a * 2:
		print(a)
	elif a >= b:
		ans = (a + b) // 3
		a -= ans * 2
		b -= ans
		ans += (a + b) // 3
		print(ans)
	elif b >= a:
		ans = (a + b) // 3
		a -= ans
		b -= ans * 2
		ans += (a + b) // 3
		print(ans)


import os
import sys
debug = True
if debug and os.path.exists('input.in'):
	input = open('input.in', 'r').readline
else:
	debug = False
	input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
test_count = int(input())
for t in range(test_count):
	if debug:
		print('Test Case #', t + 1)
	(a, b) = invr()
	print(min(a, b, (a + b) // 3))


t = int(input())
for test in range(t):
	(a, b) = [int(x) for x in input().split()]
	minn = min(a, b)
	maxx = max(a, b)
	diff = maxx - minn
	ans = 0
	if diff <= minn:
		minn -= diff
		ans += diff
		maxx -= 2 * diff
		delta = minn // 3
		frac = minn % 3
		ans += 2 * delta
		if frac == 2:
			ans += 1
	else:
		ans = minn
	print(ans)


import math
t = int(input())
while t > 0:
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	res = min(a, b)
	res = min(res, int((a + b) / 3))
	print(res)
	t -= 1


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	r = 0
	if a == b:
		t = a // 3
		l = a % 3
		if l == 2:
			print(2 * t + 1)
		else:
			print(2 * t)
	elif a > b:
		fark = a - b
		r += fark
		a -= 2 * fark
		b -= fark
		if a == 0:
			print(r)
		elif a > 0:
			t = a // 3
			l = a % 3
			if l == 2:
				print(2 * t + 1 + r)
			else:
				print(2 * t + r)
		else:
			u = -b
			print(r - u)
	else:
		fark = b - a
		r += fark
		a -= fark
		b -= 2 * fark
		if a == 0:
			print(r)
		elif a > 0:
			t = a // 3
			l = a % 3
			if l == 2:
				print(2 * t + 1 + r)
			else:
				print(2 * t + r)
		else:
			u = -a
			print(r - u)


import sys
import math
import collections

def set_debug(debug_mode=False):
	if debug_mode:
		fin = open('input.txt', 'r')
		sys.stdin = fin

def int_input():
	return list(map(int, input().split()))
t = int(input())
for ti in range(1, t + 1):
	(a, b) = int_input()
	if b > a:
		(a, b) = (b, a)
	if a >= 2 * b:
		print(b)
		continue
	res = a - b
	res += (2 * b - a) // 3 * 2
	if (2 * b - a) % 3 == 2:
		res += 1
	print(res)


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()


t = int(input())

def ans(a, b):
	if a < 1 or b < 1:
		return 0
	if a == 1 and b == 1:
		return 0
	if min(a, b) == abs(a - b):
		return abs(a - b)
	if min(a, b) < abs(a - b):
		return min(a, b)
	else:
		diff = abs(a - b)
		p = min(a, b) - diff
		if p == 1 or p == 0:
			return diff
		return abs(a - b) + int(2 * p / 3)
for qq in range(t):
	(a, b) = map(int, input().split())
	print(ans(a, b))


t = int(input())

def solve(a, b):
	if a < 1:
		return 0
	elif b >= 2 * a:
		return a
	else:
		return (a + b) // 3
while t > 0:
	l = [int(x) for x in input().split()]
	(a1, b1) = (l[0], l[1])
	a = min(a1, b1)
	b = a1 + b1 - a
	print(solve(a, b))
	t -= 1


n = int(input())
for k in range(n):
	(a, b) = map(int, input().split())
	if a >= b * 2:
		print(b)
	elif b >= a * 2:
		print(a)
	else:
		(a, b) = (max(a, b), min(a, b))
		d = a - b
		a -= 2 * d
		b -= d
		r = d
		pr = min(a // 3, b // 3)
		a -= pr * 3
		b -= pr * 3
		pr *= 2
		while a >= 2 and b >= 1 or (a >= 1 and b >= 2):
			if a >= 1 and b >= 2:
				pr += 1
				a -= 1
				b -= 2
			elif a >= 2 and b >= 1:
				pr += 1
				a -= 2
				b -= 1
		print(r + pr)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	val = min(max(a, b) // 2, min(a, b))
	ans = val + (min(a, b) - val + max(a, b) % 2) // 3
	print(ans)


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	(a, b) = (l[0], l[1])
	if a == b and a == 1:
		print(0)
	elif a == 0 or b == 0:
		print(0)
	elif 2 * a < b:
		print(a)
	elif 2 * b < a:
		print(b)
	else:
		print((a + b) // 3)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	if b >= a * 2:
		ans = a
	else:
		x1 = 2 * (b - a / 2) / 3
		x2 = int(x1)
		x3 = x2 + 1
		y2 = b - 2 * x2
		y3 = b - 2 * x3
		ans = 0
		if x2 + 2 * y2 <= a and 2 * x2 + y2 <= b:
			ans = x2 + y2
		if x3 + 2 * y3 <= a and 2 * x3 + y3 <= b and (x3 + y3 > ans):
			ans = x3 + y3
	print(ans)


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

def readn():
	return int(input())
N = readn()
for _ in range(N):
	(a, b) = readintlst()
	allx = min(a // 2, b)
	ally = min(a, b // 2)
	ans = max(allx, ally)
	if a >= 2 * b or b >= 2 * a:
		print(ans)
	else:
		print((a + b) // 3)


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	t = int(input())
	for i in range(t):
		ab = list(map(int, input().split()))
		(a, b) = (ab[0], ab[1])
		(mn, mx) = (min(a, b), max(a, b))
		if mx >= 2 * mn:
			print(mn)
		else:
			print((a + b) // 3)
main()


import sys
import math
from collections import defaultdict

def solve(test):
	(s, d) = map(int, input().split())
	mx = max(s, d)
	mn = min(s, d)
	ans = min(mn, (mx + mn) // 3)
	print(ans)
test_cases = int(input())
for t in range(1, test_cases + 1):
	solve(t)


for I in range(int(input())):
	(s, d) = map(int, input().split())
	mini = min(s, d)
	temp = (s + d) // 3
	if s >= temp and d >= temp:
		print(temp)
	else:
		print(mini)


def solve(a, b):
	if a == 0 or b == 0:
		return 0
	res = (a + b) // 3
	return min(res, a, b)
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	print(solve(a, b))


T = int(input())
for i in range(T):
	(s, d) = map(int, input().split())
	if s < d:
		(s, d) = (d, s)
	if s >= 2 * d:
		print(d)
	else:
		print((s + d) // 3)


t = int(input())
while t != 0:
	(p, q) = map(int, input().split())
	count = 0
	while p != 0 and q != 0:
		if p == q:
			count += (p + q) // 3
			break
		else:
			(a, b) = (max(p, q), min(p, q))
			x = min(a - b, b)
			a = a - 2 * x
			b = b - x
			count += x
			if p > q:
				p = a
				q = b
			else:
				q = a
				p = b
	print(count)
	t -= 1


from __future__ import division, print_function
import itertools
import sys
import os
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	input = raw_input
	range = xrange
	filter = itertools.ifilter
	map = itertools.imap
	zip = itertools.izip

def is_it_local():
	script_dir = str(os.getcwd()).split('/')
	username = 'dipta007'
	return username in script_dir

def READ(fileName):
	if is_it_local():
		sys.stdin = open(f'./{fileName}', 'r')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if not is_it_local():
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')

def input1(type=int):
	return type(input())

def input2(type=int):
	[a, b] = list(map(type, input().split()))
	return (a, b)

def input3(type=int):
	[a, b, c] = list(map(type, input().split()))
	return (a, b, c)

def input_array(type=int):
	return list(map(type, input().split()))

def input_string():
	s = input()
	return list(s)

def way(n, m):
	print(n, m)
	k = min(n // 2, m)
	n -= k * 2
	m -= k
	print(n, m)
	k += min(m // 2, n)
	return k

def f(n, m, now):
	n -= now
	m -= now * 2
	return now + min(n // 2, m)

def main():
	t = input1()
	for ci in range(t):
		(n, m) = input2()
		lo = -1
		hi = min(n, m // 2)
		while hi - lo > 1:
			mid = hi + lo >> 1
			if f(n, m, mid) > f(n, m, mid + 1):
				hi = mid
			else:
				lo = mid
		print(f(n, m, lo + 1))
	pass
READ('in.txt')
main()


t = int(input())
while t > 0:
	(sticks, diamonds) = map(int, input().split())
	if sticks == 0 or diamonds == 0:
		print(0)
		t -= 1
		continue
	ans = (sticks + diamonds) // 3
	if sticks <= ans and sticks <= diamonds:
		print(sticks)
	elif diamonds <= ans and diamonds <= sticks:
		print(diamonds)
	else:
		print(ans)
	t -= 1


T = int(input())
mapi = [[]]

def recursive(d, s):
	try:
		if mapi[d][s] != None:
			return mapi[d][s]
	except:
		print(d, s, len(mapi), len(mapi[0]))
	ans = 0
	if d == 1 and s < 2 or (s == 1 and d < 2) or d <= 0 or (s <= 0):
		return 0
	ans = max(recursive(d - 1, s - 2) + 1, recursive(d - 2, s - 1) + 1)
	mapi[d][s] = ans
	return ans
for i in range(T):
	inp = input().split()
	s = int(inp[0])
	d = int(inp[1])
	ans = 0
	ans = min(d, s, (d + s) // 3)
	print(ans)


a = int(input())
for k in range(a):
	(b, c) = list(map(int, input().split()))
	if (b + c) // 3 <= min(b, c):
		print((b + c) // 3)
	else:
		print(min(b, c))


for t in range(int(input())):
	(n, m) = (int(i) for i in input().split())
	mm = max(n, m)
	nn = min(n, m)
	if mm >= 2 * nn:
		print(nn)
	else:
		print((mm + nn) // 3)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	ans = min(min(a, b), max(a, b) // 2)
	x = (2 * a - b) / 3
	y = a - 2 * x
	if x > 0 and y > 0:
		ans = max(ans, int(x + y))
	print(ans)


l = int(input())
for i in range(l):
	st = input().split()
	x = int(st[0])
	y = int(st[1])
	if x <= y:
		temp = x
		x = y
		y = temp
	if x >= 2 * y:
		print(y)
		continue
	if y + 2 < x < 2 * y:
		t = int((y - x % y + 2) / 3)
		print(y - t)
		continue
	if x >= y:
		z = int(y / 3)
		z *= 2
		if y % 3 == 0:
			print(z)
		elif y % 3 == 1:
			if x - y >= 1:
				print(z + 1)
			else:
				print(z)
		elif x - y >= 2:
			print(z + 2)
		else:
			print(z + 1)


t = int(input())
for i in range(t):
	(a, b) = [int(x) for x in input().split()]
	(a, b) = (min(a, b), max(a, b))
	if 2 * a <= b:
		print(a)
	elif 2 * a >= b:
		print((a + b) // 3)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if a >= b * 2:
		print(b)
	elif b >= a * 2:
		print(a)
	else:
		aa = max(a, b)
		bb = min(a, b)
		c = aa // 2
		aa = aa % 2
		bb -= c
		if aa == 1 and bb > 1:
			c += 1
			bb -= 2
		c += bb // 3
		print(c)


import math
import collections
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect_left as bsl
from bisect import bisect_right as bsr
import heapq as hq
setrecursionlimit(2 ** 20)
t = 1
t = int(stdin.readline())
for _ in range(t):
	(a, b) = list(map(int, stdin.readline().rstrip().split()))
	print(min(a, b, (a + b) // 3))


a = int(input())
for i in range(a):
	(b, c) = map(int, input().split())
	s = min(max(b, c) - min(b, c), min(b, c))
	e = min(b, c) - s
	f = max(b, c) - s * 2
	d = min(e, f) // 3
	s += d * 2
	e = e - d * 3
	f = f - d * 3
	while not (e == 0 or f == 0):
		if e > 0 and f > 1 or (e > 1 and f > 0):
			if f >= e:
				e -= 1
				f -= 2
				s += 1
			else:
				e -= 2
				f -= 1
				s += 1
		else:
			break
	print(s)


y = int(input())
ans = []
for i in range(y):
	al = input().split()
	m = list(map(int, al))
	a = min(m[0], m[1])
	b = max(m[0], m[1])
	d = int((b + a) / 3)
	t = 0
	t = min(d, a, b)
	ans.append(t)
for i in ans:
	print(i)


for t in range(int(input())):
	(a, b) = (int(X) for X in input().split())
	(small, big) = (min(a, b), max(a, b))
	if big >= 2 * small:
		print(small)
	elif (2 * small - big) % 3 != 2:
		print((2 * small - big) // 3 * 2 + big - small)
	else:
		print((2 * small - big) // 3 * 2 + big - small + 1)


for testcase in range(int(input())):
	(sticks, diamonds) = map(int, input().split())
	(M, m) = (max(sticks, diamonds), min(sticks, diamonds))
	diff = M - m
	if diff >= m:
		print(m)
	else:
		e = diff
		m -= diff
		M -= 2 * diff
		remain = M // 3
		e += 2 * remain
		if M % 3 == 2:
			e += 1
		print(e)


for i in range(int(input())):
	count = 0
	(stick, diamond) = map(int, input().split())
	if stick >= diamond * 2:
		print(diamond)
	elif diamond >= stick * 2:
		print(stick)
	else:
		print((stick + diamond) // 3)


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


for _ in range(int(input())):
	c = 0
	flag = 0
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
		continue
	s = a + b
	print(min(a, b, s // 3))


import math
from decimal import *
getcontext().prec = 30
t = int(input())

def fn(i):
	if i % 3 == 0:
		return i * 2 // 3
	return 2 * (i // 3) + i % 3 - 1
while t:
	t -= 1
	(x, y) = map(int, input().split())
	if x > y:
		(x, y) = (y, x)
	if y >= 2 * x:
		print(x)
	elif y == x:
		print(fn(x))
	else:
		print(y - x + fn(2 * x - y))


def smith_game(s, d):
	count = 0
	first_layer = min(s, d)
	extras = max(s, d) - first_layer
	if extras >= first_layer:
		return first_layer
	else:
		count += extras
		first_layer -= extras
	if first_layer % 3 == 0 or first_layer % 3 == 1:
		count += first_layer // 3 * 2
	else:
		count += first_layer // 3 * 2 + 1
	return count
t = int(input())
for i in range(t):
	(s, d) = map(int, input().split())
	print(smith_game(s, d))


def solve(a, b):
	if a < b:
		(a, b) = (b, a)
	x = min(a // 2, b)
	a -= 2 * x
	b -= x
	e = x
	y = min(a, b // 2)
	a -= y
	b -= 2 * y
	e += y
	if b <= 1:
		return e
	else:
		z = b // 3
		e += z
		return e
input()
while True:
	try:
		val = input().split(' ')
		for i in range(len(val)):
			val[i] = int(val[i])
		print(solve(val[0], val[1]))
	except EOFError:
		break


t = int(input())
while t > 0:
	t -= 1
	(s, d) = [int(x) for x in input().split()]
	print(min(s, d, (s + d) // 3))


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


n = int(input())
while n:
	(a, b) = map(int, input().split())
	ans = min(a, b, (a + b) // 3)
	print(ans)
	n = n - 1


t = int(input())

def _check_response(a, b):
	(a, b) = (max(a, b), min(a, b))
	diff = a - b
	c = min(b, diff)
	a -= 2 * c
	b -= c
	c += 2 * (b // 3)
	b1 = b % 3
	a -= 3 * (b // 3)
	if a == 0 or b1 == 0:
		return c
	if a == 1 and b1 == 1:
		return c
	if a >= 2 and b1 == 1:
		return c + 1
	if b1 == 2 and a >= 1:
		return c + 1
for _ in range(t):
	(a, b) = tuple(map(int, input().split()))
	c = _check_response(a, b)
	print(c)


def solve(a_sticks, b_diamonds):
	return min(a_sticks, b_diamonds, (a_sticks + b_diamonds) // 3)

def main():
	T = int(input())
	for _ in range(T):
		(a, b) = list(map(int, input().split()))
		ans = solve(a, b)
		print(ans)
main()


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


t = int(input())
for k in range(t):
	(s, d) = list(map(int, input().split(' ')))
	c = 0
	while 1:
		if s == 0 or d == 0:
			break
		if s // d >= 2 or d // s >= 2:
			c += min(s, d)
			break
		if s == d:
			x = (s + d) // 3
			c += x
			break
		if s > d:
			y = s - d
			s -= 2 * y
			d -= y
			c += y
		if d > s:
			y = d - s
			d -= 2 * y
			s -= y
			c += y
	print(c)


t = int(input())
for i in range(t):
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	if a == 0 or b == 0:
		print(0)
	else:
		out_val = int(b - (2 * b - a) / 3)
		if out_val > a or out_val > b:
			out_val = min(a, b)
		print(out_val)


a = input()
a = int(a)
for i in range(0, a):
	tools = 0
	b = input()
	b = b.split(' ')
	b[0] = int(b[0])
	b[1] = int(b[1])
	stop = False
	if b[0] * 2 <= b[1]:
		print(b[0])
		stop = True
	elif b[1] * 2 <= b[0]:
		print(b[1])
		stop = True
	if not stop:
		if b[0] > b[1]:
			diff = b[0] - b[1]
			b[1] -= diff
			b[0] -= 2 * diff
			tools = diff + int(b[0] * (2 / 3))
		elif b[0] == b[1]:
			tools = int(b[0] * (2 / 3))
		elif b[1] > b[0]:
			diff = b[1] - b[0]
			b[0] -= diff
			b[1] -= 2 * diff
			tools = diff + int(b[0] * (2 / 3))
		print(tools)


def solve(a, b):
	if a > b:
		(a, b) = (b, a)
	if b >= 2 * a:
		return a
	else:
		import math
		temp = math.ceil((2 * b - a) / 3)
		res = temp + min(a - temp, b - 2 * temp)
		return res
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	res = solve(a, b)
	print(res)


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()


import sys
t = int(sys.stdin.readline())
while t:
	(a, b) = sorted(map(int, sys.stdin.readline().split()))
	count = 0
	if b // 2 >= a:
		print(a)
	else:
		diff = b - a
		count += diff
		a -= diff
		b -= 2 * diff
		(quo, rem) = divmod(b, 3)
		if rem == 2:
			count += 2 * quo + 1
		else:
			count += 2 * quo
		print(count)
	t -= 1


t = int(input())
while t:
	t -= 1
	(c, m) = map(int, input().split())
	mn = min(c, m)
	mx = max(c, m)
	if mx >= 2 * mn:
		print(mn)
	else:
		dif = mx - mn
		ans = dif
		mx -= 2 * dif
		mn -= dif
		print(ans + 2 * mn // 3)


q = int(input())
while q:
	q = q - 1
	(a, b) = map(int, input().split())
	res = 10 ** 18
	if a < res:
		res = a
	if b < res:
		res = b
	if (a + b) // 3 < res:
		res = (a + b) // 3
	print(res)


import math
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	result = min((n + m) // 3, n, m)
	print(result)


testing_mode = True
import sys, traceback
test_data = ''
final_output = ''

def input(input_format=0, multi=0):
	if multi > 0:
		return [input(input_format) for x in range(multi)]
	else:
		next_line = next(test_data, None).strip() if test_data else sys.stdin.readline()
		if input_format == 0:
			formatted_input = [next_line]
		elif input_format == 1:
			formatted_input = list(map(int, next_line.split()))
		elif input_format == 2:
			formatted_input = list(map(float, next_line.split()))
		elif input_format == 3:
			formatted_input = next_line.split()
		elif input_format == 4:
			formatted_input = (lambda x: [x[0], list(map(int, x[1:]))])(next_line.split())
		elif input_format == 5:
			formatted_input = (lambda x: [x[0], list(map(float, x[1:]))])(next_line.split())
		else:
			formatted_input = [next_line]
		return formatted_input

def log(*args):
	if testing_mode:
		print(*args)

def out(output_line, output_format=0, newline=True):
	global final_output
	formatted_output = ''
	if output_format == 0:
		formatted_output = str(output_line)
	elif output_format == 1:
		formatted_output = ' '.join(map(str, output_line))
	elif output_format == 1:
		formatted_output = '\n'.join(map(str, output_line))
	if testing_mode:
		final_output += formatted_output + '\n' * newline
	else:
		print(formatted_output, end='\n' if newline else '')
test_inputs = ['\n4\n4 4\n1000000000 0\n7 15\n8 7\n\n', '\n$$$\n', '\n$$$\n', '\n$$$\n']
test_outputs = ['\n2\n0\n7\n5\n\n', '\n$$$\n', '\n$$$\n', '\n$$$\n']

def solve():
	for z in range(input(1)[0]):
		(a, b) = input(1)
		x = max(a, b)
		y = min(a, b)
		if x > 2 * y:
			x = 2 * y
		k = (x + y) // 3
		out(k)
	return

def run_all(overwrite_testing=False):
	global testing_mode, final_output, test_data
	testing_mode = overwrite_testing and testing_mode
	if testing_mode:
		tests_failed = 0
		for (test_number, (test_in, test_out)) in enumerate(zip(test_inputs, test_outputs)):
			final_output = ''
			if test_in.lstrip()[:3] == '$$$':
				continue
			test_data = iter([i for i in test_in.split('\n') if i])
			print(f'Test Case #{test_number + 1}:')
			print('<' * 20)
			fail = False
			verdict = '\x1b[92m\x1b[1mPASS\x1b[0m'
			try:
				solve()
				final = final_output.rstrip('\n')
				raw_out = iter(map(str, final.split('\n'))) if final else iter(())
			except Exception:
				raw_out = ''
				fail = True
				print('\x1b[95m')
				traceback.print_exc()
				print('\x1b[0m')
			if raw_out:
				if test_out.lstrip()[:3] == '$$$':
					verdict = '\x1b[94m\x1b[1mSKIP\x1b[0m'
					print('\x1b[94m' + '\n'.join(list(raw_out)) + '\x1b[0m')
				else:
					for line_out in [i for i in test_out.split('\n') if i]:
						line_raw = next(raw_out, '% None %')
						if line_raw == line_out.strip():
							print(f'\x1b[92m{line_raw}\x1b[0m')
						else:
							print(f'\x1b[91m{line_raw}\x1b[0m')
							fail = True
					line_raw = next(raw_out, None)
					while line_raw:
						print(f'\x1b[91m{line_raw}\x1b[0m')
						line_raw = next(raw_out, None)
						fail = True
			print('>' * 20)
			if fail:
				verdict = '\x1b[91m\x1b[1mFAIL\x1b[0m'
				tests_failed += 1
			print(verdict + '\n')
		if tests_failed:
			print(f"\x1b[91m\x1b[1m{tests_failed} TEST{('S' if tests_failed > 1 else '')} FAILED!\x1b[0m")
		else:
			print(f'\x1b[92m\x1b[1mALL TESTS PASSED!\x1b[0m')
	else:
		test_data = False
		solve()
run_all(False)


import sys
input = sys.stdin.readline
x = int(input())
for i in range(x):
	(a, b) = list(map(int, input().split()))
	(a, b) = (max(a, b), min(a, b))
	z = a - b
	if z >= b:
		ans = b
		print(ans)
	else:
		ans = z
		a = a - 2 * z
		b = b - z
		ans += b // 3 * 2
		a -= b // 3 * 3
		b -= b // 3 * 3
		(a, b) = (max(a, b), min(a, b))
		if a > 1 and b > 0:
			ans += 1
		print(ans)


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


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


t = int(input())
while t > 0:
	(a, b) = map(int, input().split())
	if a >= b:
		print(min((a + b) // 3, b))
	else:
		print(min((a + b) // 3, a))
	t = t - 1


from sys import stdin
input = stdin.readline

def main():
	test = int(input())
	for _ in range(test):
		(a, b) = [int(i) for i in input().split(' ')]
		print(min(a, b, (a + b) // 3))
main()


from math import floor
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
		continue
	x = (2 * a - b) / 3
	y = (2 * b - a) / 3
	print(min(a, b, floor(x + y)))


import sys, io, os, time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect, math, heapq
alphabet = 'abcdefghijklmnopqrstuvwxyz'
input = sys.stdin.readline
for ii in range(int(input())):
	(a, b) = map(int, input().split())
	print(min(a, b, (a + b) // 3))


t = int(input())
while t > 0:
	(a, b) = [int(c) for c in input().split()]
	emerald = 0
	if a == 0 or b == 0:
		emerald = 0
	elif a >= 2 * b:
		emerald = b
	elif b >= 2 * a:
		emerald = a
	elif a > b:
		emerald += a - b
		a = 2 * b - a
		if a % 3 == 0 or a % 3 == 1:
			emerald += 2 * (a // 3)
		else:
			emerald += 2 * (a // 3) + 1
	else:
		emerald += b - a
		b = 2 * a - b
		if b % 3 == 0 or b % 3 == 1:
			emerald += 2 * (b // 3)
		else:
			emerald += 2 * (b // 3) + 1
	print(emerald)
	t -= 1


import getopt
import sys
import math
onlyCase = -1
verbose = False
try:
	(opts, args) = getopt.getopt(sys.argv[1:], 'vc:', ['case='])
except getopt.GetoptError as err:
	print(str(err))
	sys.exit(2)
for (o, a) in opts:
	if o in ('-c', '--case'):
		onlyCase = int(a)
	elif o == '-v':
		verbose = True
	else:
		sys.exit()
ncases = int(input())
for c in range(1, ncases + 1):
	(A, B) = [int(x) for x in input().split()]
	if onlyCase != -1 and onlyCase != c:
		continue
	if verbose:
		print('A= %d B=%d' % (A, B))
	if A < B:
		(A, B) = (B, A)
	x1 = min((2 * A - B) // 3, B)
	A = A - 2 * x1
	B = B - x1
	x2 = min(A, B // 2)
	if verbose:
		print('x1= %d x2=%d' % (x1, x2))
	print('%d' % (x1 + x2))


def solve(a, b):
	if a == 0 or b == 0:
		print(0)
		return
	if a < b:
		if b >= 2 * a:
			print(a)
			return
		else:
			diff = 2 * a - b
			sub = diff // 3
			if diff % 3 == 0:
				sub -= 1
			sub += 1
			print(a - sub)
	elif a >= 2 * b:
		print(b)
		return
	else:
		diff = 2 * b - a
		sub = diff // 3
		if diff % 3 == 0:
			sub -= 1
		sub += 1
		print(b - sub)
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	solve(a, b)


import math

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


import sys
max_int = 1000000001
min_int = -max_int
t = int(sys.stdin.readline())
for _ in range(t):
	(a, b) = map(int, sys.stdin.readline().split())
	if a > b:
		(a, b) = (b, a)
	diff = b - a
	if diff > a:
		print(a)
	else:
		ans = diff
		a -= diff
		print(diff + 2 * a // 3)


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


import math
from collections import defaultdict

def r():
	return int(input())

def rm():
	return map(int, input().split())

def rl():
	return list(map(int, input().split()))
for _ in range(r()):
	(a, b) = rm()
	(a, b) = (min(a, b), max(a, b))
	if b >= a * 2:
		print(a)
	else:
		print(a - (a * 2 - b + 2) // 3)


import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def main():
	for _ in range(II()):
		(a, b) = MI()
		ans = min((a + b) // 3, a, b)
		print(ans)
main()


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


W = int(input())
for i in range(W):
	X = input()
	for E in range(len(X)):
		u = X[E]
		if u == ' ':
			a = int(X[0:E])
			b = int(X[E + 1:-1] + X[-1])
	if a > b:
		if b >= (a + b) / 3:
			print((a + b) // 3)
		else:
			print(b)
	elif a >= (a + b) / 3:
		print((a + b) // 3)
	else:
		print(a)


for ii in range(int(input())):
	(a, b) = map(int, input().split())
	c = 0
	if a == 0 or b == 0:
		pass
	else:
		c = (a + b) // 3
	if c > b:
		c = b
	elif c > a:
		c = a
	print(c)


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


def cal(x, y, now):
	y -= 2 * now
	x -= now
	return now + min(x // 2, y)
t = int(input())
for o in range(t):
	s = input().split()
	(n, m) = (int(s[0]), int(s[1]))
	if n > m:
		(n, m) = (m, n)
	(l, r) = (0, min(n, m // 2))
	while r - l > 10:
		m1 = l + r >> 1
		m2 = m1 + r >> 1
		if cal(n, m, m1) > cal(n, m, m2):
			r = m2
		else:
			l = m1
	ans = 0
	for i in range(l, r + 1):
		ans = max(ans, cal(n, m, i))
	print(int(ans))


import math
import sys
from itertools import permutations
from collections import defaultdict
input = sys.stdin.readline
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	x = min(a, b)
	y = max(a, b)
	minn = min(x, y)
	print(min((x + y) // 3, minn))


def main():
	(n, m) = map(int, input().split())
	mx = max(n, m)
	mn = min(m, n)
	if mx == 0 or mn == 0:
		print(0)
	elif 2 * mn <= mx:
		print(mn)
	else:
		ans = mx + mn
		ans = ans // 3
		print(ans)
	return

def test():
	t = int(input())
	while t:
		main()
		t -= 1
test()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	p = max(n, m)
	q = min(n, m)
	if n == 0 or m == 0:
		print(0)
		continue
	if p >= q * 2:
		print(q)
		continue
	else:
		print(min(min(p, q), (q + p) // 3))


t = int(input())
TestCases = []
for test in range(0, t):
	entry = input().split(' ')
	entry[0] = int(entry[0])
	entry[1] = int(entry[1])
	TestCases.append(entry[:2])
for test in TestCases:
	Emerland = 0
	if 0 in test or sum(test) < 3:
		print(0)
		continue
	elif sum(test) < 6 or 1 in test:
		print(1)
		continue
	elif 2 in test:
		print(2)
		continue
	else:
		if test[0] < test[1]:
			(test[0], test[1]) = (test[1], test[0])
		if test[0] >= 2 * test[1]:
			Emerland = test[1]
		else:
			Emerland = Emerland + int(test[0] / 3) + int(test[1] / 3)
			test[0] = test[0] % 3
			test[1] = test[1] % 3
			if (test[0] != 0 and test[1] != 0) and test[0] + test[1] >= 3:
				Emerland = Emerland + 1
		print(Emerland)


n = int(input())
for _ in range(n):
	c = 0
	(x, y) = list(map(int, input().split()))
	(x, y) = (max(x, y), min(x, y))
	if x != 0 and y != 0:
		if x >= 2 * y:
			print(y)
		else:
			print((x + y) // 3)
	else:
		print(0)


def inp():
	return map(int, input().split())
for _ in range(int(input())):
	(a, b) = inp()
	(a, b) = (min(a, b), max(a, b))
	if a * 2 < b:
		print(a)
		continue
	x = b // 2
	a -= x
	b = b % 2
	y = 0
	if b == 1 and a > 1:
		y += 1
		b -= 1
		a -= 2
	res = x + y + min(x, a // 3)
	print(res)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().strip().split(' '))
	if a == 0 or b == 0:
		print(0)
	elif a >= 2 * b or b >= 2 * a:
		print(min(a, b))
	else:
		if a > b:
			m1 = a
			m2 = b
		else:
			m1 = b
			m2 = a
		k = m1 - m2
		m = m1 - 2 * k
		if m % 3 == 0 or m % 3 == 1:
			m = k + m // 3 * 2
			print(m)
		else:
			m = k + m // 3 * 2 + 1
			print(m)


def solve():
	(a, b) = map(int, input().split())
	ans = max(min(a // 2, b), min(a, b // 2))
	w = (2 * a - b) // 3
	for u in range(max(0, w - 10), w + 10):
		v = min(a - 2 * u, (b - u) // 2)
		if v >= 0:
			ans = max(ans, u + v)
	print(ans)
t = int(input())
for _ in range(t):
	solve()


t = int(input())
for _ in range(t):
	(a, b) = list(map(int, input().split()))
	counter = 0
	if a > b:
		r = a
		a = b
		b = r
	if a * 2 <= b:
		print(a)
	else:
		print((a + b) // 3)


def problem1():
	(a, b) = list(map(int, input().split()))
	if b > a:
		b = b + a
		a = b - a
		b = b - a
	if a * b < 2:
		print(0)
	elif a >= 2 * b:
		print(b)
	else:
		print(a - b + 2 * (2 * b - a) // 3)
cases = int(input())
for _ in range(cases):
	problem1()


a = int(input())
for i in range(0, a):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	i = max(x, y)
	j = min(x, y)
	t = 0
	if j >= i // 2:
		t = t + (i + j) // 3
	else:
		t = j
	print(t)


def main():
	(a, b) = map(int, input().split())
	c = min(a, b)
	b = max(a, b)
	a = c
	dif = b - a
	if a <= dif:
		print(a)
		return
	cnt = dif
	left = a - dif
	cnt += left // 3 * 2
	if left % 3 == 2:
		cnt += 1
	print(cnt)
t = int(input())
for i in range(t):
	main()


t = int(input())
for k in range(t):
	n = input()
	n = n.split()
	a = int(n[0])
	b = int(n[1])
	if b < a:
		t = a
		a = b
		b = t
	if a == 0:
		print('0')
	elif b / a >= 2:
		print(a)
	else:
		c = int((a + b) / 3)
		print(c)


import sys

def arr():
	return list(map(int, input().split()))
input = sys.stdin.readline
from collections import defaultdict
import math
for _ in range(int(input())):
	(A, B) = map(int, input().split())
	print(min((A + B) // 3, min(A, B)))


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


t = int(input())
while t > 0:
	(dia, sti) = map(int, input().split())
	c = 0
	if dia * 2 <= sti or sti * 2 <= dia:
		c = min(dia, sti)
	elif dia > 1 and sti > 0 or (dia > 0 and sti > 1):
		c = (dia + sti) // 3
	print(c)
	t -= 1


t = int(input())
while t != 0:
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
	else:
		c = (a + b) / 3
		v = min(a, b)
		if v > c:
			print(int(c))
		else:
			print(v)
	t = t - 1


t = int(input())
for i in range(t):
	(graveto, diamante) = list(map(int, input().split()))
	if graveto == 0 or diamante == 0:
		print(0)
	elif graveto >= diamante * 2:
		print(diamante)
	elif diamante >= graveto * 2:
		print(graveto)
	else:
		cont = graveto + diamante
		cont /= 3
		print(int(cont))


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
		continue
	resu = 0
	while a > 0 and b > 0:
		(a, b) = (max(a, b), min(a, b))
		c = abs(a - b)
		s = c // 2
		if s == 0 and a != b:
			resu += 1
			a -= 2
			b -= 1
			continue
		resu += min(s, b)
		a -= min(s * 2, b * 2)
		b -= min(s, b)
		if a == b:
			x = a // 3
			a -= x * 3
			if a == 2:
				resu += 1
			resu += x * 2
			break
	print(resu)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	if y > x:
		c = x
		x = y
		y = c
	if x >= 2 * y:
		ans = y
	else:
		ans = (x + y) // 3
	print(ans)


t = int(input())
for i in range(t):
	line = list(map(int, input().rstrip().split()))
	a = line[0]
	b = line[1]
	print(min(a, b, (a + b) // 3))


import os
import sys
from io import BytesIO, IOBase
profile = 0
pypy = 1

def iin():
	return int(input())

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

def main():
	T = iin()
	for _ in range(T):
		(a, b) = lin()
		if a > b:
			(a, b) = (b, a)
		x1 = min(b - a, b // 2, a)
		ans = x1
		a -= x1
		b -= x1 * 2
		x2 = min(a // 3, b // 3)
		ans += x2 * 2
		a -= x2 * 3
		b -= x2 * 3
		if a > b:
			(a, b) = (b, a)
		x3 = min(b // 2, a)
		ans += x3
		a -= x3
		b -= x3 * 2
		ans += min(a // 2, b)
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if pypy:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
if profile:
	import cProfile
	cProfile.run('main()')
else:
	main()


t = int(input())
count = 0
result = []
for i in range(t):
	(s, d) = [int(i) for i in input().split()]
	if 2 * s < d:
		print(s)
	elif 2 * d < s:
		print(d)
	else:
		print((s + d) // 3)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	total = 0
	if a > b:
		(a, b) = (b, a)
	q = min(a, b - a)
	total += q
	a -= q
	print(total + 2 * (a // 3) + (a % 3 == 2))


import math
t = int(input())
for i in range(t):
	project = 0
	diff = 0
	(s, d) = list(map(int, input().split()))
	if s == 0 or d == 0:
		print(project)
	else:
		print(min(math.floor((s + d) / 3), s, d))


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def fi():
	return float(input())

def si():
	return input()

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

def li():
	return list(mi())

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
mod = 1000000007
from math import *
import bisect
from decimal import *
getcontext().prec = 25
abc = 'abcdefghijklmnopqrstuvwxyz'

def fn(n):
	c = 0
	while n % 2 == 0:
		c += 1
		n //= 2
	return c
pi = 3.141592653589793

def main():
	for _ in range(ii()):
		(a, b) = mi()
		ans = (a + b) // 3
		ans = min(ans, a, b)
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if b > a:
		(a, b) = (b, a)
	dif = a - b
	count = min(b, dif)
	b -= count
	a -= count * 2
	if b > 0:
		x = (a + b) // 3
		print(count + x)
	else:
		print(count)


n = int(input())
for i in range(n):
	(x, y) = [int(x) for x in input().split()]
	z = (x + y) // 3
	ans = min(x, y, z)
	print(ans)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	cnt = 0
	if a > b:
		d = a - b
		d = min(d, b)
		a -= 2 * d
		b -= d
		cnt += d
	if a < b:
		d = b - a
		d = min(d, a)
		a -= d
		b -= 2 * d
		cnt += d
	a1 = a // 3
	a2 = b // 3
	a -= min(a1, a2) * 3
	b -= min(a1, a2) * 3
	cnt += min(a1, a2) * 2
	if a == 1 and b == 2:
		cnt += 1
	elif a == 2 and b == 1:
		cnt += 1
	elif a == 3 and b == 1:
		cnt += 1
	elif a == 1 and b == 3:
		cnt += 1
	elif a == 2 and b == 3:
		cnt += 1
	elif a == 3 and b == 2:
		cnt += 1
	elif a == 2 and b == 2:
		cnt += 1
	print(cnt)


t = int(input())
for k in range(t):
	num = [int(i) for i in input().split(' ')]
	res = min(num[0], num[1], (num[0] + num[1]) // 3)
	print(res)


import sys
input = lambda : sys.stdin.readline().rstrip()
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if a < b:
		(a, b) = (b, a)
	if a - b <= b:
		ans = a - b
		ans += 2 * ((2 * b - a) // 3)
		if (2 * b - a) % 3 == 2:
			ans += 1
		print(ans)
	else:
		print(b)


import sys
from collections import defaultdict as dd
from queue import Queue
import math
import itertools
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = lambda : sys.stdin.buffer.readline().rstrip()
for i in range(int(input())):
	(a, b) = map(int, input().split())
	q = max(a, b)
	w = min(a, b)
	if w == 0:
		print(0)
	elif q // w >= 2:
		print(w)
	else:
		print((q + w) // 3)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	count = 0
	if a == 0 or b == 0:
		print(0)
	else:
		x = min(a, b)
		y = max(a, b)
		diff = y - x
		if diff >= x:
			print(x)
		else:
			x -= diff
			y -= 2 * diff
			tot = 2 * (x // 3) + 1 if x % 3 == 2 else 2 * x // 3
			print(tot + diff)


from sys import stdin, gettrace
if gettrace():
	inputi = input
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()

def main():

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


t = int(input())
while t:
	(a, b) = map(int, input().split())
	c = max(a, b)
	d = min(a, b)
	if c >= 2 * d:
		print(d)
	else:
		ans = 0
		while c > d:
			ans += c - d
			c = c - 2 * ans
			d = d - ans
		if c >= 3:
			h = c // 3
			d -= h * 3
			c -= h * 3
			ans += 2 * h
		if c == 2 and d >= 4:
			ans += 2
		if d < 4 and d > 1 and (c > 0):
			ans += 1
		print(ans)
	t -= 1


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a < b:
		(a, b) = (b, a)
	t = min(a // 2, b)
	em = t
	a -= t * 2
	b -= t
	new = max(0, (b - 2 * a) // 3)
	em -= new
	b += new
	a += 2 * new
	if a < b:
		(a, b) = (b, a)
	t = min(a // 2, b)
	em += t
	a -= t * 2
	b -= t
	print(em)


import sys
import heapq
t = int(input())
for _ in range(t):
	(a, b) = map(int, sys.stdin.readline().split())
	em = 0
	if a > b:
		(a, b) = (b, a)
	if 2 * a <= b:
		print(a)
		continue
	div = (2 * a - b) // 3
	em = div * 2
	a -= div * 3
	b -= div * 3
	if a >= 1:
		em += b // 2
	print(em)


T = int(input())
for isc in range(T):
	(m, n) = map(int, input().split())
	if m >= 2 * n or n >= 2 * m:
		print(min(m, n))
		continue
	t = abs(m - n)
	print(t + 2 * ((min(m, n) - t) // 3) + (min(m, n) - t) % 3 // 2)


from math import *
from sys import stdin, stdout
input = stdin.buffer.readline
t = int(input())
while t > 0:
	ans = 0
	(a, b) = [int(x) for x in input().split()]
	if b < a:
		(a, b) = (b, a)
	if b >= 2 * a:
		ans += a
	else:
		dist = b - a
		if dist > 2:
			dist -= 2
			ans += dist
			a = a - dist
			b = b - dist
		x = a
		ans += x // 3 * 2
		sub = x // 3 * 3
		a -= sub
		b -= sub
		if a == 1 and b > 1:
			ans += 1
		elif a == 2 and b < 4:
			ans += 1
		elif a == 2 and b >= 4:
			ans += 2
	print(ans)
	t -= 1


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
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 i in range(0, t):
	(a, b) = list(map(int, input().split()))
	v = int(min(a, b, (a + b) / 3))
	print(v)


from bisect import *
from collections import *
from math import gcd, ceil, sqrt, floor, inf
from heapq import *
from itertools import *
from operator import add, mul, sub, xor, truediv, floordiv
from functools import *
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
farr = [1]
ifa = []

def fact(x, mod=0):
	if mod:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr) % mod)
	else:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr))
	return farr[x]

def ifact(x, mod):
	global ifa
	ifa.append(pow(farr[-1], mod - 2, mod))
	for i in range(x, 0, -1):
		ifa.append(ifa[-1] * i % mod)
	ifa = ifa[::-1]

def per(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return fact(i) // fact(i - j)
	return farr[i] * ifa[i - j] % mod

def com(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return per(i, j) // fact(j)
	return per(i, j, mod) * ifa[j] % mod

def catalan(n):
	return com(2 * n, n) // (n + 1)

def linc(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t > f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rinc(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t < f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def ldec(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t < f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rdec(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t > f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def binfun(x):
	c = 0
	for w in arr:
		c += ceil(w / x)
	return c

def lowbit(n):
	return n & -n

def inverse(a, m):
	a %= m
	if a <= 1:
		return a
	return (1 - inverse(m, a) * m) // a % m

class BIT:

	def __init__(self, arr):
		self.arr = arr
		self.n = len(arr) - 1

	def update(self, x, v):
		while x <= self.n:
			self.arr[x] += v
			x += x & -x

	def query(self, x):
		ans = 0
		while x:
			ans += self.arr[x]
			x &= x - 1
		return ans

class DSU:

	def __init__(self, n):
		self.c = [-1] * n

	def same(self, x, y):
		return self.find(x) == self.find(y)

	def find(self, x):
		if self.c[x] < 0:
			return x
		self.c[x] = self.find(self.c[x])
		return self.c[x]

	def union(self, u, v):
		(u, v) = (self.find(u), self.find(v))
		if u == v:
			return False
		if self.c[u] < self.c[v]:
			(u, v) = (v, u)
		self.c[u] += self.c[v]
		self.c[v] = u
		return True

	def size(self, x):
		return -self.c[self.find(x)]

class UFS:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.ranks = [0] * n

	def find(self, x):
		if x != self.parent[x]:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, u, v):
		(pu, pv) = (self.find(u), self.find(v))
		if pu == pv:
			return False
		if self.ranks[pu] >= self.ranks[pv]:
			self.parent[pv] = pu
			if self.ranks[pv] == self.ranks[pu]:
				self.ranks[pu] += 1
		else:
			self.parent[pu] = pv

def Prime(n):
	c = 0
	prime = []
	flag = [0] * (n + 1)
	for i in range(2, n + 1):
		if not flag[i]:
			prime.append(i)
			c += 1
		for j in range(c):
			if i * prime[j] > n:
				break
			flag[i * prime[j]] = prime[j]
			if i % prime[j] == 0:
				break
	return prime

def dij(s, graph):
	d = {}
	d[s] = 0
	heap = [(0, s)]
	seen = set()
	while heap:
		(dis, u) = heappop(heap)
		if u in seen:
			continue
		for v in graph[u]:
			if v not in d or d[v] > d[u] + graph[u][v]:
				d[v] = d[u] + graph[u][v]
				heappush(heap, (d[v], v))
	return d

def GP(it):
	return [[ch, len(list(g))] for (ch, g) in groupby(it)]

class DLN:

	def __init__(self, val):
		self.val = val
		self.pre = None
		self.next = None
t = N()
for i in range(t):
	(a, b) = RL()
	ans = min(a, b, (a + b) // 3)
	print(ans)


for t in range(int(input())):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	if a == 0 or b == 0:
		print('0')
	else:
		print(min(a, b, (a + b) // 3))


from sys import *
from math import *
from collections import *
mod = 1000000007

def get_array():
	return list(map(int, stdin.readline().split()))

def get_ints():
	return map(int, stdin.readline().split())

def get_int():
	return int(stdin.readline())

def get_input():
	return stdin.readline().strip()

def main():
	tc = get_int()
	while tc:
		(A, B) = get_ints()
		stdout.write(str(min(A, B, (A + B) // 3)) + '\n')
		tc -= 1
main()


import collections
tests = int(input())
for _ in range(tests):
	arr = [int(a) for a in input().strip().split(' ')]
	a = arr[0]
	b = arr[1]
	n = min(a, b)
	sum = min(n, max(a, b) - n)
	n = n - sum
	sum += 2 * (n // 3)
	n = n % 3
	if n < 2:
		print(sum)
		continue
	elif n == 2:
		print(sum + 1)
		continue


for _ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	if x == 0 or y == 0:
		print(0)
	else:
		cou = 0
		if y > x:
			(y, x) = (x, y)
		p = x - y
		if x - 2 * p >= 0 and y - p >= 0:
			cou += p
			x -= 2 * p
			y -= p
			cou += x // 3 * 2
			x %= 3
			y %= 3
			if x == 2:
				cou += 1
			print(cou)
		else:
			print(y)


for _ in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	cnt = 0
	if a == 0 or b == 0:
		print(0)
	elif 2 * min(a, b) <= max(a, b):
		print(min(a, b))
	elif a == b:
		print(2 * a // 3)
	else:
		m = min(a, b) - (max(a, b) - min(a, b))
		print(max(a, b) - min(a, b) + 2 * m // 3)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	c = 0
	while a >= 1 and b > 1 or (a > 1 and b >= 1):
		if a == b:
			if a % 3 == 0 or a % 3 == 1:
				c += 2 * (a // 3)
			elif a % 3 == 2:
				c += 2 * (a // 3) + 1
			break
		elif a >= 2 * b or b >= 2 * a:
			c += min(a, b)
			break
		else:
			d = abs(a - b)
			c += d
			if a > b:
				a -= 2 * d
				b -= d
			else:
				a -= d
				b -= 2 * d
	print(c)


t = int(input())
while t > 0:
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	print(min((a + b) // 3, a, b))
	t -= 1


def emeralds(sticks, diamonds):
	if sticks * 2 <= diamonds:
		return sticks
	elif diamonds * 2 <= sticks:
		return diamonds
	else:
		return (sticks + diamonds) // 3

def main():
	t = int(input())
	a = 0
	while a < t:
		l = input().split()
		(sticks, diamonds) = (int(l[0]), int(l[1]))
		print(emeralds(sticks, diamonds))
		a = a + 1
main()


def solve():
	message = input().split()
	a = int(message[0])
	b = int(message[1])
	if a > 2 * b:
		print(b)
	elif b > 2 * a:
		print(a)
	else:
		print((a + b) // 3)
for _ in range(int(input())):
	solve()


import atexit
import io
import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	c = (a + b) // 3
	print(min(c, min(a, b)))


def solution():
	(a, b) = list(map(int, input().split()))
	mn = min(a, b)
	mx = max(a, b)
	gap = mx - mn
	count = 0
	if gap > mn:
		print(mn)
		return
	mn -= gap
	mx -= 2 * gap
	count += gap
	count += 2 * (mn // 3)
	if mn % 3 == 2:
		count += 1
	print(count)
T = int(input())
for t in range(T):
	solution()


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split(' '))
	if a * 2 <= b or b * 2 <= a:
		print(min(a, b))
	elif b >= a:
		x = b - a
		a -= x
		b -= x * 2
		y = min(a // 3, b // 3)
		a -= y * 3
		b -= y * 3
		if a == 2 or b == 2:
			print(x + y * 2 + 1)
		else:
			print(x + y * 2)
	elif a > b:
		(a, b) = (b, a)
		x = b - a
		a -= x
		b -= x * 2
		y = min(a // 3, b // 3)
		a -= y * 3
		b -= y * 3
		if a == 2 or b == 2:
			print(x + y * 2 + 1)
		else:
			print(x + y * 2)


import sys
for _ in range(int(sys.stdin.readline().rstrip())):
	(n, m) = list(map(int, sys.stdin.readline().rstrip().split()))
	(n, m) = (min(n, m), max(n, m))
	re = 0
	if m - n > 1:
		re += min(m - n, n)
		n -= re
		m -= re * 2
	cnt = int(min(n, m) / 3)
	re += cnt * 2
	n -= cnt * 3
	m -= cnt * 3
	re += min(n, int(m / 2))
	print(re)


def func(s, d):
	if s <= 0 or d <= 0:
		return 0
	if s >= d * 2 or d >= s * 2:
		return min(s, d)
	return (s + d) // 3
loops = int(input())
for _ in range(loops):
	(a, b) = [int(num) for num in input().split()]
	print(func(a, b))


t = int(input())
for i in range(t):
	sd = list(map(int, input().split()))
	s = sd[0]
	d = sd[1]
	res = 0
	if s == 0 or d == 0:
		print(res)
	elif d >= 2 * s:
		print(s)
	elif s >= 2 * d:
		print(d)
	else:
		print((s + d) // 3)


from sys import stdin

def iinput():
	return int(stdin.readline())

def sinput():
	return input()

def minput():
	return map(int, stdin.readline().split())

def linput():
	return list(map(int, stdin.readline().split()))
t = iinput()
while t:
	t -= 1
	(a, b) = minput()
	print(min(a, b, (a + b) // 3))


import math
t = int(input())

def equalans(a):
	ans = int(math.floor(a / 3)) * 2
	if a % 3 == 2:
		ans += 1
	return ans
for i in range(t):
	inp = input().split(' ')
	(a, b) = (int(inp[0]), int(inp[1]))
	if a == 0 or b == 0:
		print(0)
		continue
	if a == b:
		print(equalans(a))
		continue
	if b > a:
		t = a
		a = b
		b = t
	if a >= 2 * b:
		print(b)
		continue
	ex = a % b
	a -= 2 * ex
	b -= ex
	print(equalans(a) + ex)


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


def main():
	T = int(input())
	for _ in range(T):
		(a, b) = map(int, input().split())
		if a == 0 or b == 0:
			print(0)
			continue
		if max(a, b) - min(a, b) > min(a, b):
			print(min(a, b))
		else:
			steps = max(a, b) - min(a, b)
			N = min(a, b) - steps
			print(steps + N - (N + 2) // 3)
main()


from sys import stdin, stdout
t = int(stdin.readline())
for _ in range(t):
	(a, b) = map(int, stdin.readline().split())
	emerald = 0
	if a >= 2 * b:
		emerald = b
	elif b >= 2 * a:
		emerald = a
	else:
		x = abs(a - b)
		y = min(a, b) - x
		emerald = int(x + y / 3 * 2)
	stdout.write(str(emerald) + '\n')


for t in range(int(input())):
	(a, b) = map(int, input().split())
	if a < 2 and b < 2:
		print(0)
	elif a == 0 or b == 0:
		print(0)
	else:
		ans = 0
		if abs(a - b) >= min(a, b):
			ans += min(a, b)
			print(ans)
		else:
			if a == min(a, b) and a != b:
				ans += b - a
				a = a - (b - a)
				b = b - 2 * (b - a)
				while a >= 3:
					ans += 2 * (a // 3)
					a = a % 3
					b = a
				if a == 2:
					ans += 1
			elif b == min(a, b) and a != b:
				ans += a - b
				a = a - 2 * (a - b)
				b = b - (a - b)
				while a >= 3:
					ans += 2 * (a // 3)
					a = a % 3
					b = a
				if a == 2:
					ans += 1
			else:
				while a >= 3:
					ans += 2 * (a // 3)
					a = a % 3
					b = a
				if a == 2:
					ans += 1
			print(ans)


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


t = int(input())
for tc in range(t):
	(a, b) = map(int, input().split())
	gr = max(a, b)
	lr = min(a, b)
	if a != 0 and b != 0:
		if gr / lr <= 2:
			print((a + b) // 3)
		else:
			print(lr)
	else:
		print(0)


for x in range(int(input())):
	(h, m) = list(map(int, input().split()))
	(h, m) = (min(h, m), max(h, m))
	if h <= m // 2:
		print(h)
	else:
		k = (2 * h - m) // 3
		print(k + (m - k) // 2)


t = int(input())
for i in range(t):
	xd = input().split(' ')
	a = int(xd[0])
	b = int(xd[1])
	if a == b:
		respuesta = (a + b) // 3
	if b >= 2 * a:
		respuesta = a
	if a >= 2 * b:
		respuesta = b
	if 2 * b > a > b:
		respuesta = a - b + (4 * b - 2 * a) // 3
	if 2 * a > b > a:
		respuesta = b - a + (4 * a - 2 * b) // 3
	print(respuesta)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	(a, b) = (max(a, b), min(a, b))
	n = 0
	n = a - b
	b = b - n
	if b < 0:
		print(int(n + b))
	else:
		n += b // 1.5
		print(int(n))


from sys import stdin, stdout

def main():
	for t in range(int(stdin.readline())):
		(s, d) = map(int, stdin.readline().split())
		if s == 0 or d == 0:
			print(0)
		elif max(s, d) >= 2 * min(s, d):
			print(min(s, d))
		else:
			print(s + d - 2 * ((s + d) // 3) - (s + d) % 3)
main()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		tot = 0
	else:
		tot = (a + b) // 3
	if tot > a or tot > b:
		g = min(a, b)
		tot = g
	print(tot)


def func(s, d):
	if s > d:
		if s <= 2 * d:
			return s - d + func(2 * d - s, 2 * d - s)
		return d
	if d > s:
		return func(d, s)
	return s * 2 // 3
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	print(func(a, b))


for _ in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	if a > b:
		(a, b) = (b, a)
	if a == 0 or b == 0:
		print(0)
		continue
	if a == b and a == 1:
		print(0)
		continue
	if b >= 2 * a:
		print(a)
	else:
		print((a + b) // 3)


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	if 2 * a <= b:
		print(a)
		continue
	print((a + b) // 3)


import math

def solve(a, b):
	if max(a, b) - min(a, b) >= min(a, b):
		return min(a, b)
	else:
		return (a + b) // 3

def main():
	t = int(input())
	test_case_num = 1
	while test_case_num <= t:
		(a, b) = map(int, input().split())
		ans = solve(a, b)
		print(int(ans))
		test_case_num += 1
main()


import math
cases = int(input())
for i in range(cases):
	a = [int(p) for p in input().split()]
	a.sort()
	if a[0] * 2 < a[1]:
		print(a[0])
	else:
		print(math.floor((a[0] + a[1]) / 3))


import io
import os
from collections import Counter, defaultdict, deque

def solve(A, B):
	return min(3 * A, 3 * B, A + B) // 3
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input())
for t in range(T):
	(A, B) = [int(x) for x in input().split()]
	ans = solve(A, B)
	print(ans)


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))


t = int(input())
while t:
	t = t - 1
	(a, b) = map(int, input().split())
	ans = int((a + b) / 3)
	if a == 0 or b == 0:
		ans = 0
	elif ans > b:
		ans = b
	elif ans > a:
		ans = a
	print(ans)


import sys
import math
sys.setrecursionlimit(1000000)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')
p2S = lambda x: print(*x, sep=' ')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def main():
	_v_ = II()
	for _ in range(_v_):
		(a, b) = MI()
		ma = max(a, b)
		mb = min(a, b)
		if ma >= mb << 1:
			print(mb)
		else:
			x = (2 * a - b) / 3
			y = (2 * b - a) / 3
			print(int(x + y))
main()


def solve():
	(a, b) = map(int, input().split())
	k = a + b
	k //= 3
	z = min(a, b)
	print(min(z, k))
for i in range(int(input())):
	solve()


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


n = int(input())
while n:
	(a, b) = map(int, input().split())
	mn = min(a, b)
	mx = max(a, b)
	if 2 * mn <= mx:
		print(mn)
	else:
		print((a + b) // 3)
	n -= 1


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
import sys

def solve(a, b):
	if a >= b * 2:
		return b
	ans = a - b
	b -= ans
	c = b // 3
	ans += c * 2
	d = b % 3
	if d == 2:
		ans += 1
	return ans

def main():
	t = int(input())
	for _ in range(t):
		(a, b) = map(int, input().split())
		if a < b:
			(a, b) = (b, a)
		ans = solve(a, b)
		sys.stdout.write(str(ans) + '\n')
main()


from sys import stdin, stdout
import sys
from math import *
for __ in range(int(input())):
	(n, m) = map(int, input().split())
	if m >= n * 2:
		print(n)
	elif n >= m * 2:
		print(m)
	else:
		ans = 0
		if n > m:
			dif = n - m
			ans = dif
			n -= dif * 2
			m -= dif
		elif n < m:
			dif = m - n
			ans = dif
			m -= dif * 2
			n -= dif
		ans += n // 3 * 2
		if n % 3 == 2:
			ans += 1
		print(ans)


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


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


from sys import stdin, stdout
for cases in range(int(stdin.readline())):
	(a, b) = map(int, stdin.readline().split())
	ans = 0
	j = max(a, b)
	k = min(a, b)
	if a == 0 or b == 0:
		ans = 0
	elif j >= 2 * k:
		ans = k
	else:
		ans = (a + b) // 3
	print(ans)


t = int(input())
for _ in range(t):
	(a, b) = sorted(map(int, input().split()))
	x = b - a
	c = max(0, a - x)
	s = c // 3
	(a, b) = (a - 3 * s, b - 3 * s)
	s += min(a, b // 2) + s
	print(s)


def emerald(a, b):
	total = 0
	if a <= b:
		k = b - a
		t = (a - k) // 3
		if a == 0 or b == 0:
			total = 0
		elif a == 1 and b == 1:
			total = 0
		elif a - k > 0:
			if (a - k) % 3 == 2:
				total = k + (2 * t + 1)
			else:
				total = k + 2 * t
		else:
			total = a
		return total
	else:
		return emerald(b, a)
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	x = emerald(a, b)
	print(x)


for _ in range(int(input())):
	(x, y) = map(int, input('').split())
	if x == 0 or y == 0:
		print(0)
	elif x == y:
		print((x + y) // 3)
	elif 2 * min(x, y) < max(x, y):
		print(min(x, y))
	elif (x + y) // 3 <= min(x, y):
		print((x + y) // 3)
	else:
		count = 0
		if x > y:
			(x, y) = (y, x)
		while x != 0 and y >= 2:
			x -= 1
			y -= 2
			count += 1
		print(count)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(a, b) = sorted(map(int, input().split()))
	if b > 2 * a:
		b = 2 * a
	print((b + a) // 3)


n = int(input())
for i in range(n):
	(a, b) = [int(x) for x in input().split()]
	(a, b) = (min(a, b), max(a, b))
	if b > a * 2:
		ans = a
	else:
		ans = (a + b) // 3
	print(ans)


from __future__ import division, print_function
import os, sys
import math
import collections
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

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

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey, reverse=True)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(n - r))

def binary_search(arr, low, high, x):
	if high >= low:
		mid = (high + low) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] > x:
			return binary_search(arr, low, mid - 1, x)
		else:
			return binary_search(arr, mid + 1, high, x)
	else:
		return -1

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def padded_bin_with_complement(x):
	if x < 0:
		return bin(2 ** 16 - abs(x))[2:].zfill(16)
	else:
		return bin(x)[2:].zfill(16)

def binaryToDecimal(binary):
	binary1 = binary
	(decimal, i, n) = (0, 0, 0)
	while binary != 0:
		dec = binary % 10
		decimal = decimal + dec * pow(2, i)
		binary = binary // 10
		i += 1
	print(decimal)

def CountFrequency(arr):
	return collections.Counter(arr)

def pos(a):
	b = [0] * len(a)
	c = sorted(a)
	for i in range(len(a)):
		for j in range(len(a)):
			if c[j] == a[i]:
				b[i] = j
				break
	return b

def smallestDivisor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i * i <= n:
		if n % i == 0:
			return i
		i += 2
	return n

def commonn(a, b, n):
	c = []
	for i in range(n):
		if a[i] == b[i]:
			c.append('-1')
		else:
			c.append(b[i])
	return c

def main():
	for _ in range(ii()):
		(n, k) = mi()
		cou = min((n + k) // 3, n, k)
		print(cou)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import math
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print('0')
	elif a < 2 and b < 2:
		print('0')
	else:
		if a > b:
			maxi = a
			mini = b
		else:
			maxi = b
			mini = a
		if maxi >= 2 * mini:
			print(mini)
		else:
			ans = maxi - mini
			mini = mini - ans
			r = mini % 3
			ans += 2 * math.floor(mini / 3)
			if r == 2:
				print(int(ans + 1))
			else:
				print(int(ans))


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


t = int(input())
for i in range(t):
	(a, b) = map(int, input().strip().split())
	Min = min(a, b)
	Max = max(a, b)
	if Min * 2 <= Max:
		print(Min)
		continue
	ans = 0
	diff = Max - Min
	ans = diff
	Max = Max - diff * 2
	Min = Min - diff
	ans += Min // 3 * 2
	if Min % 3 == 2:
		print(ans + 1)
	else:
		print(ans)


for _ in range(int(input())):
	(A, B) = map(int, input().split())
	if A == 0 or B == 0:
		print(0)
	else:
		c = min((A + B) // 3, A, B)
		print(c)


import os
os_input = os.read(0, int(10000000.0)).split()
os_input_pos = -1
answer_list = []

def read_s():
	global os_input_pos
	os_input_pos += 1
	return os_input[os_input_pos].decode()

def read_i():
	return int(read_s())

def write_s(v):
	answer_list.append(v)

def write_i(v):
	write_s(str(v))

def print_ans():
	os.write(1, '\n'.join(answer_list).encode())
	os.write(1, '\n'.encode())
T = read_i()
while T:
	T -= 1
	a = read_i()
	b = read_i()
	write_i(min(a, b, (a + b) // 3))
print_ans()


def fun(x, y):
	a = 0
	b = 0
	if x > y:
		a = x
		b = y
	if x == y:
		a = x
		b = x
	if x < y:
		a = y
		b = x
	if a >= 2 * b:
		return b
	if a < 2 * b and a > b:
		return int((a + b) / 3)
	if a == b:
		if a % 3 == 1:
			return int((a + 2) * 2 / 3) - 2
		if a % 3 == 2:
			return int((a + 1) * 2 / 3) - 1
		if a % 3 == 0:
			return int(a * 2 / 3)
n = int(input())
lst = []
for _ in range(n):
	(x, y) = map(int, input().split())
	lst.append(fun(x, y))
for val in lst:
	print(val)


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


import math
T = int(input())
for i in range(T):
	(s, d) = map(int, input().split())
	cnt = 0
	if min(s, d) == 0:
		print(0)
	elif s == max(s, d):
		if s // d >= 2:
			print(d)
		else:
			val = 2 * d - s
			b = math.ceil(val / 3)
			print(d - b)
	elif d // s >= 2:
		print(s)
	else:
		val = 2 * s - d
		b = math.ceil(val / 3)
		print(s - b)


test = int(input())
for i in range(test):
	(sticks, diamonds) = map(int, input().split())
	if 2 * sticks <= diamonds:
		print(sticks)
	elif 2 * diamonds <= sticks:
		print(diamonds)
	else:
		print((sticks + diamonds) // 3)


q = int(input())
for z in range(q):
	(a, b) = map(int, input().split(' '))
	if a < b:
		(a, b) = (b, a)
	if a - b < b:
		r = a - b + 2 * (a - 2 * (a - b)) // 3
	else:
		r = b
	print(r)


from collections import defaultdict, Counter
import copy, math
from copy import deepcopy
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	print(min((a, b, (a + b) // 3)))


import sys
from math import log2, floor
TEST = 0
if TEST == 1:
	input_file = open('inputA.txt', 'r')
	input_from_file = input_file.readlines()

def read_int():
	if TEST:
		return int(input_from_file.pop(0))
	else:
		return int(sys.stdin.readline())

def read_ints():
	if TEST:
		return list(map(int, input_from_file.pop(0).rstrip().split()))
	else:
		return list(map(int, sys.stdin.readline().split()))
t = read_int()
for test in range(t):
	(p, a) = read_ints()
	ans = min(a, p, int((a + p) / 3))
	print(ans)


for i in range(int(input())):
	(s, d) = map(int, input().split())
	print(min(s, d, (s + d) // 3))


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


t = int(input())
for _ in range(t):
	(a, b) = list(map(int, input().split()))
	if a == 0 or b == 0:
		print(0)
		continue
	x = min(abs(a - b), a, b)
	ans = 0
	ans += x
	red_a = x
	red_b = x
	if a > b:
		red_a *= 2
	elif b > a:
		red_b *= 2
	(a, b) = (a - red_a, b - red_b)
	if a <= 0 or b <= 0:
		print(ans)
		continue
	ans += a // 3 * 2
	ans += a % 3 // 2
	print(ans)


for _ in range(int(input())):
	(stick, diamond) = [int(i) for i in input().split()]
	print(min((stick + diamond) // 3, min(stick, diamond)))


for i in range(int(input())):
	(a, b) = map(int, input().split())
	if b > a:
		(b, a) = (a, b)
	ans = min(abs(a - b), b)
	a -= ans * 2
	b -= ans
	ans += b // 3 * 2
	a %= 3
	b %= 3
	if b == 2:
		ans += 1
	print(ans)


x = int(input())
for q in range(x):
	em = 0
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	if b >= a * 2:
		print(a)
	else:
		e = b - a
		em += e
		a -= e
		b -= 2 * e
		em += a // 3 * 2
		a %= 3
		b %= 3
		if a == 2:
			em += 1
		print(em)


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


t = int(input())

def search(num1, num2, lst):
	for i in lst:
		if i > num1 or i < num2:
			return 1
	return 0
for _ in range(t):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
	elif a > b:
		if a >= 2 * b:
			print(b)
		else:
			ct = 0
			ct += a - b
			a1 = 2 * b - a
			b1 = 2 * b - a
			if a1 % 3 == 0 or a1 % 3 == 1:
				ct += a1 // 3 * 2
			elif a1 % 3 == 2:
				ct += a1 // 3 * 2 + 1
			print(ct)
	else:
		(a1, b1) = (b, a)
		(a, b) = (a1, b1)
		if a >= 2 * b:
			print(b)
		else:
			ct = 0
			ct += a - b
			a1 = 2 * b - a
			b1 = 2 * b - a
			if a1 % 3 == 0 or a1 % 3 == 1:
				ct += a1 // 3 * 2
			elif a1 % 3 == 2:
				ct += a1 // 3 * 2 + 1
			print(ct)


n = int(input())
rr = lambda : input()
rri = lambda : int(input())
rrm = lambda : list(map(int, input().split()))

def solve(a, b):
	amt = 0
	if b > a:
		(a, b) = (b, a)
	diff = a - b
	amt += diff
	if b < diff:
		return b
	else:
		a -= diff * 2
		b -= diff
		both = min(a // 3, b // 3)
		amt += both * 2
		a -= both * 3
		b -= both * 3
		resta = min(a // 2, b)
		restb = min(b // 2, a)
	return amt + max(resta, restb)
for _ in range(n):
	(a, b) = rrm()
	print(solve(a, b))


import sys
from collections import defaultdict as dd
from collections import deque
from fractions import Fraction as f

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
from math import *
import copy
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

def li():
	return [int(x) for x in input().split()]

def fi():
	return int(input())

def si():
	return list(input().rstrip())

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

def gh():
	sys.stdout.flush()

def bo(i):
	return ord(i) - ord('a')
from copy import *
from bisect import *
from itertools import permutations

def cal(l):
	return l // 4 + (l - l // 2)
t = int(input())
while t > 0:
	t -= 1
	(a, b) = mi()
	if a < b:
		(a, b) = (b, a)
	if 2 * b <= a:
		print(b)
	else:
		print((a + b) // 3)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	c = 0
	(x, y) = (min(a, b), max(a, b))
	c += min(x, y - x)
	y -= 2 * c
	x -= c
	c += x // 3 * 2
	m = x % 3
	if m == 2:
		c += 1
	print(c)


T = int(input())

def solve():
	[A, B] = list(map(int, input().split()))
	(A, B) = (min(A, B), max(A, B))
	delta = min(A, B - A)
	A -= delta
	B -= 2 * delta
	ans = delta
	if A % 3 == 0:
		ans += 2 * A // 3
	elif A % 3 == 1:
		ans += 2 * A // 3
	elif A % 3 == 2:
		ans += 2 * (A - 2) // 3 + 1
	return ans
for _ in range(T):
	print(solve())


for _ in range(int(input())):
	l = list(input().split(' '))
	a = int(l[0])
	b = int(l[1])
	x = (a + b) // 3
	if x < a and x < b:
		print(x)
	elif a < b:
		print(a)
	else:
		print(b)


import math
t = int(input())
for i in range(t):
	(a, b) = [int(x) for x in input().split()]
	if a >= 2 * b or b >= 2 * a:
		print(min(a, b))
	else:
		print(math.floor((a + b) / 3))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if b > a:
		(a, b) = (b, a)
	ans = 0
	d = a - b
	temp = min(b, d)
	ans += temp
	a = a - 2 * temp
	b = b - temp
	ans += b // 3 * 2
	b = b % 3
	if b == 2:
		ans += 1
	print(ans)


t = int(input())
for _ in range(t):
	(a, b) = [int(i) for i in input().split()]
	if a < b:
		(a, b) = (b, a)
	dif = a - b
	ans = min(b, dif)
	a -= ans * 2
	b -= ans
	mn = min(a, b)
	k = int(mn / 3)
	a -= k * 3
	b -= k * 3
	ans += 2 * k
	ans += 1 if a * b != 0 and a + b >= 3 else 0
	print(ans)


t = int(input())
for we in range(t):
	(a, b) = map(int, input().split())
	c = max(a, b)
	d = min(a, b)
	e = 0
	if c - d < d:
		e = c - d
		d -= e
		c -= 2 * e
		e += 2 * (min(c, d) // 3)
		c = min(c, d) % 3
		if c > 1:
			e += 1
	else:
		e = d
	print(e)


t = int(input())

def solve(st, di, em):
	if (st <= 0 or di < 2) and (di <= 0 or st < 2):
		return em
	if (st >= 1 and di >= 2) and (di >= 1 and st >= 2):
		if st > di:
			return solve(st - 2, di - 1, em + 1)
		else:
			return solve(st - 1, di - 2, em + 1)
	elif st > 0 and di >= 2:
		return solve(st - 1, di - 2, em + 1)
	elif di > 0 and st >= 2:
		return solve(st - 2, di - 1, em + 1)
	else:
		pass
for case in range(t):
	(s, d) = map(int, input().split())
	ma = max(s, d)
	mi = min(s, d)
	dif = ma - mi
	if dif > mi:
		print(mi)
	else:
		ems = ma - mi
		same = mi - dif
		ems += int(same * 2 / 3)
		print(ems)


def read_list():
	return list(map(int, input().split(' ')))
N = int(input())
for _ in range(N):
	(x, y) = read_list()
	if 2 * x <= y:
		print(x)
	elif 2 * y <= x:
		print(y)
	else:
		A = (2 * x - y) // 3
		B = (2 * y - x) // 3
		if A + (B + 1) * 2 <= y or (A + 1) * 2 + B <= x:
			print(A + B + 1)
		else:
			print(A + B)


import math
for _ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	if b > a:
		(a, b) = (b, a)
	t = 0
	m = min(math.floor((2 * a - b) / 3), b)
	t += m
	a -= m * 2
	b -= m
	t += max(0, min(b // 2, a))
	print(t)


from math import ceil
for q in range(int(input())):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	y = b - a
	if a < y:
		print(a)
	else:
		res = y
		a -= y
		res += a * 2 // 3
		print(res)


t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	if n == 0 or m == 0:
		print(0)
	elif m > 2 * n or n > 2 * m:
		print(min(m, n))
	else:
		print((m + n) // 3)


from sys import stdin, stdout
for query in range(int(stdin.readline())):
	ab = stdin.readline().split()
	a = int(ab[0])
	b = int(ab[1])
	if a >= 2 * b:
		stdout.write(str(b) + '\n')
	elif b >= 2 * a:
		stdout.write(str(a) + '\n')
	else:
		if b > a:
			(b, a) = (a, b)
		total = 0
		total += a - b
		b -= total
		a -= 2 * total
		total += a // 3 * 2
		a = a % 3
		b = b % 3
		if a >= 2:
			total += 1
		stdout.write(str(total) + '\n')


for t in range(int(input())):
	(a, b) = map(int, input().split())
	l = min(a, b)
	h = max(a, b)
	if h >= 2 * l:
		ans = l
	else:
		ans = h - l
		h = l = l - ans
		ans += 2 * (h // 3)
		if h % 3 == 2:
			ans += 1
	print(ans)


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))


t = int(input())
while t > 0:
	(a, b) = [int(x) for x in input().split()]
	res = 0
	crafted = 0
	while a > 0 and b > 0:
		if a == 1 and b == 1:
			break
		elif a * 2 <= b:
			crafted = a
			res += crafted
			a -= crafted
			b -= crafted * 2
		elif b * 2 <= a:
			crafted = b
			res += crafted
			b -= crafted
			a -= crafted * 2
		elif a < b:
			crafted = b - a
			res += crafted
			a -= crafted
			b -= crafted * 2
		elif b < a:
			crafted = a - b
			res += crafted
			b -= crafted
			a -= crafted * 2
		else:
			crafted = a * 2 // 3
			res += crafted
			a -= crafted * 3 // 2
			b -= crafted * 3 // 2
	print(res)
	t -= 1


def answer(a, b):
	if min(a, b) == 0:
		return 0
	if a == b:
		return (a + b) // 3
	if a > b:
		if a // b >= 2:
			return b
		else:
			return (a + b) // 3
	if a < b:
		if b // a >= 2:
			return a
		else:
			return (a + b) // 3
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	print(answer(a, b))


from math import ceil
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if a > 2 * b:
		print(b)
	elif b > 2 * a:
		print(a)
	else:
		(a, b) = (max(a, b), min(a, b))
		ct = a - b
		a -= 2 * ct
		b -= ct
		ct += 2 * (a // 3)
		a %= 3
		b %= 3
		if min(a, b) == 1 and max(a, b) >= 2:
			ct += 1
		elif min(a, b) == 2 and max(a, b) >= 4:
			ct += 1
		elif min(a, b) == 2 and max(a, b) >= 2:
			ct += 1
		print(ct)


def get_input():
	t = int(input())
	arr = []
	for i in range(t):
		(a, b) = list(map(int, input().split(' ')))
		arr.append([a, b])
	return arr

def equalize(small, big):
	sub = big - small
	steps = min(sub - 1, small)
	return (small - steps, big - steps * 2, steps)

def f1(ab):
	(a, b) = ab
	if a == 0 or b == 0:
		print(0)
		return
	part0 = 0
	if abs(a - b) > 1:
		if a < b:
			(a, b, part0) = equalize(a, b)
		else:
			(b, a, part0) = equalize(b, a)
	if a == 0 or b == 0:
		print(part0)
		return
	part1 = min(a // 3, b // 3) * 2
	a_rest = a - min(a // 3, b // 3) * 3
	b_rest = b - min(a // 3, b // 3) * 3
	part2 = min(max(a_rest, b_rest) // 2, min(a_rest, b_rest) // 1)
	print(part0 + part1 + part2)
arr = get_input()
list(map(f1, arr))


def solve():
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	c = min(b - a, a)
	ans = c
	a -= c
	b -= c * 2
	d = min(a, b)
	e = d // 3
	ans += e * 2
	a -= e * 3
	b -= e * 3
	if a >= 1 and b >= 2:
		ans += 1
		a -= 1
		b -= 2
	if a >= 2 and b >= 1:
		ans += 1
		a -= 1
		b -= 1
	return ans

def main():
	T = int(input())
	for _ in range(T):
		print(solve())
main()


t = int(input())
while t:
	(n, k) = map(int, input().split())
	print(min(n, k, (n + k) // 3))
	t -= 1


from sys import stdin, stdout
t = int(stdin.readline())
for _ in range(t):
	(s, d) = map(int, stdin.readline().split())
	stdout.write(f'{min(s, d, (s + d) // 3)}\n')


from copy import *
from math import *
t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().split()))
	if a >= 2 * b:
		print(b)
		continue
	if b >= 2 * a:
		print(a)
		continue
	if a == 0 or b == 0:
		print(0)
		continue
	else:
		c = 0
		x = min(a, b)
		y = max(a, b)
		c += y - x
		Y = y - 2 * c
		X = x - c
		c += X // 3 * 2
		if X % 3 == 2:
			c += 1
		print(c)


import sys
import math as mt
input = sys.stdin.buffer.readline
t = int(input())
for __ in range(t):
	(a, b) = map(int, input().split())
	maxi = max(a, b)
	mini = min(a, b)
	ans = 0
	p = maxi - mini
	ans = min(p, mini)
	if maxi - 2 * p >= 0 and mini - p >= 0:
		x = mini - p
		ans += 2 * x // 3
	print(ans)


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


from math import floor
t = int(input())
for _ in range(t):
	(a, b) = (int(x) for x in input().split())
	mini = min(a, b)
	maxi = max(a, b)
	if maxi > 2 * mini:
		print(mini)
	else:
		temp = a - b + 2 * floor((2 * b - a) / 3)
		if (2 * b - a) % 3 == 2:
			print(temp + 1)
		else:
			print(temp)


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


import math as mt
import sys, string
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappush, heapify, heappop
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
t = I()
for _ in range(t):
	(n, m) = M()
	print(min(n, m, (n + m) // 3))


import io
import os
if not 'STDINPUT' in os.environ:
	global input
	input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
else:
	print('Standard input')
t = int(input())
while t:
	t -= 1
	(a, b) = [int(x) for x in input().split()]
	(a, b) = (min(a, b), max(a, b))
	b = min(b, a << 1)
	print((a + b) // 3)


nb_cases = int(input())
for case in range(nb_cases):
	(a, b) = [int(x) for x in input().split()]
	if a > b:
		temp = a
		a = b
		b = temp
	nb_emeralds = 0
	if b >= 2 * a:
		nb_emeralds = a
	else:
		nb_emeralds = b - a
		nb_emeralds += 2 * int((2 * a - b) / 3)
		if (2 * a - b) % 3 == 2:
			nb_emeralds += 1
	print(nb_emeralds)


def countSetBits(n):
	count = 0
	while n:
		count += n & 1
		n >>= 1
	return count
import math

def bubble_sort(c):
	n = len(c)
	for i in range(n):
		already_sorted = True
		for j in range(n - i - 1):
			if c[j][0] < c[j + 1][0]:
				(c[j][0], c[j + 1][0]) = (c[j + 1][0], c[j][0])
				already_sorted = False
			if c[j][0] == c[j + 1][0]:
				if c[j][1] > c[j + 1][1]:
					(c[j][1], c[j + 1][1]) = (c[j + 1][1], c[j][1])
		if already_sorted:
			break
	return c

def fun(l, r):
	if l > r:
		return
	m = (l + r) // 2
	c.append([l - r, m])
	fun(l, m - 1)
	fun(m + 1, r)
t = int(input())
while t:
	t -= 1
	(nn, mm) = map(int, input().split())
	if nn == 0 or mm == 0:
		print(0)
	elif mm > 2 * nn or nn > 2 * mm:
		print(min(mm, nn))
	else:
		print((mm + nn) // 3)


for _ in range(int(input())):
	(a, b) = map(int, input().strip().split())
	n = min(a, b)
	m = max(a, b)
	if n == 0 or m == 0:
		print(0)
	elif m >= 2 * n:
		print(n)
	elif n == m:
		print((m + n) // 3)
	else:
		x = 2 * n - m
		num = m - n + 2 * x // 3
		print(num)


t = int(input())
a_ = []
b_ = []
for i in range(t):
	(a, b) = map(int, input().split())
	a_.append(a)
	b_.append(b)

def minecraft(a, b):
	return min(a, b, (a + b) // 3)
for i in range(t):
	u = minecraft(a_[i], b_[i])
	print(u)


def ab():
	sum = 0
	(b, c) = map(int, input().split())
	if b > c:
		if b // 2 == c:
			print(c)
		elif b // 2 < c:
			ans = b // 2
			if c >= 2 and b == 1:
				ans += 1
			print((b + c) // 3)
		else:
			print(c)
	else:
		(b, c) = (c, b)
		if b // 2 == c:
			print(c)
		elif b // 2 < c:
			ans = b // 2
			if c >= 2 and b == 1:
				ans += 1
			print((b + c) // 3)
		else:
			print(c)
for i in range(0, int(input())):
	ab()


def solve(a, b):
	x = min(a, b)
	y = max(a, b)
	if y >= 2 * x:
		return x
	else:
		if y != x:
			k = y - x
			a = y - 2 * k
			k += a // 3 * 2
			if a % 3 == 2:
				k += 1
		else:
			k = y // 3 * 2
			if y % 3 == 2:
				k += 1
		return k
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	print(solve(a, b))


import math
from collections import defaultdict, Counter, deque
INF = float('inf')

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def primeFactor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i ** 2 <= n:
		if n % i == 0:
			return i
		i += 1
	return n

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


def f(a, b):
	if a == 0 or b == 0 or max(a, b) < 2:
		return 0
	if b >= a:
		(a, b) = (b, a)
	if b < a // 2:
		return min(int(a // 2), b)
	else:
		if a // 2 % 2 == 1:
			return (a // 2 + 1) // 2 + f(a - 2 * ((a // 2 + 1) // 2), b - (a // 2 + 1) // 2)
		return a // 2 // 2 + f(a - 2 * (a // 2 // 2), b - a // 2 // 2)
for tc in range(int(input())):
	al = list(map(int, input().split()))
	print(f(al[0], al[1]))


for _ in range(int(input())):
	[sticks, diamonds] = list(map(int, input().split()))
	larger = diamonds
	smaller = sticks
	if sticks < diamonds:
		larger = diamonds
		smaller = sticks
	else:
		larger = sticks
		smaller = diamonds
	if smaller * 2 < larger:
		print(smaller)
	else:
		print((larger + smaller) // 3)


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


t = int(input())
for test in range(t):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	if 2 * a <= b:
		print(a)
	else:
		q = (2 * a - b) // 3
		r = (2 * a - b) % 3
		print(b - a + q * 2 + (r == 2))


def ShovelsandSwords(a, b):
	if 2 * a <= b:
		return a
	elif 2 * b <= a:
		return b
	else:
		return int((a + b) / 3)
Lista = []
total = int(input())
for i in range(total):
	All = [int(i) for i in input().split()]
	Lista.append(All)
for j in Lista:
	print(ShovelsandSwords(j[0], j[1]))


def program():
	(a, b) = map(int, input().split())
	if b < a:
		(b, a) = (a, b)
	d = b - a
	if a <= b // 2:
		print(a)
	elif a == b:
		di = {1: 0, 2: 1, 3: 2}
		count = 0
		if a <= 3:
			count += di[a]
		elif a % 3 == 0:
			count += 2 * (a // 3)
		else:
			count += 2 * (a // 3) + di[a % 3]
		print(count)
	else:
		a -= d
		di = {1: 0, 2: 1, 3: 2}
		b -= 2 * d
		count = d
		if a <= 3:
			count += di[a]
		elif a % 3 == 0:
			count += 2 * (a // 3)
		else:
			count += 2 * (a // 3) + di[a % 3]
		print(count)
for i in range(int(input())):
	program()


import math
for _ in range(int(input())):
	l = list(map(int, input().split()))
	(a, b) = (l[0], l[1])
	if a < b:
		a = a + b
		b = a - b
		a = a - b
	if a == 0 or b == 0:
		print(0)
	elif a > 2 * b:
		print(b)
	else:
		p = math.ceil((2 * a - b) / 3)
		s = a - 2 * p
		print(p + s)


for t in range(int(input())):
	(a, b) = map(int, input().split())
	ans = 0
	if a < b:
		(a, b) = (b, a)
	if a >= 2 * b:
		print(b)
	else:
		ans = a - b
		a -= 2 * ans
		b -= ans
		ans += 2 * (a // 3)
		if a % 3 == 2:
			ans += 1
		print(ans)


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


import queue
import math
t = int(input())
while t:
	line = input().split()
	(a, b) = (int(line[0]), int(line[1]))
	if a > b:
		(a, b) = (b, a)
	if a * 2 <= b:
		print(a)
	else:
		ans = b - a
		a -= ans
		ans += a - a // 3 - (a % 3 > 0)
		print(ans)
	t -= 1


import math
import os
import random
import re
import sys
from math import gcd
for _ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	d = (a + b) // 3
	print(min(a, b, d))


h = int(input())
for i in range(0, h):
	(x, y) = [int(a) for a in input().split()]
	if x > y:
		if x >= y * 2:
			s = y
		else:
			s = (x + y) // 3
	elif y >= x * 2:
		s = x
	else:
		s = (x + y) // 3
	print(s)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	res = min(min(a, b), abs(a - b))
	k = min(a, b) - min(min(a, b), abs(a - b))
	res += k // 3 * 2
	if k % 3 == 2:
		res += 1
	print(res)


tests = int(input())
for _ in range(tests):
	materials = list(map(int, input().split()))
	sticks = materials[0]
	diamonds = materials[1]
	awns = min(sticks, diamonds, (sticks + diamonds) // 3)
	print(awns)


def f(ab):
	(a, b) = (int(ab[0]), int(ab[1]))
	if a < b:
		(a, b) = (b, a)
	if a > 2 * b:
		return b
	else:
		return int((a + b) / 3)
for i in range(int(input())):
	print(f(input().split(' ')))


from math import *
sInt = lambda : int(input())
mInt = lambda : map(int, input().split())
lInt = lambda : list(map(int, input().split()))
t = sInt()
for _ in range(t):
	(a, b) = mInt()
	if a != 0 and b != 0:
		print(min((a + b) // 3, min(a, b)))
	else:
		print(0)


import math

def dtod(a):
	s = ''
	while a != 0:
		s += str(a % 2)
		a = int(a / 2)
	return s[::-1]
n = int(input())
for i in range(n):
	s = input().split(' ')
	a = int(s[0])
	b = int(s[1])
	print(min(min(a, b), int((a + b) / 3)))


def shovels_and_swords(a, b):
	equal = False
	if a == b:
		equal = True
	bigger = max(a, b)
	smaller = min(a, b)
	if equal:
		product = a / 1.5
		product = int(product)
	else:
		difference = bigger - smaller
		if smaller >= difference:
			leftover = smaller - difference
			product = difference + int(leftover / 1.5)
		else:
			product = smaller
	return product
t = int(input())
answers = []
for test in range(t):
	(a, b) = (int(x) for x in input().split())
	ans = shovels_and_swords(a, b)
	answers.append(ans)
for ans in answers:
	print(ans)


import math

def fact(n):
	ans = 1
	for i in range(2, n + 1):
		ans *= i
	return ans

def comb(n, c):
	return fact(n) // (fact(n - c) * c)
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	ans = 0
	done = False
	if a <= 0 or b <= 0:
		done = True
	while a > 0 and b > 0:
		if a == 1 and b == 1:
			done = True
			break
		if b == a:
			break
		dif = min(abs(a - b), min(a, b))
		if a > b:
			a -= dif * 2
			b -= dif
			ans += dif
		elif b >= a:
			b -= dif * 2
			a -= dif
			ans += dif
	if not done and a > 0 and (b > 0):
		ans += a // 3 * 2
		a -= 3 * (a // 3)
		b -= 3 * (b // 3)
		if a == 2:
			ans += 1
	print(ans)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		c = 0
	elif a > b:
		x = a / b
		if x >= 2:
			c = b
		elif x > 1:
			p = (2 * b - a) / 3
			b = b - 2 * p
			c = p + b
	elif b > a:
		x = b / a
		if x >= 2:
			c = a
		elif x > 1:
			p = (2 * a - b) / 3
			a = a - 2 * p
			c = p + a
	else:
		c = 2 * (a // 3) + a % 3 / 2
	print(int(c))


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)


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


def shovel_sword(a, b):
	if a == 0 or b == 0:
		return 0
	return min((a + b) // 3, b, a)
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	print(shovel_sword(a, b))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	(a, b) = (max(n, m), min(n, m))
	if b == 0 or a == 0:
		print(0)
		continue
	elif 2 * b <= a:
		print(b)
		continue
	x = n + m
	print(x // 3)


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


import sys
import math
from decimal import *

def I():
	return int(sys.stdin.readline())

def IL():
	return list(map(int, sys.stdin.readline().strip().split()))

def ILS():
	return list(map(str, sys.stdin.readline().strip().split()))
tt = I()
for ii in range(tt):
	(a, b) = IL()
	if a < b:
		(a, b) = (b, a)
	diff = abs(a - b)
	cut = min(diff, b)
	em = cut
	a -= 2 * cut
	b -= cut
	em += b // 3 * 2
	if b % 3 > 1:
		em += 1
	print(em)
	pass


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


import sys
import math
sys.setrecursionlimit(100000)
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

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


for t in range(int(input())):
	(a, b) = map(int, input().split())
	if a < b:
		(a, b) = (b, a)
	m = min(b, a - b)
	(a, b) = (a - m * 2, b - m)
	m2 = min(a // 3, b // 3)
	(m, a, b) = (m + m2 * 2, a - m2 * 3, b - m2 * 3)
	if max((a, b)) == 2 and min((a, b)) != 0:
		print(m + 1)
	else:
		print(m)


t = int(input())
for c in range(t):
	(a, b) = map(int, input().split())

	def doble(x, y):
		if x >= 2 * y:
			return y
		else:
			return x

	def iguales(z, w):
		if z == w:
			if z == 0 or w == 0:
				return 0
			if z == 1 and w == 1:
				return 0
			if z > 1:
				coins = z // 3 * 2
				if z % 3 == 0 or z % 3 == 1:
					return coins
				if z % 3 == 2:
					return coins + 1
	if a == b:
		print(iguales(a, b))
	elif a >= 2 * b or b >= 2 * a:
		print(doble(a, b))
	else:
		if a < b:
			dif = b - a
			a = a - dif
			b = a
			parte = iguales(a, b)
			monedas = parte + dif
			print(monedas)
		if b < a:
			dif = a - b
			b = b - dif
			a = b
			parte = iguales(a, b)
			monedas = parte + dif
			print(monedas)


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


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


import sys
input = sys.stdin.readline
t = int(input())
for ti in range(1, t + 1):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	if b >= a * 2:
		print(a)
	else:
		print((a + b) // 3)


from sys import stdin
input = stdin.readline
import bisect
import math
for xoxo in range(1):
	for _ in range(int(input())):
		(a, b) = map(int, input().split())
		if a < b:
			(a, b) = (b, a)
		if a >= 2 * b:
			ans = b
		elif a == b:
			ans = a // 3 * 2
			if a % 3 == 2:
				ans += 1
		else:
			ans = (a + b) // 3
		print(ans)


n = int(input())
for i in range(n):
	t = 0
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	h = (a + b) // 3
	s = min(a, b)
	if a == 0:
		print(0)
	elif b == 0:
		print(0)
	elif min(a, b) >= h:
		print(h)
	elif max(a, b) >= 2 * min(a, b):
		print(min(a, b))


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	ans = min(a, b - a)
	a -= ans
	b -= ans * 2
	ans2 = a // 3
	a -= ans2 * 3
	b -= ans2 * 3
	print(ans + ans2 * 2 + int(a + b > 2 and min(a, b) >= 1))


def profit(sticks, diamonds):
	return min([sticks, diamonds, (sticks + diamonds) // 3])
lines = int(input())
for i in range(lines):
	line = input().split()
	print(profit(int(line[0]), int(line[1])))


import sys, math
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	ans = (a + b) // 3
	print(min(a, b, ans))


def main():
	t = int(input())
	for i in range(0, t):
		(a, b) = map(int, input().split())
		ans = [a, b, int((a + b) / 3)]
		print(min(ans))
main()


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))
T = 1
T = int(stdin.readline())
for _ in range(T):
	(a, b) = list(map(int, stdin.readline().split()))
	ans = 0
	(a, b) = (min(a, b), max(a, b))
	if a == 0 or b == 0:
		print(0)
	elif 2 * a <= b:
		print(a)
	else:
		print((a + b) // 3)


for _t in range(int(input())):
	(a, b) = list(map(int, input().split()))
	if a == 0 or b == 0:
		print(0)
	elif a < b // 2 or b < a // 2:
		print(min(a, b))
	else:
		s = a + b
		print(s // 3)


def ans(a, b):
	x = a
	y = b
	if x == 1 and y > 1:
		print(1)
	elif y == 1 and x > 1:
		print(1)
	elif x * 2 <= y or y * 2 <= x:
		print(min(x, y))
	else:
		print((a + b) // 3)
t = int(input())
while t > 0:
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
	else:
		ans(a, b)
	t -= 1


from sys import *

def get():
	return [int(w) for w in stdin.readline().split()]
(t,) = get()
for i in range(t):
	(a, b) = get()
	ans = min(a, min(b, (a + b) // 3))
	print(ans)


t = int(input())
while t > 0:
	t = t - 1
	_ = input().split()
	a = int(_[0])
	b = int(_[1])
	if a < b:
		temp = a
		a = b
		b = temp
	if a > 2 * b:
		print(b)
	else:
		print(int((a + b) / 3))


import sys
input = sys.stdin.readline

def inp():
	return int(input())

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

def instr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
for i in range(t):
	(a, b) = invr()
	tools = 0
	if a == 0 or b == 0 or (a == 1 and b == 1):
		tools = 0
	elif 2 * a < b:
		tools = a
	elif 2 * b < a:
		tools = b
	else:
		tools = int((a + b) / 3)
	print(tools)


import math
from sys import stdin, stdout
from heapq import heapify, heappop, heappush
T = int(stdin.readline())
for i in range(T):
	(a, b) = list(map(int, stdin.readline().split()))
	ans = 0
	if a > 1 and b > 0 or (b > 1 and a > 0):
		if a >= 2 * b:
			ans += b
		elif b >= 2 * a:
			ans += a
		else:
			ans += (a + b) // 3
	print(ans)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a < b:
		t = a
		a = b
		b = t
	f = a // 2
	if f >= b:
		print(b)
	else:
		if a % 2 == 0:
			m = b - f
		else:
			m = b - f + 1
		r = m // 3
		print(r + f)


t = int(input())
import copy
import math
ans = []
for _ in range(t):
	inp = input().split()
	a = int(inp[0])
	b = int(inp[1])
	count = 0
	x = max(a, b)
	y = min(a, b)
	count = (x + y) // 3
	count = min(count, y)
	ans.append(count)
for i in range(len(ans)):
	print(ans[i])


import math
t = int(input())
for w in range(t):
	(a, b) = (int(i) for i in input().split())
	k1 = min(a, b)
	k2 = max(a, b)
	if k2 <= 1:
		print(0)
	elif k2 >= 2 * k1:
		print(k1)
	else:
		print((a + b) // 3)


def solve():
	(d, s) = map(int, input().split(' '))
	ans = 0
	if d > s:
		craft = min(d - s, s)
		d -= 2 * craft
		s -= craft
		ans += craft
	else:
		craft = min(s - d, d)
		d -= craft
		s -= 2 * craft
		ans += craft
	craft = min(d, s) // 3
	ans += craft * 2
	d -= craft * 3
	s -= craft * 3
	if d > 0 and s > 1 or (d > 1 and s > 0):
		ans += 1
	return ans
T = int(input())
ans = []
for _ in range(T):
	ans.append(solve())
for a in ans:
	print(a)


import math

def main():
	t = int(input())
	for case in range(t):
		(s, d) = input().split()
		s = int(s)
		d = int(d)
		count = 0
		if d > s:
			big = d
			small = s
		else:
			big = s
			small = d
		if big >= 2 * small:
			count = small
		else:
			while big > 3 and small > 2:
				temp = int(big / 2)
				if temp % 2 == 1:
					temp -= 1
				big -= temp
				small -= temp / 2
				count += temp / 2
				if big < small:
					temp = big
					big = int(small)
					small = int(temp)
			if big == 3 and small == 3:
				count += 2
			elif small > 0 and big > 1:
				count += 1
		print(int(count))
main()


from sys import stdin, stdout
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
P = lambda x: stdout.write(x)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
N = 10 ** 9 + 7
for _ in range(I()):
	(a, b) = R()
	if a < b:
		(a, b) = (b, a)
	if 2 * b <= a:
		print(b)
		continue
	ans = a - b
	a -= ans * 2
	b -= ans
	ans += a // 3 * 2
	if a % 3 > 1:
		ans += 1
	print(ans)


a = int(input())
for i in range(a):
	b = [int(x) for x in input().split()]
	summ = 0
	if b[0] > b[1]:
		k = b[0]
		b[0] = b[1]
		b[1] = k
	dif = b[1] - b[0]
	if dif <= b[0]:
		summ += dif
		b[1] -= 2 * dif
		b[0] -= dif
	if b[0] == b[1]:
		k = b[0] // 3
		summ += 2 * (b[0] // 3) + max(b[0] % 3 - 1, 0)
		print(summ)
	else:
		print(min(b[0], b[1] // 2))


import sys
input = lambda : sys.stdin.readline().rstrip()
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	(a, b) = (max(a, b), min(a, b))
	ans = 0
	c = a - b
	d = min(c, a // 2, b)
	ans += d
	a -= 2 * d
	b -= d
	(a, b) = (max(a, b), min(a, b))
	e = min(a // 3, b // 3)
	ans += 2 * e
	a -= 3 * e
	b -= 3 * e
	ans += min(a // 2, b)
	print(ans)


t = int(input())
for case in range(t):
	[a, b] = list(map(int, input().split()))
	if a == 0 or b == 0:
		print(0)
		continue
	(r, q) = (a // b, b // a)
	if r >= 2:
		print(b)
	elif q >= 2:
		print(a)
	else:
		print((a + b) // 3)


def function(a, b):
	cash = 0
	(a, b) = (max(a, b), min(a, b))
	while a > 2 and b > 2 and (a < 2 * b):
		a -= 3
		b -= 3
		cash += 2
	cash += min(a // 2, b)
	print(cash)

def solve(a, b):
	print(min(a, b, (a + b) // 3))

def submit():
	for _ in range(int(input())):
		(a, b) = list(map(int, input().split()))
		solve(a, b)

def tryOut():
	(a, b) = (8, 7)
	function(a, b)
submit()


testy = int(input())
results = []
for i in range(testy):
	(a, b) = map(int, input().split())
	if min(a, b) == 0:
		results.append(0)
	elif max(a, b) // min(a, b) >= 2:
		results.append(min(a, b))
	else:
		results.append((a + b) // 3)
for result in results:
	print(result)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')
from math import factorial
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def main():
	for _ in range(N()):
		(a, b) = RL()
		print(min(a, b, (a + b) // 3))
main()


def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
entries = inp()
for i in range(entries):
	l = inlt()
	x = l[0]
	y = l[1]
	res = 0
	if x > y:
		p = x - y
		x -= 2 * p
		if y - p <= 0:
			print(y)
		else:
			res += p
			y = y - p
			res += x // 3 * 2
			y = y % 3
			if y == 2:
				res += 1
			print(res)
	else:
		p = y - x
		y -= 2 * p
		if x - p <= 0:
			print(x)
		else:
			res += p
			x = x - p
			res += x // 3 * 2
			x = x % 3
			if x == 2:
				res += 1
			print(res)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	c = 0
	if a > b:
		c = min(a - b, b)
		b -= c
		a -= 2 * c
	elif a < b:
		c = min(b - a, a)
		a -= c
		b -= 2 * c
	d = min(a, b) // 3
	c += d * 2
	a -= d * 3
	b -= d * 3
	if a > 1 and b > 0 or (a > 0 and b > 1):
		c += 1
	print(c)


import sys
import math

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()
t = II()
for q in range(t):
	(a, b) = MI()
	(a, b) = (max(a, b), min(a, b))
	if a < b * 2:
		print((a + b) // 3)
	else:
		print(b)


def countgems(a, b):
	if a == 0 or b == 0:
		return 0
	maxe = max(a, b)
	mine = min(a, b)
	gems = min(mine, maxe - mine)
	gems += 2 * (mine - gems) // 3
	return gems
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	print(countgems(a, b))


def emeralds(min_val, max_val):
	if max_val >= 2 * min_val:
		return min_val
	else:
		count = 0
		diff = max_val - min_val
		count += diff
		max_val -= 2 * diff
		min_val -= diff
		pairs = min_val // 3
		count += pairs * 2
		min_val -= pairs * 3
		max_val -= pairs * 3
		if min_val == 2:
			count += 1
		return count
t_test = int(input().strip())
while t_test > 0:
	(a, b) = list(map(int, input().strip().split(' ')))
	min_val = min(a, b)
	max_val = max(a, b)
	print(emeralds(min_val, max_val))
	t_test -= 1


from __future__ import division, print_function
from sys import stdin, stdout
import bisect
import math
import heapq
i_m = 9223372036854775807

def inin():
	return int(input())

def stin():
	return input()

def spin():
	return map(int, stin().split())

def lin():
	return list(map(int, stin().split()))

def matrix(n):
	return [list(map(int, input().split())) for i in range(n)]

def count2Dmatrix(i, list):
	return sum((c.count(i) for c in list))

def modinv(n, p):
	return pow(n, p - 2, p)

def GCD(x, y):
	x = abs(x)
	y = abs(y)
	if min(x, y) == 0:
		return max(x, y)
	while y:
		(x, y) = (y, x % y)
	return x

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l
prime = []

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j
for _ in range(inin()):
	(a, b) = spin()
	print(min(a, b, (a + b) // 3))


case = int(input())
for i in range(case):
	(x, y) = (int(v) for v in input().split())
	if x > y * 2:
		print(y)
	elif y > x * 2:
		print(x)
	else:
		print((x + y) // 3)


import sys
sys.setrecursionlimit(10000)
t = int(input())
for _ in range(t):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	if a > 2 * b:
		print(b)
	elif b > 2 * a:
		print(a)
	else:
		x = (2 * a - b) / 3
		y = (2 * b - a) / 3
		print(int(x + y))


def solve(a, b):
	if min(a, b) == 0:
		return 0
	if max(a, b) / min(a, b) >= 2:
		return min(a, b)
	else:
		return (a + b) // 3
for i in range(int(input())):
	(a, b) = map(int, input().split())
	print(solve(a, b))


import sys
t = int(sys.stdin.readline())
for i in range(t):
	(a, b) = map(int, sys.stdin.readline().split())
	sys.stdout.write(str(min(a, b, (a + b) // 3)) + '\n')


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


inp = lambda cast=int: [cast(x) for x in input().split()]
printf = lambda s='', *args, **kwargs: print(str(s).format(*args), flush=True, **kwargs)
(t,) = inp()
for _ in range(t):
	(a, b) = inp()
	if a > b:
		(a, b) = (b, a)
	if b >= 2 * a:
		print(a)
	else:
		print((a + b) // 3)


def solve():
	for _ in range(int(input())):
		(s, d) = map(int, input().strip().split())
		if s == 0 or d == 0:
			print(0)
		elif s >= 2 * d or d >= 2 * s:
			print(min(s, d))
		else:
			cs = s // 3
			s = s % 3
			cd = d // 3
			d = d % 3
			c = cs + cd
			if d == 1 and s == 2 or (s == 1 and d == 2) or (d == 2 and s == 2):
				c += 1
			print(c)
solve()


import math
t = int(input())
while t > 0:
	t -= 1
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		print(0)
	elif a >= b // 2 and b >= a // 2:
		print((a + b) // 3)
	elif a < b:
		print(a)
	else:
		print(b)


t = int(input())
for i in range(t):
	cnt = 0
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	if a == 0 or b == 0:
		print(0)
	elif a * 2 <= b:
		print(a)
	elif b * 2 <= a:
		print(b)
	else:
		temp = a + b
		temp2 = temp // 3
		print(temp2)


t = int(input())
for i in range(0, t):
	tmp = input()
	tmp = tmp.split(' ')
	sticks = int(tmp[0])
	diamonds = int(tmp[1])
	if diamonds > sticks:
		(sticks, diamonds) = (diamonds, sticks)
	k = sticks - diamonds
	if k >= diamonds:
		print(diamonds)
	else:
		sticks -= 2 * k
		diamonds -= k
		r = diamonds // 3
		diamonds -= r * 3
		if diamonds == 2:
			k += 1
		r *= 2
		r += k
		print(r)


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))

def solve():
	(a, b) = get_tuple()
	if a == 0 or b == 0:
		return 0
	if a < b:
		(a, b) = (b, a)
	if a >= 2 * b:
		return min(a // 2, b)
	ans = 0
	while abs(a - b) > 1 and a > 0 and (b > 0):
		if a < b:
			(a, b) = (b, a)
		x = (a - b) // 2
		a -= x * 2
		b -= x
		ans += x
	if a == 0 or b == 0:
		return ans
	return ans + (a + b) // 3

def main():
	print(solve())
TestCases = True
if TestCases:
	for i in range(get_int()):
		main()
else:
	main()


import sys
t = int(input())
for i in range(t):
	inp = input().split()
	a = int(inp[0])
	b = int(inp[1])
	count = 0
	if a == 0 or b == 0:
		a = -1
		b = -1
	if a == 1 and b == 1:
		a = -1
		b = -1
	if b > a and a > 0:
		if b >= 2 * a:
			count += a
			a = 0
			b = 0
		else:
			count += a - b
			b = 2 * b - a
			a = b
	if a > b and b > 0:
		if a >= 2 * b:
			count += b
			a = 0
			b = 0
		else:
			count += a - b
			b = 2 * b - a
			a = b
	if a > 1:
		count += int(2 * a / 3)
		print(count)
	else:
		print(count)


exec(int(input()) * 'a=list(map(int,input().split()))\nprint(min(sum(a)//3,min(a)))\n')


import os
import sys
from io import BytesIO, IOBase
from collections import Counter
from collections import deque
import heapq
import math
import statistics

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
p = print
MAX = float('inf')
MIN = float('-inf')

def readTree(n):
	adj = [set() for _ in range(n)]
	for _ in range(n - 1):
		(u, v) = ain()
		adj[u - 1].add(v - 1)
		adj[v - 1].add(u - 1)
	return adj

def main():
	for _ in range(iin()):
		(a, b) = ain()
		e = 0
		if a == 0 or b == 0:
			e = 0
		else:
			if b > a:
				(a, b) = (b, a)
			if a // 2 >= b:
				e += b
			else:
				x = '(2*a - b)/3'
				p = eval(x)
				p = math.ceil(p)
				e += p
				a = a - p * 2
				b = b - p
				if a != 0:
					if b == 2 * a:
						e += a
					else:
						e += min(a, b // 2)
		print(e)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
for _ in range(n):
	(a, b) = list(map(int, input().split()))
	max_ab = max(a, b)
	min_ab = min(a, b)
	diamond = 0
	if min_ab >= 1 and max_ab >= 2:
		diff = abs(a - b)
		if diff >= min_ab:
			diamond = min_ab
		else:
			diamond += diff
			min_ab -= diff
			diamond += int(min_ab / 3 * 2)
	print(diamond)