#include<iostream>
#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;

int  w[100005];  // 记录 w 坐标
double wi[100005]; // 到 w 位置的值
int  e[100005];  // 记录 e 坐标
double ei[100005]; // 到 e 位置的值

int find( int lt,int rt,int key )
{
    if( rt - lt < 10 )
    {
        for( int i = lt; i <= rt; i++ )
        if( e[i] >= key )
        return i;
        return rt;
    }
    int mid = ( lt + rt )/2;
    if( e[mid] >= key )
          return find( lt,mid,key );
    else  return find( mid+1,rt,key);
}

int  finds( int  l,int r,double key  )
{
    int  mid;
    while( l <=  r  )
    {
        mid  = (l + r )>>1;
        if(  e[mid]  >=  key  )
             r = mid  -  1;
        else l = mid  +  1;
    }
    return   l;
}

int main( )
{
    int N,M,pos,a,b;
    while( scanf("%d%d%d%d",&N,&M,&a,&b ) != EOF )
    {
        int ans = 0;
        for( int i = 1; i <= N; i++ )
        {
            scanf("%d",&e[i]);             // 读入值放入 e
            ei[i] = sqrt( (a*a) + (e[i]*e[i]) );
        }
        for( int i = 1; i <= M; i++ )
             scanf("%d",&w[i]);
        for( int i = 1; i <= M; i++ )
             scanf("%lf",&wi[i]);
        int wt,et;
        double val = 1<<30;
        for( int i = 1; i <= M; i++ )
        {
                pos = find( 1,N,w[i]>>1 );
                if( pos >= 1 && pos <= N )
                if( val > wi[i] + ei[pos] + sqrt( (a-b)*(a-b)+(w[i]-e[pos])*(w[i]-e[pos]) ) )
                {
                    val = wi[i] + ei[pos] + sqrt( (a-b)*(a-b)+(w[i]-e[pos])*(w[i]-e[pos]) );
                    wt = i;
                    et = pos;
                }
                pos--;
                if( pos >= 1 && pos <= N )
                if( val > wi[i] + ei[pos] + sqrt( (a-b)*(a-b)+(w[i]-e[pos])*(w[i]-e[pos]) ) )
                {
                    val = wi[i] + ei[pos] + sqrt( (a-b)*(a-b)+(w[i]-e[pos])*(w[i]-e[pos]) );
                    wt = i;
                    et = pos;
                }
        }
        printf("%d %d\n",et,wt);
    }
    return 0;
}


import sys
from math import *

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

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

n, m, a, b = mints()
A = list(mints())
B = list(mints())
l = list(mints())
j = -1
r = (1e100,-1,-1)
for i in range(m):
	while not((j == -1 or a*B[i]-b*A[j] >= 0) \
		and (j+1 == n or a*B[i]-b*A[j+1] < 0)):
		j += 1
	print(j)#,a*B[i]-b*A[j],a*B[i]-b*A[j+1])
	if j != -1:
		r = min(r,(l[i]+sqrt(a*a+A[j]*A[j])+sqrt((b-a)**2+(B[i]-A[j])**2),j,i))
	if j+1 != n:
		r = min(r,(l[i]+sqrt(a*a+A[j+1]*A[j+1])+sqrt((b-a)**2+(B[i]-A[j+1])**2),j+1,i))
print(r[1]+1,r[2]+1)


import sys
from math import *

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

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

n, m, a, b = mints()
A = list(mints())
B = list(mints())
l = list(mints())
j = -1
r = (1e100,-1,-1)
for i in range(m):
	while not((j == -1 or a*B[i]-b*A[j] >= 0) \
		and (j+1 == n or a*B[i]-b*A[j+1] < 0)):
		j += 1
	#print(j)#,a*B[i]-b*A[j],a*B[i]-b*A[j+1])
	if j != -1:
		r = min(r,(l[i]+sqrt(a*a+A[j]*A[j])+sqrt((b-a)**2+(B[i]-A[j])**2),j,i))
	if j+1 != n:
		r = min(r,(l[i]+sqrt(a*a+A[j+1]*A[j+1])+sqrt((b-a)**2+(B[i]-A[j+1])**2),j+1,i))
print(r[1]+1,r[2]+1)


import sys
from math import *

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

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

n, m, a, b = mints()
A = list(mints())
B = list(mints())
l = list(mints())
j = -1
r = (1e100,-1,-1)
for i in range(m):
	while not((j == -1 or a*B[i]-b*A[j] >= 0) \
		and (j+1 == n or a*B[i]-b*A[j+1] < 0)):
		j += 1
	if j != -1:
		r = min(r,(l[i]+sqrt(a*a+A[j]*A[j])+sqrt((b-a)**2+(B[i]-A[j])**2),j,i))
	if j+1 != n:
		r = min(r,(l[i]+sqrt(a*a+A[j+1]*A[j+1])+sqrt((b-a)**2+(B[i]-A[j+1])**2),j,i))
print(r[1]+1,r[2]+1)


# http://codeforces.com/problemset/problem/250/D
from math import sqrt

def calcPath(x1, y1, x2, y2):
	return sqrt(pow(x1-x2,2)+pow(y1-y2,2))

# with open('h.in', 'r') as inputFile, open('h.out', 'w') as outputFile:
(n,m,a,b) = [int(x) for x in input().strip().split(' ')]
A = [int(x) for x in input().strip().split(' ')]
B = [int(x) for x in input().strip().split(' ')]
L = [int(x) for x in input().strip().split(' ')]
# print(n,m,a,b)
# print(A,B,L)
i = 0
j = 0
res = {}
stop = 0
while i<m:
	min_path = 0
	curr_path = 0
	while j<n:
		curr_path = calcPath(0,0,a,A[j]) + calcPath(a,A[j],b,B[i])+L[i]
		if min_path < curr_path and min_path != 0:
			break
		min_path = curr_path
		j += 1
	i += 1
	res[min_path] = [j-1,i];
min_k = min(res.keys())
# print(res)
print(str(res[min_k][0])+" "+str(res[min_k][1]))


# http://codeforces.com/problemset/problem/250/D
from math import sqrt

def calcPath(x1, y1, x2, y2):
	return sqrt(pow(x1-x2,2)+pow(y1-y2,2))

(n,m,a,b) = [int(x) for x in input().strip().split(' ')]
A = [int(x) for x in input().strip().split(' ')]
B = [int(x) for x in input().strip().split(' ')]
L = [int(x) for x in input().strip().split(' ')]
i = 0
j = 0
min_path = 0
min_i = 0
min_j = 0
curr_path = 0
flagDec = False
res = {}
while i<m:
	while j<n:
		curr_path = calcPath(0,0,a,A[j]) + calcPath(a,A[j],b,B[i])+L[i]
		if min_path < curr_path and min_path != 0:
			i += 1
			if flagDec:
				j -= 1
				flagDec = False
			break
		min_path = curr_path
		min_i = i+1
		min_j = j+1
		j += 1
		flagDec = True
print(str(min_j)+" "+str(min_i))


# http://codeforces.com/problemset/problem/250/D
# inputFile.readline
from math import sqrt

def calcPath(x1, y1, x2, y2):
	return sqrt(pow(x1-x2,2)+pow(y1-y2,2))

(n,m,a,b) = [int(x) for x in input().strip().split(' ')]
A = [int(x) for x in input().strip().split(' ')]
B = [int(x) for x in input().strip().split(' ')]
L = [int(x) for x in input().strip().split(' ')]
i = 0
j = 0
res = {}
flagDec = False
res = {}
while i<m:
	min_path = 0
	curr_path = 0
	while j<n:
		curr_path = calcPath(0,0,a,A[j]) + calcPath(a,A[j],b,B[i])+L[i]
		if min_path < curr_path and min_path != 0:
			i += 1
			if flagDec:
				j -= 1
				flagDec = False
			break
		min_path = curr_path
		res[min_path] = [j+1,i+1];
		j += 1
		flagDec = True
	if j == n:
		break
min_k = min(res.keys())
print(str(res[min_k][0])+" "+str(res[min_k][1]))


from math import sqrt,fabs

def dist(x1, y1, x2, y2):
    return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2))

def calcOptimumRightPoint(startX, startY):
    l = float("inf")
    idx = -1
    for i in range(len(B)):
        d = dist(startX, startY, b, B[i]) + L[i]
        if d <= l:
            l = d
            idx = i
    return idx

n,m,a,b = [int(x) for x in input().split()]

A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
L = [int(x) for x in input().split()]

optimumRightPoint = calcOptimumRightPoint(0,0)

intersectLeft = (a * B[optimumRightPoint]) / b

l = float("inf")
optimumLeftPoint = -1
for i in range(len(A)):
    if fabs(intersectLeft-A[i]) < l:
        l = fabs(intersectLeft-A[i])
        optimumLeftPoint = i

optimumRightPoint = calcOptimumRightPoint(a, A[optimumLeftPoint])

print(optimumLeftPoint + 1, optimumRightPoint + 1)


# http://codeforces.com/problemset/problem/250/D
from math import sqrt

def calcPath(x1, y1, x2, y2):
	return sqrt(pow(x1-x2,2)+pow(y1-y2,2))

# with open('h.in', 'r') as inputFile, open('h.out', 'w') as outputFile:
(n,m,a,b) = [int(x) for x in input().strip().split(' ')]
A = [int(x) for x in input().strip().split(' ')]
B = [int(x) for x in input().strip().split(' ')]
L = [int(x) for x in input().strip().split(' ')]
# print(n,m,a,b)
# print(A,B,L)
i = 0
res = {}
while i<m:
	min_path = 0
	curr_path = 0
	j = 0
	while j<n:
		curr_path = calcPath(0,0,a,A[j])+ calcPath(a,A[j],b,B[i])+L[i]
		if min_path < curr_path and min_path != 0:
			break
		min_path = curr_path
		res[min_path] = [j+1,i+1];
		j += 1
	i += 1
min_k = min(res.keys())
# print(res)
print(str(res[min_k][0])+" "+str(res[min_k][1]))


# http://codeforces.com/problemset/problem/250/D
from math import sqrt

def calcPath(x1, y1, x2, y2):
	return sqrt(pow(x1-x2,2)+pow(y1-y2,2))

# with open('h.in', 'r') as inputFile, open('h.out', 'w') as outputFile:
(n,m,a,b) = [int(x) for x in input().strip().split(' ')]
A = [int(x) for x in input().strip().split(' ')]
B = [int(x) for x in input().strip().split(' ')]
L = [int(x) for x in input().strip().split(' ')]
# print(n,m,a,b)
# print(A,B,L)
i = 0
j = 0
res = {}
while i<m:
	min_path = 0
	curr_path = 0
	while j<n:
		curr_path = calcPath(0,0,a,A[j]) + calcPath(a,A[j],b,B[i])+L[i]
		if min_path < curr_path and min_path != 0:
			i += 1
			j -= 1
			break
		min_path = curr_path
		res[min_path] = [j+1,i+1];
		# print(res)
		j += 1
min_k = min(res.keys())
# print(res)
print(str(res[min_k][0])+" "+str(res[min_k][1]))


# http://codeforces.com/problemset/problem/250/D
from math import sqrt

def calcPath(x1, y1, x2, y2):
	return sqrt(pow(x1-x2,2)+pow(y1-y2,2))

# with open('h.in', 'r') as inputFile, open('h.out', 'w') as outputFile:
(n,m,a,b) = [int(x) for x in input().strip().split(' ')]
A = [int(x) for x in input().strip().split(' ')]
B = [int(x) for x in input().strip().split(' ')]
L = [int(x) for x in input().strip().split(' ')]
# print(n,m,a,b)
# print(A,B,L)
i = 0
j = 0
res = {}
while i<m:
	min_path = 0
	curr_path = 0
	while j<n:
		curr_path = calcPath(0,0,a,A[j]) + calcPath(a,A[j],b,B[i])+L[i]
		if min_path < curr_path and min_path != 0:
			i += 1
			j -= 1
			break
		min_path = curr_path
		res[min_path] = [j+1,i+1];
		# print(res)
		j += 1
	if j == m:
		break
min_k = min(res.keys())
# print(res)
print(str(res[min_k][0])+" "+str(res[min_k][1]))


# http://codeforces.com/problemset/problem/250/D
from math import sqrt

def calcPath(x1, y1, x2, y2):
	return sqrt(pow(x1-x2,2)+pow(y1-y2,2))

(n,m,a,b) = [int(x) for x in input().strip().split(' ')]
A = [int(x) for x in input().strip().split(' ')]
B = [int(x) for x in input().strip().split(' ')]
L = [int(x) for x in input().strip().split(' ')]
i = 0
j = 0
min_path = 0
min_i = 0
min_j = 0
curr_path = 0
flagDec = False
res = {}
while i<m:
	while j<n:
		curr_path = calcPath(0,0,a,A[j]) + calcPath(a,A[j],b,B[i])+L[i]
		if min_path < curr_path and min_path != 0:
			i += 1
			if flagDec:
				j -= 1
				flagDec = False
			break
		min_path = curr_path
		min_i = i+1
		min_j = j+1
		j += 1
		flagDec = True
	if m == 1:
		break
print(str(min_j)+" "+str(min_i))


# http://codeforces.com/problemset/problem/250/D
from math import sqrt

def calcPath(x1, y1, x2, y2):
	return sqrt(pow(x1-x2,2)+pow(y1-y2,2))

(n,m,a,b) = [int(x) for x in input().strip().split(' ')]
A = [int(x) for x in input().strip().split(' ')]
B = [int(x) for x in input().strip().split(' ')]
L = [int(x) for x in input().strip().split(' ')]
i = 0
j = 0
min_path = 0
min_i = 0
min_j = 0
curr_path = 0
flagDec = False
res = {}
while i<m:
	while j<n:
		curr_path = calcPath(0,0,a,A[j]) + calcPath(a,A[j],b,B[i])+L[i]
		if min_path < curr_path and min_path != 0:
			i += 1
			if flagDec:
				j -= 1
				flagDec = False
			break
		min_path = curr_path
		min_i = i+1
		min_j = j+1
		j += 1
		flagDec = True
	if j == n:
		break
print(str(min_j)+" "+str(min_i))


# http://codeforces.com/problemset/problem/250/D
# inputFile.readline
from math import sqrt

def calcPath(x1, y1, x2, y2):
	return sqrt(pow(x1-x2,2)+pow(y1-y2,2))

(n,m,a,b) = [int(x) for x in input().strip().split(' ')]
A = [int(x) for x in input().strip().split(' ')]
B = [int(x) for x in input().strip().split(' ')]
L = [int(x) for x in input().strip().split(' ')]
i = 0
j = 0
res = {}
flagDec = False
res = {}
if n == 1 and m == 1:
	print("1 1")
else:
	while i<m:
		min_path = 0
		curr_path = 0
		while j<n:
			curr_path = calcPath(0,0,a,A[j]) + calcPath(a,A[j],b,B[i])+L[i]
			if min_path < curr_path and min_path != 0:
				res[min_path] = [j,i+1];
				i += 1
				if flagDec:
					j -= 1
					flagDec = False
				break
			min_path = curr_path

			j += 1
			flagDec = True
		if j == n:
			break
	min_k = min(res.keys())
	print(str(res[min_k][0])+" "+str(res[min_k][1]))


# http://codeforces.com/problemset/problem/250/D
from math import sqrt

def calcPath(x1, y1, x2, y2):
	return sqrt(pow(x1-x2,2)+pow(y1-y2,2))

# with open('h.in', 'r') as inputFile, open('h.out', 'w') as outputFile:
(n,m,a,b) = [int(x) for x in input().strip().split(' ')]
A = [int(x) for x in input().strip().split(' ')]
B = [int(x) for x in input().strip().split(' ')]
L = [int(x) for x in input().strip().split(' ')]
# print(n,m,a,b)
# print(A,B,L)
i = 0
res = {}
while i<m:
	min_path = 0
	curr_path = 0
	j = 0
	while j<n:
		curr_path = calcPath(0,0,a,A[j])+ calcPath(a,A[j],b,B[i])+L[i]
		if min_path < curr_path and min_path != 0:
			break
		min_path = curr_path
		res[min_path] = [i+1,j+1];
		j += 1
	i += 1
min_k = min(res.keys())
# print(res)
print(str(res[min_k][0])+" "+str(res[min_k][1]))


import sys
from itertools import *
from math import *
def solve():
    n,m,leftbank,rightbank = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    l = list(map(int, input().split()))
    smallx = leftbank
    smallxsquared = smallx * smallx
    rightbankminusleftbanksquared = (rightbank -leftbank)*(rightbank - leftbank)
    leftbest, rightbest, distbest = -1, -1, 100000000
    ll = 0
    for i, bcord, length in zip(count(), b, l):
        wanty = bcord * smallx / rightbank
        while ll < n and a[ll] <= wanty: ll+=1
        for pos in range(ll - 1, ll + 1):
            if pos >= 0 and pos < n:
                first = sqrt(smallxsquared + a[pos] * a[pos])
                second = sqrt(rightbankminusleftbanksquared + (bcord - a[pos]) * (bcord - a[pos]))
                totaldist = first + second + length
                if totaldist < distbest:
                    distbest = totaldist
                    leftbest = pos
                    rightbest = i
    print(leftbest + 1, rightbest + 1)

if sys.hexversion == 50594544 : sys.stdin = open("test.txt")
solve()


import sys
from itertools import *
from math import *
def solve():
    n,m,leftbank,rightbank = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    l = list(map(int, input().split()))
    smallx = leftbank
    smallxsquared = smallx * smallx
    rightbankminusleftbanksquared = (rightbank -leftbank)*(rightbank - leftbank)
    leftbest, rightbest, distbest = -1, -1, 100000000
    for i, bcord, length in zip(count(), b, l):
        wanty = bcord * smallx / rightbank
        ll , rr = 0, n - 1
        while ll < rr:
            mm = (ll + rr + 1) // 2
            if a[mm] > wanty: rr = mm - 1
            else: ll = mm
        for pos in range(ll, ll + 2):
            if pos < n:
                first = sqrt(smallxsquared + a[pos] * a[pos])
                second = sqrt(rightbankminusleftbanksquared + (bcord - a[pos]) * (bcord - a[pos]))
                totaldist = first + second + length
                if totaldist < distbest:
                    distbest = totaldist
                    leftbest = pos
                    rightbest = i
    print(leftbest + 1, rightbest + 1)

if sys.hexversion == 50594544 : sys.stdin = open("test.txt")
solve()


import sys
from itertools import *
from math import *
def solve():
    n,m,leftbank,rightbank = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    l = list(map(int, input().split()))
    smallx = leftbank
    smallxsquared = smallx * smallx
    rightbankminusleftbanksquared = (rightbank -leftbank)*(rightbank - leftbank)
    leftbest, rightbest, distbest = -1, -1, 100000000
    ll = 0
    for i, bcord, length in zip(count(), b, l):
        wanty = bcord * smallx / rightbank
        while ll < n and a[ll] <= wanty: ll+=1
        for pos in range(ll - 1, ll + 1):
            if pos < n:
                first = sqrt(smallxsquared + a[pos] * a[pos])
                second = sqrt(rightbankminusleftbanksquared + (bcord - a[pos]) * (bcord - a[pos]))
                totaldist = first + second + length
                if totaldist < distbest:
                    distbest = totaldist
                    leftbest = pos
                    rightbest = i
    print(leftbest + 1, rightbest + 1)

if sys.hexversion == 50594544 : sys.stdin = open("test.txt")
solve()


import sys
from itertools import *
from math import *
def solve():
    n,m,leftbank,rightbank = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    l = list(map(int, input().split()))
    dist = rightbank - leftbank
    smallx = leftbank
    leftbest, rightbest, distbest = -100, -100, 100000000
    for i, bcord, length in zip(count(), b, l):
        wanty = bcord * smallx / dist
        ll , rr = 0, n - 1
        while ll < rr:
            mm = (ll + rr + 1) // 2
            if a[mm] > wanty: rr = mm - 1
            else: ll = mm
        for pos in range(ll - 1, ll + 2):
            if pos >= 0 and pos < n:
                first = sqrt(smallx * smallx + a[pos] * a[pos])
                second = sqrt((dist - smallx)*(dist - smallx) + (bcord - a[pos])*(bcord - a[pos]))
                totaldist = first + second + length
                if totaldist < distbest:
                    distbest = totaldist
                    leftbest = pos
                    rightbest = i
    print(leftbest + 1, rightbest + 1)

if sys.hexversion == 50594544 : sys.stdin = open("test.txt")
solve()


import sys
from itertools import *
from math import *
def solve():
    n,m,leftbank,rightbank = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    l = list(map(int, input().split()))
    dist = rightbank - leftbank
    smallx = leftbank
    leftbest, rightbest, distbest = -100, -100, 100000000
    for i, bcord, length in zip(count(), b, l):
        wanty = bcord * smallx / rightbank
        ll , rr = 0, n - 1
        while ll < rr:
            mm = (ll + rr + 1) // 2
            if a[mm] > wanty: rr = mm - 1
            else: ll = mm
        for pos in range(ll - 1, ll + 2):
            if pos >= 0 and pos < n:
                first = sqrt(smallx * smallx + a[pos] * a[pos])
                second = sqrt((dist - smallx)*(dist - smallx) + (bcord - a[pos])*(bcord - a[pos]))
                totaldist = first + second + length
                if totaldist < distbest:
                    distbest = totaldist
                    leftbest = pos
                    rightbest = i
    print(leftbest + 1, rightbest + 1)

if sys.hexversion == 50594544 : sys.stdin = open("test.txt")
solve()


import sys
from itertools import *
from math import *
def solve():
    n,m,leftbank,rightbank = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    l = list(map(int, input().split()))
    smallx = leftbank
    leftbest, rightbest, distbest = -100, -100, 100000000
    for i, bcord, length in zip(count(), b, l):
        wanty = bcord * smallx / rightbank
        ll , rr = 0, n - 1
        while ll < rr:
            mm = (ll + rr + 1) // 2
            if a[mm] > wanty: rr = mm - 1
            else: ll = mm
        for pos in range(ll - 1, ll + 2):
            if pos >= 0 and pos < n:
                first = sqrt(smallx * smallx + a[pos] * a[pos])
                second = sqrt((rightbank -leftbank)*(rightbank - leftbank) + (bcord - a[pos])*(bcord - a[pos]))
                totaldist = first + second + length
                if totaldist < distbest:
                    distbest = totaldist
                    leftbest = pos
                    rightbest = i
    print(leftbest + 1, rightbest + 1)

if sys.hexversion == 50594544 : sys.stdin = open("test.txt")
solve()


import sys
from itertools import *
from math import *
def solve():
    n,m,leftbank,rightbank = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    l = list(map(int, input().split()))
    dist = rightbank - leftbank
    smallx = leftbank
    leftbest, rightbest, distbest = -100, -100, 100000000
    for i, bcord, length in zip(count(), b, l):
        wanty = bcord * smallx / rightbank
        ll , rr = 0, n - 1
        while ll < rr:
            mm = (ll + rr + 1) // 2
            if a[mm] > wanty: rr = mm - 1
            else: ll = mm
        for pos in range(ll - 3, ll + 4):
            if pos >= 0 and pos < n:
                first = sqrt(smallx * smallx + a[pos] * a[pos])
                second = sqrt((dist - smallx)*(dist - smallx) + (bcord - a[pos])*(bcord - a[pos]))
                totaldist = first + second + length
                if totaldist < distbest:
                    distbest = totaldist
                    leftbest = pos
                    rightbest = i
    print(leftbest + 1, rightbest + 1)

if sys.hexversion == 50594544 : sys.stdin = open("test.txt")
solve()


import sys
from itertools import *
from math import *
def solve():
    n,m,leftbank,rightbank = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    l = list(map(int, input().split()))
    dist = rightbank - leftbank
    smallx = leftbank
    leftbest, rightbest, distbest = -1, -1, 100000000
    for righty, bcord, length in zip(count(), b, l):
        wanty = bcord * smallx / dist
        ll , rr = 0, n - 1
        while ll < rr:
            mm = (ll + rr) // 2
            if a[mm] > wanty: rr = mm - 1
            else: ll = mm + 1
        for pos in range(ll - 1, ll + 2):
            if pos > 0 and pos < n:
                first = sqrt(smallx * smallx + a[pos] * a[pos])
                second = sqrt((dist - smallx)*(dist - smallx) + (righty - a[pos])*(righty - a[pos]))
                totaldist = first + second + length
                if totaldist < distbest:
                    distbest = totaldist
                    leftbest = pos
                    rightbest = righty
    print(leftbest + 1, rightbest + 1)

if sys.hexversion == 50594544 : sys.stdin = open("test.txt")
solve()


import sys
from itertools import *
from math import *
def solve():
    n,m,leftbank,rightbank = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    l = list(map(int, input().split()))
    dist = rightbank - leftbank
    smallx = leftbank
    leftbest, rightbest, distbest = -100, -100, 100000000
    for i, bcord, length in zip(count(), b, l):
        wanty = bcord * smallx / dist
        ll , rr = 0, n - 1
        while ll < rr:
            mm = (ll + rr) // 2
            if a[mm] > wanty: rr = mm - 1
            else: ll = mm + 1
        for pos in range(ll - 1, ll + 2):
            if pos >= 0 and pos < n:
                first = sqrt(smallx * smallx + a[pos] * a[pos])
                second = sqrt((dist - smallx)*(dist - smallx) + (bcord - a[pos])*(bcord - a[pos]))
                totaldist = first + second + length
                if totaldist < distbest:
                    distbest = totaldist
                    leftbest = pos
                    rightbest = i
    print(leftbest + 1, rightbest + 1)

if sys.hexversion == 50594544 : sys.stdin = open("test.txt")
solve()


# http://codeforces.com/problemset/problem/250/D
# inputFile.readline
from math import sqrt

def calcPath(x1, y1, x2, y2):
    return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2))

# with open('h.in', 'r') as inputFile, open('h.out', 'w') as outputFile:
(n, m, a, b) = [int(x) for x in input().strip().split(' ')]
A = [int(x) for x in input().strip().split(' ')]
B = [int(x) for x in input().strip().split(' ')]
L = [int(x) for x in input().strip().split(' ')]
# print(n,m,a,b)
# print(A,B,L)
i = 0
j = 0
min_path = 0
min_i = 0
min_j = 0
# curr_path = 0
flagDec = False
if n == 1 and m == 1:
    print("1 1")
else:
    while i < m:
        c_min_path = 0
        curr_path = 0
        while j < n:
            curr_path = calcPath(0, 0, a, A[j]) + calcPath(a, A[j], b, B[i]) + L[i]
            if c_min_path < curr_path and c_min_path != 0:
                # res[min_path] = [j, i + 1]
                if c_min_path < min_path:
                    min_path = c_min_path
                    min_i = i + 1
                    min_j = j
                i += 1
                if flagDec:
                    j -= 1
                    flagDec = False
                # print(j,i,curr_path)
                break
            c_min_path = curr_path

            # print(res)
            # min_i = i+1
            # min_j = j+1
            # print(min_j,min_i,min_path)
            j += 1
            flagDec = True
        if j == n:
            break
    # print(str(min_j)+" "+str(min_i))
    # print(res)
    print(str(min_j) + " " + str(min_i))


__author__ = 'Michael Ilyin'

import math

# debug = True
debug = False

def dist(x1, y1, x2, y2):
    return math.sqrt(math.pow(math.fabs(x1 - x2), 2) + math.pow(math.fabs(y1 - y2), 2))

def get_y(x1, y1, x2, y2, x):
    return (((x - x1) * (y2 - y1)) / (x2 - x1)) + y1

if debug:
    with open("input.txt", "r") as inp:
        firstLine = inp.readline()
        secondLine = inp.readline()
        thirdLine = inp.readline()
        fourthLine = inp.readline()
else:
    firstLine = input()
    secondLine = input()
    thirdLine = input()
    fourthLine = input()

first = firstLine.split()
n = float(first[0])
m = float(first[1])
a = float(first[2])
b = float(first[3])

A = [float(x) for x in secondLine.split()]
B = [float(x) for x in thirdLine.split()]
L = [float(x) for x in fourthLine.split()]

if debug:
    print(A)
    print(B)
    print(L)

optimalLen = float("inf")
optimalBIdx = -1
for i, bi in enumerate(B):
    d = dist(0, 0, b, bi) + L[i]
    if d <= optimalLen:
        optimalLen = d
        optimalBIdx = i

if debug:
    print(optimalBIdx + 1, optimalLen)

intersectY = get_y(0, 0, b, B[optimalBIdx], a)

if debug:
    print(intersectY)

pointDist = float("inf")
optimalAIdx = -1
for i, ai in enumerate(A):
    d = dist(a, ai, a, intersectY)
    if d < pointDist:
        pointDist = d
        optimalAIdx = i

if debug:
    print(optimalAIdx + 1, pointDist)

optimalLen = float("inf")
optimalBIdx = -1
for i, bi in enumerate(B):
    d = dist(a, A[optimalAIdx], b, bi) + L[i]
    if d <= optimalLen:
        optimalLen = d
        optimalBIdx = i

print(optimalAIdx + 1, optimalBIdx + 1)


# http://codeforces.com/problemset/problem/250/D
# inputFile.readline
from math import sqrt

def calcPath(x1, y1, x2, y2):
    return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2))

# with open('h.in', 'r') as inputFile, open('h.out', 'w') as outputFile:
(n, m, a, b) = [int(x) for x in input().strip().split(' ')]
A = [int(x) for x in input().strip().split(' ')]
B = [int(x) for x in input().strip().split(' ')]
L = [int(x) for x in input().strip().split(' ')]
# print(n,m,a,b)
# print(A,B,L)
i = 0
j = 0
min_path = float("inf")
min_i = 0
min_j = 0
# curr_path = 0
flagDec = False
if n == 1 and m == 1:
    print("1 1")
else:
    while i < m:
        c_min_path = float("-inf")
        curr_path = float("inf")
        while j < n:
            curr_path = calcPath(0, 0, a, A[j]) + calcPath(a, A[j], b, B[i]) + L[i]
            if c_min_path < curr_path and c_min_path != 0:
                # res[min_path] = [j, i + 1]
                if c_min_path < min_path:
                    min_path = c_min_path
                    min_i = i + 1
                    min_j = j
                i += 1
                if flagDec:
                    j -= 1
                    flagDec = False
                # print(j,i,curr_path)
                break
            c_min_path = curr_path

            # print(res)
            # min_i = i+1
            # min_j = j+1
            # print(min_j,min_i,min_path)
            j += 1
            flagDec = True
        if j == n:
            break
    # print(str(min_j)+" "+str(min_i))
    # print(res)
    print(str(min_j) + " " + str(min_i))


__author__ = 'Michael Ilyin'

import math

# debug = True
debug = False

def dist(x1, y1, x2, y2):
    return math.sqrt(math.pow(x1 - x2, 2) + math.pow(y1 - y2, 2))

def get_y(x1, y1, x2, y2, x):
    return (((x - x1) * (y2 - y1)) / (x2 - x1)) + y1

if debug:
    with open("input.txt", "r") as inp:
        firstLine = inp.readline()
        secondLine = inp.readline()
        thirdLine = inp.readline()
        fourthLine = inp.readline()
else:
    firstLine = input()
    secondLine = input()
    thirdLine = input()
    fourthLine = input()

first = firstLine.split()
n = float(first[0])
m = float(first[1])
a = float(first[2])
b = float(first[3])

A = [float(x) for x in secondLine.split()]
B = [float(x) for x in thirdLine.split()]
L = [float(x) for x in fourthLine.split()]

if debug:
    print(A)
    print(B)
    print(L)

optimalLen = float("inf")
optimalBIdx = -1
for i, bi in enumerate(B):
    d = dist(0, 0, b, bi) + L[i]
    if d <= optimalLen:
        optimalLen = d
        optimalBIdx = i

if debug:
    print(optimalBIdx + 1, optimalLen)

intersectY = get_y(0, 0, b, B[optimalBIdx], a)

if debug:
    print(intersectY)

pointDist = float("inf")
optimalAIdx = -1
for i, ai in enumerate(A):
    d = dist(a, ai, a, intersectY)
    if d < pointDist:
        pointDist = d
        optimalAIdx = i

if debug:
    print(optimalAIdx + 1, pointDist)

print(optimalAIdx + 1, optimalBIdx + 1)


__author__ = 'Michael Ilyin'

import math

# debug = True
debug = False

def dist(x1, y1, x2, y2):
    return math.sqrt(math.pow(math.fabs(x1 - x2), 2) + math.pow(math.fabs(y1 - y2), 2))

def get_y(x1, y1, x2, y2, x):
    return (((x - x1) * (y2 - y1)) / (x2 - x1)) + y1

if debug:
    with open("input.txt", "r") as inp:
        firstLine = inp.readline()
        secondLine = inp.readline()
        thirdLine = inp.readline()
        fourthLine = inp.readline()
else:
    firstLine = input()
    secondLine = input()
    thirdLine = input()
    fourthLine = input()

first = firstLine.split()
n = float(first[0])
m = float(first[1])
a = float(first[2])
b = float(first[3])

A = [float(x) for x in secondLine.split()]
B = [float(x) for x in thirdLine.split()]
L = [float(x) for x in fourthLine.split()]

if debug:
    print(A)
    print(B)
    print(L)

optimalLen = float("inf")
optimalBIdx = -1
for i, bi in enumerate(B):
    d = dist(0, 0, b, bi) + L[i]
    if d <= optimalLen:
        optimalLen = d
        optimalBIdx = i

if debug:
    print(optimalBIdx + 1, optimalLen)

intersectY = get_y(0, 0, b, B[optimalBIdx], a)

if debug:
    print(intersectY)

pointDist = float("inf")
optimalAIdx = -1
for i, ai in enumerate(A):
    d = dist(a, ai, a, intersectY)
    if d < pointDist:
        pointDist = d
        optimalAIdx = i

if debug:
    print(optimalAIdx + 1, pointDist)

print(optimalAIdx + 1, optimalBIdx + 1)


# http://codeforces.com/problemset/problem/250/D
# inputFile.readline
from math import sqrt

def calcPath(x1, y1, x2, y2):
    return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2))

# with open('h.in', 'r') as inputFile, open('h.out', 'w') as outputFile:
(n, m, a, b) = [int(x) for x in input().strip().split(' ')]
A = [int(x) for x in input().strip().split(' ')]
B = [int(x) for x in input().strip().split(' ')]
L = [int(x) for x in input().strip().split(' ')]
# print(n,m,a,b)
# print(A,B,L)
i = 0
j = 0
min_path = float("inf")
min_i = 0
min_j = 0
# curr_path = 0
flagDec = False
if n == 1 and m == 1:
    print("1 1")
else:
    while i < m:
        c_min_path = 0
        curr_path = 0
        while j < n:
            curr_path = calcPath(0, 0, a, A[j]) + calcPath(a, A[j], b, B[i]) + L[i]
            if c_min_path < curr_path and c_min_path != 0:
                # res[min_path] = [j, i + 1]
                if c_min_path < min_path:
                    min_path = c_min_path
                    min_i = i + 1
                    min_j = j
                i += 1
                if flagDec:
                    j -= 1
                    flagDec = False
                # print(j,i,curr_path)
                break
            c_min_path = curr_path

            # print(res)
            # min_i = i+1
            # min_j = j+1
            # print(min_j,min_i,min_path)
            j += 1
            flagDec = True
        if j == n:
            break
    # print(str(min_j)+" "+str(min_i))
    # print(res)
    print(str(min_j) + " " + str(min_i))


__author__ = 'Michael Ilyin'

import math

# debug = True
debug = False

def dist(x1, y1, x2, y2):
    return math.sqrt(math.pow(x1 - x2, 2) + math.pow(y1 - y2, 2))

def get_y(x1, y1, x2, y2, x):
    return (((x - x1) * (y2 - y1)) / (x2 - x1)) + y1

if debug:
    with open("input.txt", "r") as inp:
        firstLine = inp.readline()
        secondLine = inp.readline()
        thirdLine = inp.readline()
        fourthLine = inp.readline()
else:
    firstLine = input()
    secondLine = input()
    thirdLine = input()
    fourthLine = input()

first = firstLine.split()
n = int(first[0])
m = int(first[1])
a = int(first[2])
b = int(first[3])

A = [int(x) for x in secondLine.split()]
B = [int(x) for x in thirdLine.split()]
L = [int(x) for x in fourthLine.split()]

optimalLen = float("inf")
optimalBIdx = -1
for i, bi in enumerate(B):
    d = dist(0, 0, b, bi) + L[i]
    if d < optimalLen:
        optimalLen = d
        optimalBIdx = i

if debug:
    print(optimalBIdx + 1, optimalLen)

intersectY = get_y(0, 0, b, B[optimalBIdx], a)

if debug:
    print(intersectY)

pointDist = float("inf")
optimalAIdx = -1
for i, ai in enumerate(A):
    d = dist(a, ai, a, intersectY)
    if d < pointDist:
        pointDist = d
        optimalAIdx = i

if debug:
    print(optimalAIdx + 1, pointDist)

print(optimalAIdx + 1, optimalBIdx + 1)


__author__ = 'Michael Ilyin'

import math

# debug = True
debug = False

def dist(x1, y1, x2, y2):
    return math.sqrt(math.pow(x1 - x2, 2) + math.pow(y1 - y2, 2))

def get_y(x1, y1, x2, y2, x):
    return (((x - x1) * (y2 - y1)) / (x2 - x1)) + y1

if debug:
    with open("input.txt", "r") as inp:
        firstLine = inp.readline()
        secondLine = inp.readline()
        thirdLine = inp.readline()
        fourthLine = inp.readline()
else:
    firstLine = input()
    secondLine = input()
    thirdLine = input()
    fourthLine = input()

first = firstLine.split()
n = int(first[0])
m = int(first[1])
a = int(first[2])
b = int(first[3])

A = [int(x) for x in secondLine.split()]
B = [int(x) for x in thirdLine.split()]
L = [float(x) for x in fourthLine.split()]

optimalLen = float("inf")
optimalBIdx = -1
for i, bi in enumerate(B):
    d = dist(0, 0, b, bi) + L[i]
    if d <= optimalLen:
        optimalLen = d
        optimalBIdx = i

if debug:
    print(optimalBIdx + 1, optimalLen)

intersectY = get_y(0, 0, b, B[optimalBIdx], a)

if debug:
    print(intersectY)

pointDist = float("inf")
optimalAIdx = -1
for i, ai in enumerate(A):
    d = dist(a, ai, a, intersectY)
    if d < pointDist:
        pointDist = d
        optimalAIdx = i

if debug:
    print(optimalAIdx + 1, pointDist)

print(optimalAIdx + 1, optimalBIdx + 1)


# http://codeforces.com/problemset/problem/250/D
# inputFile.readline
from math import sqrt

def calcPath(x1, y1, x2, y2):
    return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2))

# with open('h.in', 'r') as inputFile, open('h.out', 'w') as outputFile:
(n, m, a, b) = [int(x) for x in input().strip().split(' ')]
A = [int(x) for x in input().strip().split(' ')]
B = [int(x) for x in input().strip().split(' ')]
L = [int(x) for x in input().strip().split(' ')]
# print(n,m,a,b)
# print(A,B,L)
i = 0
j = 0
min_path = 0
min_i = 0
min_j = 0
# curr_path = 0
flagDec = False
if n == 1 and m == 1:
    print("1 1")
else:
    while i < m:
        c_min_path = 0
        curr_path = 0
        while j < n:
            curr_path = calcPath(0, 0, a, A[j]) + calcPath(a, A[j], b, B[i]) + L[i]
            if c_min_path < curr_path and c_min_path != 0:
                # res[min_path] = [j, i + 1]
                min_path = c_min_path
                min_i = i + 1
                min_j = j
                i += 1
                if flagDec:
                    j -= 1
                    flagDec = False
                # print(j,i,curr_path)
                break
            c_min_path = curr_path

            # print(res)
            # min_i = i+1
            # min_j = j+1
            # print(min_j,min_i,min_path)
            j += 1
            flagDec = True
        if j == n:
            break
    # print(str(min_j)+" "+str(min_i))
    # print(res)
    print(str(min_j) + " " + str(min_i))


# http://codeforces.com/problemset/problem/250/D
# inputFile.readline
from math import sqrt

def calcPath(x1, y1, x2, y2):
    return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2))

# with open('h.in', 'r') as inputFile, open('h.out', 'w') as outputFile:
(n, m, a, b) = [int(x) for x in input().strip().split(' ')]
A = [int(x) for x in input().strip().split(' ')]
B = [int(x) for x in input().strip().split(' ')]
L = [int(x) for x in input().strip().split(' ')]
# print(n,m,a,b)
# print(A,B,L)
i = 0
j = 0
min_path = 0
min_i = 0
min_j = 0
# curr_path = 0
flagDec = False
if n == 1 and m == 1:
    print("1 1")
else:
    while i < m:
        c_min_path = 0
        curr_path = 0
        while j < n:
            curr_path = calcPath(0, 0, a, A[j]) + calcPath(a, A[j], b, B[i]) + L[i]
            if c_min_path < curr_path and c_min_path != 0:
                # res[min_path] = [j, i + 1]
                min_path = c_min_path
                min_i = i + 1
                min_j = j
                i += 1
                if flagDec:
                    j -= 1
                    flagDec = False
                # print(j,i,curr_path)
                break
            c_min_path = curr_path

            # print(res)
            # min_i = i+1
            # min_j = j+1
            # print(min_j,min_i,min_path)
            j += 1
            flagDec = True
        if j == n:
            break
    # print(str(min_j)+" "+str(min_i))
    # print(res)
    print(str(min_i) + " " + str(min_j))


__author__ = 'Michael Ilyin'

import math

# debug = True
debug = False

def dist(x1, y1, x2, y2):
    return math.sqrt(math.pow(x1 - x2, 2) + math.pow(y1 - y2, 2))

def get_y(x1, y1, x2, y2, x):
    return (((x - x1) * (y2 - y1)) / (x2 - x1)) + y1

if debug:
    with open("input.txt", "r") as inp:
        firstLine = inp.readline()
        secondLine = inp.readline()
        thirdLine = inp.readline()
        fourthLine = inp.readline()
else:
    firstLine = input()
    secondLine = input()
    thirdLine = input()
    fourthLine = input()

first = firstLine.split()
n = int(first[0])
m = int(first[1])
a = int(first[2])
b = int(first[3])

A = [int(x) for x in secondLine.split()]
B = [int(x) for x in thirdLine.split()]
L = [int(x) for x in fourthLine.split()]

eps = 10**-7
optimalLen = float("inf")
optimalBIdx = -1
for i, bi in enumerate(B):
    d = dist(0, 0, b, bi) + L[i]
    if d <= optimalLen + eps:
        optimalLen = d
        optimalBIdx = i

if debug:
    print(optimalBIdx + 1, optimalLen)

intersectY = get_y(0, 0, b, B[optimalBIdx], a)

if debug:
    print(intersectY)

pointDist = float("inf")
optimalAIdx = -1
for i, ai in enumerate(A):
    d = dist(a, ai, a, intersectY)
    if d < pointDist:
        pointDist = d
        optimalAIdx = i

if debug:
    print(optimalAIdx + 1, pointDist)

print(optimalAIdx + 1, optimalBIdx + 1)


__author__ = 'Michael Ilyin'

import math

# debug = True
debug = False

def dist(x1, y1, x2, y2):
    return math.sqrt(math.pow(x1 - x2, 2) + math.pow(y1 - y2, 2))

def get_y(x1, y1, x2, y2, x):
    return (((x - x1) * (y2 - y1)) / (x2 - x1)) + y1

if debug:
    with open("input.txt", "r") as inp:
        firstLine = inp.readline()
        secondLine = inp.readline()
        thirdLine = inp.readline()
        fourthLine = inp.readline()
else:
    firstLine = input()
    secondLine = input()
    thirdLine = input()
    fourthLine = input()

first = firstLine.split()
n = int(first[0])
m = int(first[1])
a = int(first[2])
b = int(first[3])

A = [int(x) for x in secondLine.split()]
B = [int(x) for x in thirdLine.split()]
L = [int(x) for x in fourthLine.split()]

optimalLen = float("inf")
optimalBIdx = -1
for i, bi in enumerate(B):
    d = dist(0, 0, b, bi) + L[i]
    if d <= optimalLen:
        optimalLen = d
        optimalBIdx = i

if debug:
    print(optimalBIdx + 1, optimalLen)

intersectY = get_y(0, 0, b, B[optimalBIdx], a)

if debug:
    print(intersectY)

pointDist = float("inf")
optimalAIdx = -1
for i, ai in enumerate(A):
    d = dist(a, ai, a, intersectY)
    if d < pointDist:
        pointDist = d
        optimalAIdx = i

if debug:
    print(optimalAIdx + 1, pointDist)

print(optimalAIdx + 1, optimalBIdx + 1)


from bisect import *
R=lambda:map(int,raw_input().split())
n,m,a,b=R()
y=R()
v=R()
s=R()
l,r,t=0,0,10**10
for i in range(m):
  j=max(0,bisect(y,v[i]*a/b)-1)
  k=(a*a+y[j]**2)**.5+((b-a)**2+(v[i]-y[j])**2)**.5+s[i]
  if k<t:l,r,t=j,i,k
print l+1,r+1


#include <bits/stdc++.h>
using namespace std;
int main(){
    int t, ans, m, s;
    cin >> t;
    while(t--){
    int a, b, i;
    cin >> a >> b;
    if(a<b)swap(a, b);
    cout << min((a+b)/3, b) << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    int t, eme, m, s;
    cin >> t;
    while(t--){
    int a, b, i;
    cin >> a >> b;
    /*if(a>b){
        m= a/2;
        s = m - b;

        for(int s>=2; ; s++)
        cout << s << endl;
        break;
    }*/
    if(b>a){
        int q, n;
        n = b/2;
        q = n - a;
        for(int q=2; q<n; q++)
        cout << q << endl;
        /*else
        cout << q+1;*/

    }

    return 0;
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long t;
    cin>>t;
    while (t--)
    {
        long long a, b;
        cin>>a>>b;
        if (a < b)
        {
            a += b;
            b = a - b;
            a = a - b;
        }
        cout<<min((a+b)/3, b)<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define pi 3.1415926535897932384626433832795
#define f(i, a, b) for (ll i = a; i < b; i++)
#define fb(i, a, b) for (ll i = a; i > b; i--)
#define input(DT, var, n) ll n; cin>>n; DT var[n]; f(i, 0, n) cin>>var[i];
#define print(var, n) f(i, 0, n) cout<<var[i]<<" ";
#define all(X) X.begin(), X.end()

void YN (bool x)
{
	if (x) cout<<"YES";
	else cout<<"NO";
}
ll gcd (ll a, ll b)
{
	if (b == 0) return a;
	return gcd (b, a%b);
}
void swap (ll &a, ll &b)
{
	ll t = a;
	a = b;
	b = t;
}

// ----- code here ----- //
void solve()
{
	ll a, b, c = 0, cpre = -1;
	cin>>a>>b;
	while (c != cpre && a && b)
	{
		cpre = c;
		if (a >= 2*b)
		{
			ll d = min(a/2, b);
			a -= 2*d;
			b -= d;
			c += d;
		}
		else if (b >= 2*a)
		{
			ll d = min(a, b/2);
			a -= d;
			b -= 2*d;
			c += d;
		}
		else if (a == b)
		{
			ll d = a/3;
			c += 2*d;
			a -= 3*d;
			b -= 3*d;
		}
		else if (a > b && a > 1)
		{
			a -= 2;
			b--;
			c++;
		}
		else if (b > 1)
		{
			a--;
			b -= 2;
			c++;
		}
	}
	cout<<c;
}
// ----- code here ----- //

signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("INPUT.txt", "r", stdin);
    // for writing output to output.txt
    freopen("OUTPUT.txt", "w", stdout);
    #endif
	ll t;
	cin>>t;
	while(t--)
	{
		solve();
		cout<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a, b;
    cin>>a>>b;
    if (a < b)
    {
        a += b;
        b = a - b;
        a = a - b;
    }
    cout<<min((a+b)/3, b);
}


#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define pi 3.1415926535897932384626433832795
#define f(i, a, b) for (ll i = a; i < b; i++)
#define fb(i, a, b) for (ll i = a; i > b; i--)
#define input(DT, var, n) ll n; cin>>n; DT var[n]; f(i, 0, n) cin>>var[i];
#define print(var, n) f(i, 0, n) cout<<var[i]<<" ";
#define all(X) X.begin(), X.end()

void YN (bool x)
{
	if (x) cout<<"YES";
	else cout<<"NO";
}
ll gcd (ll a, ll b)
{
	if (b == 0) return a;
	return gcd (b, a%b);
}
void swap (ll &a, ll &b)
{
	ll t = a;
	a = b;
	b = t;
}

// ----- code here ----- //
void solve()
{
	ll a, b, c = 0, cpre = -1;
	cin>>a>>b;
	while (c != cpre && a && b)
	{
		cpre = c;
		if (a >= 2*b)
		{
			ll d = min(a/2, b);
			a -= 2*d;
			b -= d;
			c += d;
		}
		else if (b >= 2*a)
		{
			ll d = min(a, b/2);
			a -= d;
			b -= 2*d;
			c += d;
		}
		else if (a == b && a > 2)
		{
			ll d = a/3;
			c += 2*d;
			a -= 3*d;
			b -= 3*d;
		}
		else if (a > b && a > 1)
		{
			ll x = min(a - b, b);
			a -= 2 * x;
			b -= x;
			c += x;
		}
		else if (b > 1)
		{
			ll x = min(b - a, a);
			a -= x;
			b -= 2*x;
			c += x;
		}
	}
	cout<<c;
}
// ----- code here ----- //

signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("INPUT.txt", "r", stdin);
    // for writing output to output.txt
    freopen("OUTPUT.txt", "w", stdout);
    #endif
	ll t;
	cin>>t;
	while(t--)
	{
		solve();
		cout<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define pi 3.1415926535897932384626433832795
#define f(i, a, b) for (ll i = a; i < b; i++)
#define fb(i, a, b) for (ll i = a; i > b; i--)
#define input(DT, var, n) ll n; cin>>n; DT var[n]; f(i, 0, n) cin>>var[i];
#define print(var, n) f(i, 0, n) cout<<var[i]<<" ";
#define all(X) X.begin(), X.end()

void YN (bool x)
{
	if (x) cout<<"YES";
	else cout<<"NO";
}
ll gcd (ll a, ll b)
{
	if (b == 0) return a;
	return gcd (b, a%b);
}
void swap (ll &a, ll &b)
{
	ll t = a;
	a = b;
	b = t;
}

// ----- code here ----- //
void solve()
{
	ll a, b, c = 0, cpre = -1;
	cin>>a>>b;
	while (c != cpre && a && b)
	{
		cpre = c;
		if (a >= 2*b)
		{
			ll d = min(a/2, b);
			a -= 2*d;
			b -= d;
			c += d;
		}
		else if (b >= 2*a)
		{
			ll d = min(a, b/2);
			a -= d;
			b -= 2*d;
			c += d;
		}
		else if (a == b && a > 2)
		{
			ll d = a/3;
			c += 2*d;
			a -= 3*d;
			b -= 3*d;
		}
		else if (a > b && a > 1)
		{
			ll x = a - b;
			a -= 2 * x;
			b -= x;
			c += x;
		}
		else if (b > 1)
		{
			ll x = b - a;
			a -= x;
			b -= 2*x;
			c += x;
		}
	}
	cout<<c;
}
// ----- code here ----- //

signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("INPUT.txt", "r", stdin);
    // for writing output to output.txt
    freopen("OUTPUT.txt", "w", stdout);
    #endif
	ll t;
	cin>>t;
	while(t--)
	{
		solve();
		cout<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define pi 3.1415926535897932384626433832795
#define f(i, a, b) for (ll i = a; i < b; i++)
#define fb(i, a, b) for (ll i = a; i > b; i--)
#define input(DT, var, n) ll n; cin>>n; DT var[n]; f(i, 0, n) cin>>var[i];
#define print(var, n) f(i, 0, n) cout<<var[i]<<" ";
#define all(X) X.begin(), X.end()

void YN (bool x)
{
	if (x) cout<<"YES";
	else cout<<"NO";
}
ll gcd (ll a, ll b)
{
	if (b == 0) return a;
	return gcd (b, a%b);
}
void swap (ll &a, ll &b)
{
	ll t = a;
	a = b;
	b = t;
}

// ----- code here ----- //
void solve()
{
	ll a, b, c = 0, cpre = -1;
	cin>>a>>b;
	while (c != cpre && a && b)
	{
		cpre = c;
		if (a >= 2*b)
		{
			ll d = min(a/2, b);
			a -= 2*d;
			b -= d;
			c += d;
		}
		else if (b >= 2*a)
		{
			ll d = min(a, b/2);
			a -= d;
			b -= 2*d;
			c += d;
		}
		else
		{
			if (a > b && a > 1)
			{
				a -= 2;
				b--;
				c++;
			}
			else if (b > 1)
			{
				a--;
				b -= 2;
				c++;
			}
		}
	}
	cout<<c;
}
// ----- code here ----- //

signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("INPUT.txt", "r", stdin);
    // for writing output to output.txt
    freopen("OUTPUT.txt", "w", stdout);
    #endif
	ll t;
	cin>>t;
	while(t--)
	{
		solve();
		cout<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define pi 3.1415926535897932384626433832795
#define f(i, a, b) for (ll i = a; i < b; i++)
#define fb(i, a, b) for (ll i = a; i > b; i--)
#define input(DT, var, n) ll n; cin>>n; DT var[n]; f(i, 0, n) cin>>var[i];
#define print(var, n) f(i, 0, n) cout<<var[i]<<" ";
#define all(X) X.begin(), X.end()

void YN (bool x)
{
	if (x) cout<<"YES";
	else cout<<"NO";
}
ll gcd (ll a, ll b)
{
	if (b == 0) return a;
	return gcd (b, a%b);
}
void swap (ll &a, ll &b)
{
	ll t = a;
	a = b;
	b = t;
}

// ----- code here ----- //
void solve()
{
	ll a, b, c = 0, cpre = -1;
	cin>>a>>b;
	while (c != cpre && a && b)
	{
		cpre = c;
		if (a >= 2*b)
		{
			ll d = min(a/2, b);
			a -= 2*d;
			b -= d;
			c += d;
		}
		else if (b >= 2*a)
		{
			ll d = min(a, b/2);
			a -= d;
			b -= 2*d;
			c += d;
		}
		else if (a == b && a > 2)
		{
			ll d = a/3;
			c += 2*d;
			a -= 3*d;
			b -= 3*d;
		}
		else if (a > b && a > 1)
		{
			a -= 2;
			b--;
			c++;
		}
		else if (b > 1)
		{
			a--;
			b -= 2;
			c++;
		}
	}
	cout<<c;
}
// ----- code here ----- //

signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("INPUT.txt", "r", stdin);
    // for writing output to output.txt
    freopen("OUTPUT.txt", "w", stdout);
    #endif
	ll t;
	cin>>t;
	while(t--)
	{
		solve();
		cout<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define pi 3.1415926535897932384626433832795
#define f(i, a, b) for (ll i = a; i < b; i++)
#define fb(i, a, b) for (ll i = a; i > b; i--)
#define input(DT, var, n) ll n; cin>>n; DT var[n]; f(i, 0, n) cin>>var[i];
#define print(var, n) f(i, 0, n) cout<<var[i]<<" ";
#define all(X) X.begin(), X.end()

void YN (bool x)
{
	if (x) cout<<"YES";
	else cout<<"NO";
}
ll gcd (ll a, ll b)
{
	if (b == 0) return a;
	return gcd (b, a%b);
}
void swap (ll &a, ll &b)
{
	ll t = a;
	a = b;
	b = t;
}

// ----- code here ----- //
void solve()
{
	ll a, b, c = 0, cpre = -1;
	cin>>a>>b;
	while (c != cpre && a && b)
	{
		cpre = c;
		if (a == 2 && b == 2)
		{
			a = 0;
			b = 1;
			c++;
		}
		else if (a >= 2*b)
		{
			ll d = min(a/2, b);
			a -= 2*d;
			b -= d;
			c += d;
		}
		else if (b >= 2*a)
		{
			ll d = min(a, b/2);
			a -= d;
			b -= 2*d;
			c += d;
		}
		else if (a > b)
		{
			ll d = a - b;
			ll x = (b - d)/3;
			a -= x*3;
			b -= x*3;
			c += x*2;
		}
		else
		{
			ll d = b - a;
			ll x = (a - d)/3;
			a -= x*3;
			b -= x*3;
			c += x*2;
		}
	}
	cout<<c;
}
// ----- code here ----- //

signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("INPUT.txt", "r", stdin);
    // for writing output to output.txt
    freopen("OUTPUT.txt", "w", stdout);
    #endif
	ll t;
	cin>>t;
	while(t--)
	{
		solve();
		cout<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define pi 3.1415926535897932384626433832795
#define f(i, a, b) for (ll i = a; i < b; i++)
#define fb(i, a, b) for (ll i = a; i > b; i--)
#define input(DT, var, n) ll n; cin>>n; DT var[n]; f(i, 0, n) cin>>var[i];
#define print(var, n) f(i, 0, n) cout<<var[i]<<" ";
#define all(X) X.begin(), X.end()

void YN (bool x)
{
	if (x) cout<<"YES";
	else cout<<"NO";
}
ll gcd (ll a, ll b)
{
	if (b == 0) return a;
	return gcd (b, a%b);
}
void swap (ll &a, ll &b)
{
	ll t = a;
	a = b;
	b = t;
}

// ----- code here ----- //
void solve()
{
	ll a, b, c = 0, cpre = -1;
	cin>>a>>b;
	while (c != cpre && a && b)
	{
		cpre = c;
		if (a >= 2*b)
		{
			ll d = min(a/2, b);
			a -= 2*d;
			b -= d;
			c += d;
		}
		else if (b >= 2*a)
		{
			ll d = min(a, b/2);
			a -= d;
			b -= 2*d;
			c += d;
		}
		else if (a == b)
		{
			ll d = a/3;
			c += d;
			a -= d;
			b -= d;
		}
		else if (a > b && a > 1)
		{
			a -= 2;
			b--;
			c++;
		}
		else if (b > 1)
		{
			a--;
			b -= 2;
			c++;
		}
	}
	cout<<c;
}
// ----- code here ----- //

signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("INPUT.txt", "r", stdin);
    // for writing output to output.txt
    freopen("OUTPUT.txt", "w", stdout);
    #endif
	ll t;
	cin>>t;
	while(t--)
	{
		solve();
		cout<<endl;
	}
}


#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define f(i,s,n) for(int i=(int)s;i<=(int)n;++i)
#define Fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
void solve()
{
	ll a,b;cin>>a>>b;
	if(a<b)
	swap(a,b);
	if(a==0 || b==0)
	cout<<0<<'\n';
	else{
		if(a/3 > b){
			cout<<b<<'\n';
		}
		else{
			int ans=a/3 + b/3;
			int x=a%3 + b%3;
			if(x>2){
				cout<<ans+1<<'\n';
			}
			else{
				cout<<ans<<'\n';
			}

		}
	}
}
int main()
{	Fast;
	int t;cin>>t;
	while(t--)
	solve();
}


#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define f(i,s,n) for(int i=(int)s;i<=(int)n;++i)
#define Fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
void solve()
{

	ll a,b;cin>>a>>b;
	if(a<b)
	swap(a,b);
	if(a==0 || b==0)
	cout<<0<<'\n';
	else{
		if(a/2 > b)
		cout<<b<<'\n';
		else{
			if(a%2){
				b-=(a/2);
				if(b>1){
					cout<<(a/2)+1<<'\n';
				}
				else{
					cout<<(a/2)<<'\n';
				}
			}
			else{
				b-=(a/2);
				if(b>2)
				cout<<(a/2) +1<<'\n';
				else{
					cout<<(a/2)<<'\n';
				}
			}
		}

	}
}
int main()
{	Fast;
	int t;cin>>t;
	while(t--)
	solve();
}


#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define f(i,s,n) for(int i=(int)s;i<=(int)n;++i)
#define Fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
void solve()
{
	ll a,b;cin>>a>>b;
	if(a==0 || b==0)
	cout<<0<<'\n';
	else{
		int cnt=0;
		while(a!=b && a>0 && b>0){
			if(a>b){
				a-=2;
				b-=1;
				++cnt;
			}
			else{
				b-=2;
				a-=1;
				++cnt;
			}
			if(a==b){
				break;
			}
			if(a==0 || b==0)
			break;
		}
		ll ans=(a/3)*2+cnt;
		cout<<ans<<'\n';
	}
}
int main()
{	Fast;
	int t;cin>>t;
	while(t--)
	solve();
}


#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define f(i,s,n) for(int i=(int)s;i<=(int)n;++i)
#define Fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
void solve()
{

	ll a,b;cin>>a>>b;
	if(a<b)
	swap(a,b);
	ll ans1=(a/3)+(b/3) ;//+ (a%3 + b%3 )>2?1:0;
	int x=(a%3) + (b%3);
	if(x>2)++ans1;
	//cout<<ans1<<'\n';
	if(a==0 || b==0){
	cout<<0<<'\n';
	return;
	}
	else{
		if(	(a/2) > b)
		cout<<b<<'\n';
		else{
			if(a%2){
				b-=(a/2);
				if(b>=1){
					cout<<max(ans1,(a/2)+1)<<'\n';
				}
				else{
					cout<<max(ans1,(a/2))<<'\n';
				}
			}
			else{
				b-=(a/2);
				if(b>2)
				cout<<max((ll)ans1,(a/2)+1)<<'\n';
				else{
					cout<<max((ll)ans1,(a/2))<<'\n';
				}
			}
		}

	}
}
int main()
{	Fast;
	int t;cin>>t;
	while(t--)
	solve();
}


#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define f(i,s,n) for(int i=(int)s;i<=(int)n;++i)
#define Fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
void solve()
{
	ll a,b;cin>>a>>b;
	if(a==0 || b==0)
	cout<<0<<'\n';
	else{
		int x=a%3+b%3;
		if(x>2)
		cout<<(a/3)+(b/3)+1<<'\n';
		else
		cout<<(a/3)+(b/3)<<'\n';
	}
}
int main()
{	Fast;
	int t;cin>>t;
	while(t--)
	solve();
}


#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define f(i,s,n) for(int i=(int)s;i<=(int)n;++i)
#define Fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
void solve()
{
	ll a,b;cin>>a>>b;
	if(a<b)
	swap(a,b);
	if(a==0 || b==0)
	cout<<0<<'\n';
	else{
		int x=a%3 +b%3;
		if(a/2 > b){
			cout<<b<<'\n';
		}
		else if(x>2){
			cout<<a/2 +1<<'\n';
		}
		else
		cout<<a/2<<'\n';
	}
}
int main()
{	Fast;
	int t;cin>>t;
	while(t--)
	solve();
}


#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define f(i,s,n) for(int i=(int)s;i<=(int)n;++i)
#define Fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
void solve()
{

	ll a,b;cin>>a>>b;
	if(a<b)
	swap(a,b);
	ll ans1=(a/3)+(b/3) ;//+ (a%3 + b%3 )>2?1:0;
	int x=(a%3) + (b%3);
	if(x>2)++ans1;
	//cout<<ans1<<'\n';
	if(a==0 || b==0){
	cout<<0<<'\n';
	return;
	}
	else{
		int x=a-b;
		if(2*(a-b)<a){
		a-=2*(a-b);
		int ans=(a/3)+(b/3);
		if((a%3) + (b%3) >2)++ans;
		cout<<ans + (x/2)<<'\n';
		}
		else{
			cout<<b<<'\n';
		}

	}
}
int main()
{	Fast;
	int t;cin>>t;
	while(t--)
	solve();
}


#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define f(i,s,n) for(int i=(int)s;i<=(int)n;++i)
#define Fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
void solve()
{
	ll a,b;cin>>a>>b;
	if(a<b)
	swap(a,b);
	if(a==0 || b==0)
	cout<<0<<'\n';
	else{
		if(a/3 > b){
			cout<<b<<'\n';
		}
		else{
			int ans=a/3 + b/3;
			int x=a%3 + b%3;
			if(x>2){
				cout<<ans+1;
			}
			else{
				cout<<ans<<'\n';
			}

		}
	}
}
int main()
{	Fast;
	int t;cin>>t;
	while(t--)
	solve();
}


#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define f(i,s,n) for(int i=(int)s;i<=(int)n;++i)
#define Fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
void solve()
{

	ll a,b;cin>>a>>b;
	if(a<b)
	swap(a,b);
	//cout<<ans1<<'\n';
	if(a==0 || b==0){
	cout<<0<<'\n';
	return;
	}
	else{
		ll ans=min(a,b);
		cout<<min(ans,(a+b)/3)<<'\n';
	}
}
int main()
{	Fast;
	int t;cin>>t;
	while(t--)
	solve();
}


#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define f(i,s,n) for(int i=(int)s;i<=(int)n;++i)
#define Fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
void solve()
{

	ll a,b;cin>>a>>b;
	if(a<b)
	swap(a,b);
	ll ans1=(a/3)+(b/3) ;//+ (a%3 + b%3 )>2?1:0;
	int x=(a%3) + (b%3);
	if(x>2)++ans1;
	//cout<<ans1<<'\n';
	if(a==0 || b==0){
	cout<<0<<'\n';
	return;
	}
	else{
		int x=a-b;
		if(2*(a-b)<a){
			a-=2*(a-b);
			int ans=(a/3)+(a/3);
			if((a%3) + (a%3) >2)++ans;
			if(x==0){
				cout<<ans<<'\n';
			}
			else
			cout<<ans + max(1,(x/2))<<'\n';
		}
		else{
			cout<<b<<'\n';
		}

	}
}
int main()
{	Fast;
	int t;cin>>t;
	while(t--)
	solve();
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int a,b;
        cin>>a>>b;

        if(a==0||b==0)
        cout<<0<<endl;
        else
        {
            int sum=0;
            sum=a+b;
            int res=floor(sum/3);
            res=res%1000000000;
            cout<<min(a,min(b,res))<<endl;
        }
    }

}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int a,b;
        cin>>a>>b;

        if(a==0||b==0)
        cout<<0<<endl;
        else
        {
            int sum=0;
            sum=a+b;
            int res=floor(sum/3);
            res=res%1000000000
            cout<<min(a,min(b,res))<<endl;
        }
    }

}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int a,b;
        cin>>a>>b;

        if(a==0||b==0)
        cout<<0<<endl;
        else
        {
            int sum=0;
            sum=a+b;
            cout<<floor(sum/3)<<endl;
        }
    }

}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        long long a,b;
        cin>>a>>b;

        if(a==0||b==0)
        cout<<0<<endl;
        else
        {
            long long sum=0;
            sum=a+b;
            cout<<floor(sum/3)<<endl;
        }
    }

}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int a,b;
        cin>>a>>b;

        if(a==0||b==0)
        cout<<0<<endl;
        else
        {
            int sum=0;
            sum=a+b;
            int res=floor(sum/3);
            cout<<res%1000000000<<endl;
        }
    }

}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        lint a,b;
        cin>>a>>b;

        if(a==0||b==0)
        cout<<0<<endl;
        else
        {
            int sum=0;
            sum=a+b;
            cout<<floor(sum/3)<<endl;
        }
    }

}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        long long a,b;
        cin>>a>>b;

        if(a==0||b==0)
        cout<<0<<endl;
        else
        {
            long long sum=0;
            sum=a+b;
            cout<<(int)floor(sum/3)<<endl;
        }
    }

}


#include <iostream>

using namespace std;

int main()
{
	int t;
	cin >> t;
	for (int i = 0; i < t; ++i)
	{
		int a, b;
		cin >> a >> b;
		if (a > 0 && b > 0)
		{
			if (((a+b) > 4) &&(((a + 1) == b) || ((b + 1) == a)))
			{
				if (a > b)
				{
					a = a / 2 + 1;
				}
				else
				{
					a = b / 2 + 1;
				}
			}
			else if (a >= b)
			{
				a = a / 2;
			}
			else
			{
				a = b / 2 ;
			}
			cout << a << endl;
		}
		else
		{
			cout << 0 << endl;
		}
	}
}


#include <iostream>

using namespace std;

int main()
{
	int t;
	cin >> t;
	for (int i = 0; i < t; ++i)
	{
		int a, b;
		int c = 0;
		cin >> a >> b;
		while (a>0 && b>0 && (a > 1 || b > 1) )
		{
			if (a >= b)
			{
				c++;
				a = a - 2;
				b = b - 1;
			}
			else
			{
				c++;
				a = a - 1;
				b = b - 2;
			}
		}
		cout << c << endl;
	}
}


#include <iostream>

using namespace std;

int main()
{
	int t;
	cin >> t;
	for (int i = 0; i < t; ++i)
	{
		int a, b;
		cin >> a >> b;
		if (a > 0 && b > 0)
		{
			int c;
			c = (a + b) / 3;
			if ((a - b) > c)
			{
				cout << b  << endl;
			}
			else if ((b - a) > c )
			{
				cout << a  << endl;
			}
			else
			{
				cout << c << endl;
			}
		}
		else
		{
			cout << 0 << endl;
		}
	}
}


#include <iostream>

using namespace std;

int main()
{
	int t;
	cin >> t;
	for (int i = 0; i < t; ++i)
	{
		int a, b;
		cin >> a >> b;
		if (a > 0 && b > 0)
		{
			a = (a + b) / 3;
			cout << a << endl;
		}
		else
		{
			cout << 0 << endl;
		}
	}
}


#include <iostream>

using namespace std;

int main()
{
	int t;
	cin >> t;
	for (int i = 0; i < t; ++i)
	{
		int n, m, k, a1,a2;
		cin >> n >> m >> k;
		if (n / k < m)
		{
			a1 = n / k;
		}
		else
		{
			a1 = m;
		}
		a2 = (m - a1 + k - 2) / (k - 1);
		cout << a1 - a2 << endl;
	}
}


#include <iostream>

using namespace std;

int main()
{
	int t;
	cin >> t;
	for (int i = 0; i < t; ++i)
	{
		int a, b;
		cin >> a >> b;
		if (a > 0 && b > 0)
		{
			if (((a+b) > 5) &&(((a + 1) == b) || ((b + 1) == a)))
			{
				if (a > b)
				{
					a = a / 2 + 1;
				}
				else
				{
					a = b / 2 + 1;
				}
			}
			else if (a >= b)
			{
				a = a / 2;
			}
			else
			{
				a = b / 2 ;
			}
			cout << a << endl;
		}
		else
		{
			cout << 0 << endl;
		}
	}
}


#include <iostream>

using namespace std;

int main()
{
	int t;
	cin >> t;
	for (int i = 0; i < t; ++i)
	{
		int a, b;
		int c = 0;
		cin >> a >> b;
		while (a>0 && b>0 && (a > 1 || b > 1) )
		{
			if (a >= b)
			{
				c++;
				a = a - 2;
				b = b - 1;
			}
			else if (b > a)
			{
				c++;
				a = a - 1;
				b = b - 2;
			}
		}
		cout << c << endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define vi vector<int>
#define V(a) vector<a>
#define ii pair<int,int>
#define lii pair<ll,ll>
#define PI 3.14159265358
#define mp make_pair
#define F first
#define S second
#define mod 998244353
#define INF (ll)1e18
#define wh(a) cout<<#a<<" is "<<a<<endl;cout.flush()
#define INI(a) memset(a,0,sizeof(a))
#define LIMIT 1000000

void solve(){
    ll a,b;
    cin>>a>>b;
    if(a>=2*b){
        cout<<b<<endl;
        return;
    }
    if(b>=2*a){
        cout<<a<<endl;
        return;
    }
    ll ans=min(a/3,b/3);
    a=a-3*ans;
    b=b-3*ans;
    ans=2*ans;
    if(a>=1 && b>=2) ans++;
    if(a>=2 && b>=1) ans++;
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define vi vector<int>
#define V(a) vector<a>
#define ii pair<int,int>
#define lii pair<ll,ll>
#define PI 3.14159265358
#define mp make_pair
#define F first
#define S second
#define mod 998244353
#define INF (ll)1e18
#define wh(a) cout<<#a<<" is "<<a<<endl;cout.flush()
#define INI(a) memset(a,0,sizeof(a))
#define LIMIT 10000090

void solve(){
    int a,b;
    cin>>a>>b;
    int ans=0;
    while(1){
        if(a>b){
            a=a-2;
            b=b-1;
            if(a>=0 && b>=0)
                ans++;
            else
                break;
        }
        else{
            a=a-1;
            b=b-2;
            if(a>=0 && b>=0)
                ans++;
            else
                break;
        }
    }
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define vi vector<int>
#define V(a) vector<a>
#define ii pair<int,int>
#define lii pair<ll,ll>
#define PI 3.14159265358
#define mp make_pair
#define F first
#define S second
#define mod 998244353
#define INF (ll)1e18
#define wh(a) cout<<#a<<" is "<<a<<endl;cout.flush()
#define INI(a) memset(a,0,sizeof(a))
#define LIMIT 10000090

void solve(){
    int a,b;
    cin>>a>>b;
    int ans=0;
    while(1){
        if(a==b){
            int rem=min(a/3,b/3);
            a=a-rem*3;
            b=b-rem*3;
            ans=ans+rem*2;
            if(a==b){
                break;
            }

        }
        else if(a>b){
            int rem=min(b,a-b);
            a=a-2*rem;
            b=b-1*rem;
            if(a>=0 && b>=0)
            ans=ans+rem;
        }
        else{
            int rem=min(a,b-a);
            a=a-1*rem;
            b=b-2*rem;
            if(a>=0 && b>=0)
            ans=ans+rem;
        }
        if(a<=0 || b<=0){
            break;
        }
    }
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define vi vector<int>
#define V(a) vector<a>
#define ii pair<int,int>
#define lii pair<ll,ll>
#define PI 3.14159265358
#define mp make_pair
#define F first
#define S second
#define mod 998244353
#define INF (ll)1e18
#define wh(a) cout<<#a<<" is "<<a<<endl;cout.flush()
#define INI(a) memset(a,0,sizeof(a))
#define LIMIT 1000000

void solve(){
    int a,b;
    cin>>a>>b;
    // int ans=0;
    // if(a>b){
    //     int c=a;
    //     a=b;
    //     b=c;
    // }
    // ans=min(2*a,b);
    // ans=ans-ans%2;
    // wh(ans);
    // a=a-ans;
    // b=b-2*ans;
    // ans=ans/2;
    // if(b>=1 && a>=2){
    //     ans++;
    // }
    // cout<<ans<<endl;
    int ans=(a+b)/3;
    ans=min(ans,2*a);
    ans=min(ans,2*b);
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define vi vector<int>
#define V(a) vector<a>
#define ii pair<int,int>
#define lii pair<ll,ll>
#define PI 3.14159265358
#define mp make_pair
#define F first
#define S second
#define mod 998244353
#define INF (ll)1e18
#define wh(a) cout<<#a<<" is "<<a<<endl;cout.flush()
#define INI(a) memset(a,0,sizeof(a))
#define LIMIT 10000090

void solve(){
    int a,b;
    cin>>a>>b;
    int ans=(a+b)/3;
    ans=min(ans,min(a,b));
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define vi vector<int>
#define V(a) vector<a>
#define ii pair<int,int>
#define lii pair<ll,ll>
#define PI 3.14159265358
#define mp make_pair
#define F first
#define S second
#define mod 998244353
#define INF (ll)1e18
#define wh(a) cout<<#a<<" is "<<a<<endl;cout.flush()
#define INI(a) memset(a,0,sizeof(a))
#define LIMIT 1000000

void solve(){
    ll a,b;
    cin>>a>>b;
    if(a>=2*b){
        cout<<b<<endl;
        return;
    }
    if(b>=2*a){
        cout<<a<<endl;
        return;
    }
    if(a>b){
        int c=b;
        b=a;
        a=c;
    }
    ll ans=min(a,(b-a)/2);
    a=a-ans;
    b=b-2*ans;
    ll val=min(a/3,b/3);
    a=a-val*3;
    b=b-val*3;
    ans=ans+val*2;
    if(a%3>=2 && b%3>=1){
        ans++;
    }
    else if(a%3>=1 && b%3>=2){
        ans++;
    }
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define vi vector<int>
#define V(a) vector<a>
#define ii pair<int,int>
#define lii pair<ll,ll>
#define PI 3.14159265358
#define mp make_pair
#define F first
#define S second
#define mod 998244353
#define INF (ll)1e18
#define wh(a) cout<<#a<<" is "<<a<<endl;cout.flush()
#define INI(a) memset(a,0,sizeof(a))
#define LIMIT 10000090

void solve(){
    int a,b;
    cin>>a>>b;
    int ans=0;
    while(1){
        if(a>b){
            int rem=min(b,a-b);
            if(rem==0){
                rem=1;
            }
            a=a-2*rem;
            b=b-1*rem;
            if(a<0 || b<0) break;
            ans=ans+rem;
            if(a<=0 || b<=0) break;
        }
        else{
            int rem=min(a,b-a);
            if(rem==0){
                rem=1;
            }
            a=a-1*rem;
            b=b-2*rem;
            if(a<0 || b<0) break;

            ans=ans+rem;
            if(a<=0 || b<=0) break;
        }
    }
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define vi vector<int>
#define V(a) vector<a>
#define ii pair<int,int>
#define lii pair<ll,ll>
#define PI 3.14159265358
#define mp make_pair
#define F first
#define S second
#define mod 998244353
#define INF (ll)1e18
#define wh(a) cout<<#a<<" is "<<a<<endl;cout.flush()
#define INI(a) memset(a,0,sizeof(a))
#define LIMIT 1000000

void solve(){
    ll a,b;
    cin>>a>>b;
    // int ans=0;
    // if(a>b){
    //     int c=a;
    //     a=b;
    //     b=c;
    // }
    // ans=min(2*a,b);
    // ans=ans-ans%2;
    // wh(ans);
    // a=a-ans;
    // b=b-2*ans;
    // ans=ans/2;
    // if(b>=1 && a>=2){
    //     ans++;
    // }
    // cout<<ans<<endl;
    ll ans=(a+b)/3;
    ans=min(ans,2*a);
    ans=min(ans,2*b);
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


/*
	author: Ibrahim-Elsayed (Codeforces Handle)
	date: 9/14/2020
*/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const double PI = acos(-1);

void solve() {
	ll a, b;
	cin >> a >> b;
	cout << ((a == 0 || b == 0) ? 0 : (abs(a-b) > max(a, b)/2 ? min(a, b) : (a+b)/3)) << "\n";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int t;
	cin >> t;
	while(t--) solve();

	return 0;
}


/*
	author: Ibrahim-Elsayed (Codeforces Handle)
	date: 9/14/2020
*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const double PI = acos(-1);

void solve() {
	ll a, b;
	cin >> a >> b;
	if(a*2 <= b) {
		cout << a << "\n";
	} else if(b*2 <= a) {
		cout << b << "\n";
	} else {
		cout << (a+b)/3 << "\n";
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int t;
	cin >> t;
	while(t--) solve();

	return 0;
}


/*
	author: Ibrahim-Elsayed (Codeforces Handle)
	date: 9/14/2020
*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const double PI = acos(-1);

void solve() {
	ll a, b;
	cin >> a >> b;
	cout << (a == 0 || b == 0 ? 0 : (a+b)/3) << "\n";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int t;
	cin >> t;
	while(t--) solve();

	return 0;
}


/*
	author: Ibrahim-Elsayed (Codeforces Handle)
	date: 9/14/2020
*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const double PI = acos(-1);

void solve() {
	ll a, b;
	cin >> a >> b;
	cout << ((a == 0 || b == 0) ? 0 : (a+b)/3) << "\n";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int t;
	cin >> t;
	while(t--) solve();

	return 0;
}


/*
	author: Ibrahim-Elsayed (Codeforces Handle)
	date: 9/14/2020
*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const double PI = acos(-1);

void solve() {
	ll a, b;
	cin >> a >> b;
	cout << ((a == 0 || b == 0) ? 0 : (abs(a-b) > max(a, b)/2 ? min(a, b) : (a+b)/3)) << "\n";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int t;
	cin >> t;
	while(t--) solve();

	return 0;
}


/*
	author: Ibrahim-Elsayed (Codeforces Handle)
	date: 9/14/2020
*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const double PI = acos(-1);

void solve() {
	ll a, b;
	cin >> a >> b;
	cout << ((a == 0 || b == 0) ? 0 : (abs(a-b) >= max(a, b)/2 ? min(a, b) : (a+b)/3)) << "\n";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int t;
	cin >> t;
	while(t--) solve();

	return 0;
}


/*
	author: Ibrahim-Elsayed (Codeforces Handle)
	date: 9/14/2020
*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const double PI = acos(-1);

void solve() {
	ll a, b;
	cin >> a >> b;
	cout << min({a, b, (a+b)/3}) << "\n";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int t;
	cin >> t;
	while(t--) solve();

	return 0;
}


#include <bits/stdc++.h>
#define inf 9999999999999999
using namespace std;
#define int long long
#define pii pair<int,int>
#define mii map<int,int>
#define pb push_back
#define vi vector<int>
int32_t main(){
	int t;
	cin >> t;
	while(t--){
		int a,b;
		cin >> a >> b;
		if(a<b){
			swap(a,b);
		}
		int ans = 0;
		if(a == 0 || b == 0){
			cout << "0\n";
			continue;
		}
		if(b != 0 && a/b >= 2){
			ans += b;
			cout << ans << "\n";
			continue;
		}
		ans = 0;
		int diff = a - b;
		ans += diff;
		a -= 2*diff;
		b -= diff;
		if(a%3 == 0)
			ans += (a/3)*2;
		else{
			int x = a/3;
			ans += (a/3)*2;
			// cout << a << " " << b << "\n";
			a -= 3*x;
			b -= 3*x;
			// cout << a << " " << b << "\n";
			if(a == 2 && b == 2)
				ans++;
		}
		cout << ans << "\n";
	}
}


#include <bits/stdc++.h>
#define inf 9999999999999999
using namespace std;
#define int long long
#define pii pair<int,int>
#define mii map<int,int>
#define pb push_back
#define vi vector<int>
int32_t main(){
	int t;
	cin >> t;
	while(t--){
		int a,b;
		cin >> a >> b;
		if(a<b){
			swap(a,b);
		}
		int ans = 0;
		if(a == 0 || b == 0){
			cout << "0\n";
			continue;
		}
		if(b != 0 && a/b >= 2){
			ans += a/2;
			cout << ans << "\n";
			continue;
		}
		ans = 0;
		int diff = a - b;
		ans += diff;
		a -= 2*diff;
		b -= diff;
		if(a%3 == 0)
			ans += (a/3)*2;
		else{
			int x = a/3;
			ans += (a/3)*2;
			// cout << a << " " << b << "\n";
			a -= 3*x;
			b -= 3*x;
			// cout << a << " " << b << "\n";
			if(a == 2 && b == 2)
				ans++;
		}
		cout << ans << "\n";
	}
}


#include <bits/stdc++.h>
#define inf 9999999999999999
using namespace std;
#define int long long
#define pii pair<int,int>
#define mii map<int,int>
#define pb push_back
#define vi vector<int>
int32_t main(){
	int t;
	cin >> t;
	while(t--){
		int a,b;
		cin >> a >> b;
		if(a<b){
			swap(a,b);
		}
		int ans = 0;
		// while(a !=0 && b != 0 && a != b){
		// 	ans++;
		// 	a -= 2;
		// 	b--;
		// }
		if(a == 0 || b == 0){
			cout << "0\n";
			continue;
		}
		int diff = a-b;
		// ans = diff;
		diff = min(diff,min(a,b));
		ans = diff;
		a -= 2*diff;
		b -= diff;
		if(a!=0 && a == b){
			ans += 2*(a/3);
		}
		cout << ans << "\n";
	}
}


#include <bits/stdc++.h>
#define inf 9999999999999999
using namespace std;
#define int long long
#define pii pair<int,int>
#define mii map<int,int>
#define pb push_back
#define vi vector<int>
int32_t main(){
	int t;
	cin >> t;
	while(t--){
		int a,b;
		cin >> a >> b;
		if(a<b){
			swap(a,b);
		}
		int ans = 0;
		if(a == 0 || b == 0){
			cout << "0\n";
			continue;
		}
		if(b != 0 && a/b >= 2){
			ans += a/2;
			cout << ans << "\n";
			continue;
		}
		ans = 0;
		int diff = a - b;
		ans += diff;
		a -= 2*diff;
		b -= diff;
		ans += (a/3)*2;
		cout << ans << "\n";
	}
}


#include <bits/stdc++.h>
#define inf 9999999999999999
using namespace std;
#define int long long
#define pii pair<int,int>
#define mii map<int,int>
#define pb push_back
#define vi vector<int>
int32_t main(){
	int t;
	cin >> t;
	while(t--){
		int a,b;
		cin >> a >> b;
		if(a<b){
			swap(a,b);
		}
		int ans = 0;
		while(a !=0 && b != 0 && a != b){
			ans++;
			a -= 2;
			b--;
		}
		if(a!=0 && a == b){
			ans += 2*(a/3);
		}
		cout << ans << "\n";
	}
}


#include <bits/stdc++.h>
#define inf 9999999999999999
using namespace std;
#define int long long
#define pii pair<int,int>
#define mii map<int,int>
#define pb push_back
#define vi vector<int>
int32_t main(){
	int t;
	cin >> t;
	while(t--){
		int a,b;
		cin >> a >> b;
		if(a<b){
			swap(a,b);
		}
		int ans = 0;
		if(a == 0 || b == 0){
			cout << "0\n";
			continue;
		}
		if(b != 0 && a/b >= 2){
			ans += b/2;
			cout << ans << "\n";
			continue;
		}
		ans = 0;
		int diff = a - b;
		ans += diff;
		a -= 2*diff;
		b -= diff;
		if(a%3 == 0)
			ans += (a/3)*2;
		else{
			int x = a/3;
			ans += (a/3)*2;
			// cout << a << " " << b << "\n";
			a -= 3*x;
			b -= 3*x;
			// cout << a << " " << b << "\n";
			if(a == 2 && b == 2)
				ans++;
		}
		cout << ans << "\n";
	}
}


#include <bits/stdc++.h>
#define inf 9999999999999999
using namespace std;
#define int long long
#define pii pair<int,int>
#define mii map<int,int>
#define pb push_back
#define vi vector<int>
int32_t main(){
	int t;
	cin >> t;
	while(t--){
		int a,b;
		cin >> a >> b;
		if(a<b){
			swap(a,b);
		}
		int ans = 0;
		if(a == 0 || b == 0){
			cout << "0\n";
			continue;
		}
		if(b != 0 && a/b >= 2){
			ans += b/2;
			cout << ans << "\n";
			continue;
		}
		ans = 0;
		int diff = a - b;
		ans += diff;
		a -= 2*diff;
		b -= diff;
		if(a%3 == 0)
			ans += (a/3)*2;
		else{
			int x = a/3;
			ans += (a/3)*2;
			cout << a << " " << b << "\n";
			a -= 3*x;
			b -= 3*x;
			cout << a << " " << b << "\n";
			if(a == 2 && b == 2)
				ans++;
		}
		cout << ans << "\n";
	}
}


#include <bits/stdc++.h>
#define inf 9999999999999999
using namespace std;
#define int long long
#define pii pair<int,int>
#define mii map<int,int>
#define pb push_back
#define vi vector<int>
int32_t main(){
	int t;
	cin >> t;
	while(t--){
		int a,b;
		cin >> a >> b;
		if(a<b){
			swap(a,b);
		}
		int ans = 0;
		if(a == 0 || b == 0){
			cout << "0\n";
			continue;
		}
		while((a/b) < 2 && a > 0 && b > 0){
			if(a == b){
				ans += (a/3)*2;
				a= 0;
				break;
			}
			if(a<b){
				swap(a,b);
			}
			a -= 2;
			b--;
			ans++;
		}
		if(b != 0 && a/b >= 2){
			ans += a/2;
		}
		cout << ans << "\n";
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
       ll a,b;
       cin >> a >> b;
       ll ans = 0;
       ll x =  min(a,b);
       ll y = max(a,b);
       if(y>=2*x)
       {
           ans = x;
       }
       else
       {
           ans = (y-x)+2*((2*x-y)/3);
       }
       cout<<ans<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
       ll a,b;
       cin >> a >> b;
       if(2*a<=b)
       {
           cout<<a<<endl;
       }
       else if(2*b<=a)
       {
           cout<<b<<endl;
       }
       else
       {
           cout<<(a+b)/3<<endl;
       }

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
       ll a,b;
       cin >> a >> b;
       if(2*a>=b)
       {
           cout<<b<<endl;
       }
       else if(2*b<=a)
       {
           cout<<a<<endl;
       }
       else
       {
           cout<<(a+b)/3<<endl;
       }

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
       ll a,b;
       cin >> a >> b;
       if(2*a>=b)
       {
           cout<<b<<endl;
       }
       else if(2*b>=a)
       {
           cout<<a<<endl;
       }
       else
       {
           cout<<(a+b)/3<<endl;
       }

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
       ll a,b;
       cin >> a >> b;
       ll ans = 0;
       while(min(a,b)>=1)
       {
           ans += 1;
           ll x = min(a,b);
           if(x==a)
           {
               a-=1;
               b-=2;
           }
           else
           {
               a-=2;
               b-=1;
           }
           if(a==1 && b==1)break;
       }
       cout<<ans<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
       ll a,b;
       cin >> a >> b;
       ll ans = 0;
       ll x =  min(a,b);
       ll y = max(a,b);
       if(y>=2*x)
       {
           ans = x;
       }
       else
       {
           ans += y-x;
           ll z = (2*x-y)/3;
           ans += 2*z;
       }
       cout<<ans<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
       ll a,b;
       cin >> a >> b;
       ll x = min(a,b);
       ll y = max(a,b);
       ll ans = 0;
       ans += 2*(x/3);

       y -= (x-x%3);
       x = x%3;
       if(x==1 && y>= 2)
       {
           ans+= 1;
       }
       else if(x==2 && y>=4)
       {
           ans += 2;
       }
       else if(x== 2 && y<=2)
       {
           ans += 1;
       }
       cout << ans << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
       ll a,b;
       cin >> a >> b;
       if(2*a>=b)
       {
           cout<<b<<endl;
       }
       else if(2*b<=a)
       {
           cout<<a<<endl;
       }
       else
       {
           cout<<(a+b)/3<<endl;
       }
       cout<<ans<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
       ll a,b;
       cin >> a >> b;
       if(2*a<=b)
       {
           cout<<b<<endl;
       }
       else if(2*b<=a)
       {
           cout<<a<<endl;
       }
       else
       {
           cout<<(a+b)/3<<endl;
       }

    }
    return 0;
}


#include <bits/stdc++.h>
#define MAX 8001
#define ull unsigned long long
using namespace std;

// void sieve(int* primes) {
// 	for(int i = 2;i*i <= MAX;i++) {
// 		if(!primes[i]) {
// 			for(int j = i*i;j <= MAX;j+=i) {
// 				primes[j] = 1;
// 			}
// 		}
// 	}
// }

// double comb(ull n, ull r) {
// 	double nu=1,de=1;
// 	for(int i=0;i<r;i++)
// 		nu*=(n-i),de*=(i+1);
// 	return nu/de;
// }

int main() {
  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  int t;
	cin>>t;
	while(t--) {
		ull a,b;
		cin>>a>>b;
		if(!a||!b)
			cout<<"0";
		else {
			if(a > b)
				swap(a,b);
			// cout<<min(2*a,b)<<endl;
			cout<<ceil((a+min(2*a,b))/3);
		}
		cout<<"\n";
	}
  return 0;
}


#include <bits/stdc++.h>
#define MAX 8001
using namespace std;

// void sieve(int* primes) {
// 	for(int i = 2;i*i <= MAX;i++) {
// 		if(!primes[i]) {
// 			for(int j = i*i;j <= MAX;j+=i) {
// 				primes[j] = 1;
// 			}
// 		}
// 	}
// }

// double comb(ull n, ull r) {
// 	double nu=1,de=1;
// 	for(int i=0;i<r;i++)
// 		nu*=(n-i),de*=(i+1);
// 	return nu/de;
// }

int main() {
  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  int t;
	cin>>t;
	while(t--) {
		int a,b;
		cin>>a>>b;
		if(!a||!b)
			cout<<"0";
		else {
			cout<<(a+b)/3;
		}
		cout<<"\n";
	}
  return 0;
}


#include <bits/stdc++.h>
#define MAX 8001
#define ull unsigned long long
using namespace std;

// void sieve(int* primes) {
// 	for(int i = 2;i*i <= MAX;i++) {
// 		if(!primes[i]) {
// 			for(int j = i*i;j <= MAX;j+=i) {
// 				primes[j] = 1;
// 			}
// 		}
// 	}
// }

// double comb(ull n, ull r) {
// 	double nu=1,de=1;
// 	for(int i=0;i<r;i++)
// 		nu*=(n-i),de*=(i+1);
// 	return nu/de;
// }

int main() {
  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  int t;
	cin>>t;
	while(t--) {
		ull a,b;
		cin>>a>>b;
		if(!a||!b)
			cout<<"0";
		else {
			if(a > b)
				swap(a,b);
			cout<<((a%3+b%3)/3)+(a/3+b/3);
		}
		cout<<"\n";
	}
  return 0;
}


#include <bits/stdc++.h>
#define MAX 8001
#define ull unsigned long long
using namespace std;

// void sieve(int* primes) {
// 	for(int i = 2;i*i <= MAX;i++) {
// 		if(!primes[i]) {
// 			for(int j = i*i;j <= MAX;j+=i) {
// 				primes[j] = 1;
// 			}
// 		}
// 	}
// }

// double comb(ull n, ull r) {
// 	double nu=1,de=1;
// 	for(int i=0;i<r;i++)
// 		nu*=(n-i),de*=(i+1);
// 	return nu/de;
// }

int main() {
  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  int t;
	cin>>t;
	while(t--) {
		int a,b;
		cin>>a>>b;
		int ops = 0;
		while(a!=0 && b!=0) {
			if(a==b) {
				if(a < 2)
					break;
				a--,b-=2,ops++;
			}
			else {
				if(a > b)
					swap(a,b);
				int d = ceil((b-a)/2.0);
				a=a-d;
				b=b-(d<<1);
				if(a <= 0 || b <= 0) {
					a+=d;
					ops += a;
					break;
				}
				ops += d;
			}
		}
		cout<<ops;
		cout<<"\n";
	}
  return 0;
}


#include <bits/stdc++.h>
#define MAX 8001
#define ull unsigned long long
using namespace std;

// void sieve(int* primes) {
// 	for(int i = 2;i*i <= MAX;i++) {
// 		if(!primes[i]) {
// 			for(int j = i*i;j <= MAX;j+=i) {
// 				primes[j] = 1;
// 			}
// 		}
// 	}
// }

// double comb(ull n, ull r) {
// 	double nu=1,de=1;
// 	for(int i=0;i<r;i++)
// 		nu*=(n-i),de*=(i+1);
// 	return nu/de;
// }

int main() {
  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  int t;
	cin>>t;
	while(t--) {
		int a,b;
		cin>>a>>b;
		if(a > b)
			swap(a,b);
		int ops = b-a;
		a = a-(b-a);
		b = b-2*(b-a);
		if(a <= 0)
			ops+=a;
		else {
			ops+=(a<<1)/3;
		}
		cout<<ops;
		cout<<"\n";
	}
  return 0;
}


#include <bits/stdc++.h>
#define MAX 8001
#define ull unsigned long long
using namespace std;

// void sieve(int* primes) {
// 	for(int i = 2;i*i <= MAX;i++) {
// 		if(!primes[i]) {
// 			for(int j = i*i;j <= MAX;j+=i) {
// 				primes[j] = 1;
// 			}
// 		}
// 	}
// }

// double comb(ull n, ull r) {
// 	double nu=1,de=1;
// 	for(int i=0;i<r;i++)
// 		nu*=(n-i),de*=(i+1);
// 	return nu/de;
// }

int main() {
  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  int t;
	cin>>t;
	while(t--) {
		int a,b;
		cin>>a>>b;
		int ops = 0;
		while(a!=0 && b!=0) {
			if(a==b) {
				if(a < 2)
					break;
				a--,b-=2,ops++;
			}
			else {
				if(a > b)
					swap(a,b);
				int d = ceil((b-a)/2.0);
				a=a-d;
				b=b-(d<<1);
				ops += d;
			}
		}
		cout<<ops;
		cout<<"\n";
	}
  return 0;
}


#include <bits/stdc++.h>
#define MAX 8001
#define ull unsigned long long
using namespace std;

// void sieve(int* primes) {
// 	for(int i = 2;i*i <= MAX;i++) {
// 		if(!primes[i]) {
// 			for(int j = i*i;j <= MAX;j+=i) {
// 				primes[j] = 1;
// 			}
// 		}
// 	}
// }

// double comb(ull n, ull r) {
// 	double nu=1,de=1;
// 	for(int i=0;i<r;i++)
// 		nu*=(n-i),de*=(i+1);
// 	return nu/de;
// }

int main() {
  // ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  int t;
	// cin>>t;
	scanf("%d",&t);
	while(t--) {
		int a,b;
		// cin>>a>>b;
		scanf("%d %d",&a,&b);
		if(a > b)
			swap(a,b);
		int ops = b-a;
		a = (a<<1)-b;
		if(a <= 0)
			ops+=a;
		else {
			ops+=(a<<1)/3;
		}
		printf("%d\n",ops);
	}
  return 0;
}


#include <bits/stdc++.h>
#define MAX 8001
#define ull unsigned long long
using namespace std;

// void sieve(int* primes) {
// 	for(int i = 2;i*i <= MAX;i++) {
// 		if(!primes[i]) {
// 			for(int j = i*i;j <= MAX;j+=i) {
// 				primes[j] = 1;
// 			}
// 		}
// 	}
// }

// double comb(ull n, ull r) {
// 	double nu=1,de=1;
// 	for(int i=0;i<r;i++)
// 		nu*=(n-i),de*=(i+1);
// 	return nu/de;
// }

int main() {
  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  int t;
	cin>>t;
	while(t--) {
		ull a,b;
		cin>>a>>b;
		if(!a||!b)
			cout<<"0";
		else {
			cout<<(a+b)/3;
		}
		cout<<"\n";
	}
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        long long a, b;
        cin >> a >> b;
        if (a < b)
            swap(a, b);
        if (a >= 2 * b)
            cout << b << "\n";
        else

            if ((2 * b - a) % 3 == 2)
                cout << a - b + (2 * b - a)/ 3 * 2 + 1 << "\n";
            else
                cout << a - b + (2 * b - a) / 3 * 2  << "\n";

    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        long long a, b;
        cin >> a >> b;
        if (a < b)
            swap(a, b);
        if (a >= 2 * b)
            cout << b << "\n";
        else

            if ((2 * b - a) % 3 == 2)
                cout << a - b + (2 * b - a)/ 3 * 2 - 1 << "\n";
            else
                cout << a - b + (2 * b - a) / 3 * 2  << "\n";

    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        long long a, b;
        cin >> a >> b;
        if (a < b)
            swap(a, b);
        if (a >= 2 * b)
            cout << b << "\n";
        else
            cout << a - b + (2 * b - a) / 3 * 2  << "\n";

    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        long long a, b;
        cin >> a >> b;
        if (a < b)
            swap(a, b);
        if (a >= 2 * b)
            cout << b << "\n";
        if ((2 * b - a) % 3 == 2)
            cout << a - b + (2 * b - a)/ 3 * 2 - 1 << "\n";
        else
            cout << a - b + (2 * b - a) / 3 * 2  << "\n";

    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        long long a, b;
        cin >> a >> b;
        if (a < b)
            swap(a, b);
        if (a >= 2 * b)
            cout << b << "\n";
        if (a == 0 || b == 0)
            cout << 0 << "\n"
        else
            cout << a - b + (2 * b - a) / 3 * 2  << "\n";

    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int a, b;
        cin >> a >> b;
        if (a < b)
            swap(a, b);
        if (a >= 2 * b)
            cout << b << "\n";
        else
            cout << a - b + (2 * b - a) / 3 * 2  << "\n";

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef   long  double ld;
#define syncboost ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
#define mp make_pair
#define pb push_back
#define pp pop_back
#define pl pair<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vpl vector<pair<ll,ll>>
#define all(x) x.begin(),x.end()
#define precise(n) cout << fixed; cout << setprecision(n)
#define forn(i, n) for (ll i = 0; i < ll(n); i++)
#define setbit(x) __builtin_popcount(x)
#define run(i, v) for(auto &i: v)
#define hike(i, v) for(const auto &i: v)
#define srt(v) sort(v.begin(),v.end())
#define mem(x,val) memset(x,val,sizeof(x))
#define rep(i,init,n) for(ll i = init;i<n;i++)
#define rrep(i,n,init) for(ll i = n;i>=init;i--)
#define fi first
#define se second
double pi = 3.14159265;
#define show(x) cerr << x
#define deb(x) show(#x << ": " << (x) << endl);
#define det(x) cout<<x<<"\n";
#define No cout<<"No\n";
#define Yes cout<<"Yes\n";
#define YES cout<<"YES\n";
#define NO cout<<"NO\n";
#define sp " "
#define nl cout<<"\n";
#define ps(x,y)   fixed<<setprecision(y)<<x
ll MOD = 1e9+7;
const ll mod  =998244353;
inline ll add(ll x, ll y) { x += y; if (x >= MOD) x -= MOD; return x; }
inline ll sub(ll x, ll y) { x -= y; if (x < 0) x += MOD; return x; }
inline ll mul(ll x, ll y) { return (x * y) % MOD; }
inline ll powr(ll a, ll b) {
     ll x = 1 % MOD;
     while (b) {
          if (b & 1) x = mul(x, a);
          a = mul(a, a);
          b >>= 1;
     }
     return x;
}
inline ll modinv(ll x) {
    return powr(x,MOD-2);
}

inline ll inv(ll a) { return powr(a, MOD - 2); }
const ll N = 500005;
const ll maxn = 1e9+1;
const ll INF = ll(1e18);
ll dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

int n, m;
int ans[N];

int lasar[N];
vector <int> G[N];
vector <int> in[N];
vl ct;
void precomp()
{

}
void solve(){
   ll n,k,a,b;
    cin>>a>>b;
    if(a<b)
    {
      swap(a,b);

    }
    if(a>=2*b)
      cout<<b<<"\n";
    else
    {
     ll ans = min(b/2,a/2);
      a -= ans*2;
      b-=ans;
      if(a<b)
        swap(a,b);
      ans += min(b,a/2);
      cout<<ans;
      nl

    }
    return;
}
void io()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
}
signed main()
{
    ll t = 1;

syncboost;
  // io();
//
    cin>>t;
    //precomp();
   //precise(6);
   rep(testcase,1,t+1)
    {
    //  deb(testcase);

     //  cout<<"Case #"<<testcase<<": ";
       solve();
       //nl
    }

   return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef   long  double ld;
#define syncboost ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
#define mp make_pair
#define pb push_back
#define pp pop_back
#define pl pair<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vpl vector<pair<ll,ll>>
#define all(x) x.begin(),x.end()
#define precise(n) cout << fixed; cout << setprecision(n)
#define forn(i, n) for (ll i = 0; i < ll(n); i++)
#define setbit(x) __builtin_popcount(x)
#define run(i, v) for(auto &i: v)
#define hike(i, v) for(const auto &i: v)
#define srt(v) sort(v.begin(),v.end())
#define mem(x,val) memset(x,val,sizeof(x))
#define rep(i,init,n) for(ll i = init;i<n;i++)
#define rrep(i,n,init) for(ll i = n;i>=init;i--)
#define fi first
#define se second
double pi = 3.14159265;
#define show(x) cerr << x
#define deb(x) show(#x << ": " << (x) << endl);
#define det(x) cout<<x<<"\n";
#define No cout<<"No\n";
#define Yes cout<<"Yes\n";
#define YES cout<<"YES\n";
#define NO cout<<"NO\n";
#define sp " "
#define nl cout<<"\n";
#define ps(x,y)   fixed<<setprecision(y)<<x
ll MOD = 1e9+7;
const ll mod  =998244353;
inline ll add(ll x, ll y) { x += y; if (x >= MOD) x -= MOD; return x; }
inline ll sub(ll x, ll y) { x -= y; if (x < 0) x += MOD; return x; }
inline ll mul(ll x, ll y) { return (x * y) % MOD; }
inline ll powr(ll a, ll b) {
     ll x = 1 % MOD;
     while (b) {
          if (b & 1) x = mul(x, a);
          a = mul(a, a);
          b >>= 1;
     }
     return x;
}
inline ll modinv(ll x) {
    return powr(x,MOD-2);
}

inline ll inv(ll a) { return powr(a, MOD - 2); }
const ll N = 500005;
const ll maxn = 1e9+1;
const ll INF = ll(1e18);
ll dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

int n, m;
int ans[N];

int lasar[N];
vector <int> G[N];
vector <int> in[N];
vl ct;
void precomp()
{

}
void solve(){
   ll n,k;
    cin>>n>>k;
    if(n<k)
    {
      swap(n,k);

    }
    ll ans = min(k,n/2);
    ll rem = k-ans;
    if(rem>2 && (rem+1)%2 ==0)
     ans--,ans += (rem+1)/2;
   cout<<ans;
   nl
    return;
}
void io()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
}
signed main()
{
    ll t = 1;

syncboost;
  // io();
//
    cin>>t;
    //precomp();
   //precise(6);
   rep(testcase,1,t+1)
    {
    //  deb(testcase);

     //  cout<<"Case #"<<testcase<<": ";
       solve();
       //nl
    }

   return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main(){
	IOS;
	int t;
	cin >> t;
	while(t--){
		int a, b;
		cin >> a >> b;
		int ini = 0;
		while( true ){
			if( b > a )
				swap(a, b);
			int dif = min((a-b)/2, b);
			if( dif == 0 )
				break;
			ini = ini + dif;
			a = a - dif*2;
			b = b - dif;
			// cout << "iter " << ini << " " << a << " " << b << " df " << dif << endl;
		}
		cout << ini << " " << a << " " << b << endl;
		int tot = min(a, b);
		tot = (tot/3);
		a = a - tot*3;
		b = b - tot*3;
		ini = ini + tot*2;
		// cout << "ini " << ini << " " << a <<  " " << b << endl;
		while( true ){
			if( a == 0 || b == 0 || ( a < 2 && b < 2 ))
				break;
			if( b > a )
				swap(a, b);
			a = a - 2;
			b = b - 1;
			ini++;
		}

		cout << ini << endl;
	}
	return 0;
}