l=list(map(int,input().split()))
A,B,n=l[0],l[1],l[2]
if A==0 and B==0:
    print('5')
elif A==0 and B!=0:
    print('No solution')

elif A!=0 and B==0:
    print('0')

elif (B/A).is_integer():
    c=int(B/A)

    e=abs(c)

    f=e**(1/n)

    if (f).is_integer():

        if c<0:
            print(-int(f))
        else:
            print(int(f))

    else:
        print('No solution')
else:
    print('No solution')


l=list(map(int,input().split()))
A,B,n=l[0],l[1],l[2]
if A==0 and B==0:
    print('5')
elif A==0 and B!=0:
    print('No solution')

elif A!=0 and B==0:
    print('0')

elif (B/A).is_integer():
    c=B/A
    e=abs(int(c))
    d=False
    f=(int(e**0.5))+1
    for i in range(2,f):

        if e%i==0:
            if i**n==e:
                d=True
                break

    if d==True:
        if c<0:
            print(-i)
        else:
            print(i)
    else:
        print('No solution')

else:
    print('No solution')


a,b,n=input().split()
import math
a=int(a)
b=int(b)
n=int(n)
c=1
d=1

if b==0 and a==0:
	ans=0
elif a*b==0:
	if a==0:
		d=0
	else:
		ans=0
else:
	if a*b<0:
		c=-1
		a=abs(a)
		b=abs(b)

	ans=pow(b/a,1/n)
if d:
	if ans-int(ans+1e-8)<1e-8:
		ans = int(ans+1e-8)*c
	else:
		ans="No solution"
else:
	ans="No solution"
print(ans)


a,b,n=input().split()
import math
a=int(a)
b=int(b)
n=int(n)
c=1
d=1

if b==0 and a==0:
	ans=0
elif a*b==0:
	if a==0:
		d=0
	else:
		ans=0
else:
	if a*b<0:
		c=-1
		a=abs(a)
		b=abs(b)

	ans=pow(b/a,1/n)
if d:
	if ans-int(ans)<1e-8:
		ans = int(ans+1e-8)*c
	else:
		ans="No solution"
else:
	ans="No solution"
print(ans)


a,b,n=input().split()
import math
a=int(a)
b=int(b)
n=int(n)
c=1;
if b==0:
	ans=0
else:
	if a*b<0:
		c=-1
		a=abs(a)
		b=abs(b)

	ans=pow(b/a,1/n)
if ans-int(ans)<1e-8:
	ans = int(ans+1e-8)*c
else:
	ans="No solution"
print(ans)


a,b,n=input().split()
import math
a=int(b)/int(a)
b=math.pow(a,1/int(n))
print(int(b+1e-8))


import sys
a,b,n = map(int,input().split())
for x in range(-1000,1001):
	if a * x**n == b:
		print(x)
		sys.exit()
print('No solution')


def uravnenie(a, b, n):
    for x in range(-1000, 1001):
        if a * (x ** n) == b:
            return abs(x)
    return "No solution"

A, B, N = [int(i) for i in input().split()]
print(uravnenie(A, B, N))


def uravnenie(a, b, n):
    for x in range(-1000, 1001):
        if a * (x ** n) == b:
            return x
    return "No solution"

A, B, N = [int(i) for i in input().split()]
print(uravnenie(A, B, N))


import sys
import math
a,b,n = map(int,input().split())

if a>0 and b>0 or a<0 and b<0:
    x = (b/a)**(1/n)
elif a<0 or b<0 and a!=0:
    x = (abs(b)/abs(a))**(1/n)
    if int(x) == x:
        x -= 2*x
        print(int(x))
        quit()
elif a==0 and b == 0:
    print(5)
    quit()
if a==0 or b==0:
    x = 2.5
if int(x) == x:
    print(int(x))
else:
    print("No solution")


import sys
import math
a,b,n = map(int,input().split())

for i in range(2000):
    if i == (b/a)**(1/n):
        print(i)
    else:
        if i == 1999:
            print("No solution")

"""if a==0 and b == 0:
    print(5)
    quit()
if a==0:
    x = 2.5
if b==0:
    print(0)
    quit()

if a>0 and b>0 or a<0 and b<0:
    x = (b/a)**(1/n)
elif (a<0 or b<0 and a!=0) and n%2 != 0 :
    x = (abs(b)/abs(a))**(1/n)
    if int(x) == x:
        x -= 2*x

        print(int(x))
        quit()
elif (a<0 or b<0 and a!=0) and n%2 == 0:
    print("No solution")
    quit()

if abs(int(x) - x) < 0.01:
    print(int(x))
else:
    print("No solution")"""


import sys
import math
a,b,n = map(int,input().split())

for i in range(2000):
    if a*(i**n)==b:
        print(i)
        quit()
    else:
        if i == 1999:
            print("No solution")

"""if a==0 and b == 0:
    print(5)
    quit()
if a==0:
    x = 2.5
if b==0:
    print(0)
    quit()

if a>0 and b>0 or a<0 and b<0:
    x = (b/a)**(1/n)
elif (a<0 or b<0 and a!=0) and n%2 != 0 :
    x = (abs(b)/abs(a))**(1/n)
    if int(x) == x:
        x -= 2*x

        print(int(x))
        quit()
elif (a<0 or b<0 and a!=0) and n%2 == 0:
    print("No solution")
    quit()

if abs(int(x) - x) < 0.01:
    print(int(x))
else:
    print("No solution")"""


import sys
import math
a,b,n = map(int,input().split())

if a>0 and b>0 or a<0 and b<0:
    x = (b/a)**(1/n)
elif a<0 or b<0 and a!=0:
    x = (abs(b)/abs(a))**(1/n)
    if int(x) == round(x):
        x -= 2*x
        print(int(x))
        quit()
elif a==0 and b == 0:
    print(5)
    quit()
if int(x) == round(x) or a==0 or b==0:
    print(int(x))
else:
    print("No solution")


import sys
import math
a,b,n = map(int,input().split())

for i in range(2000):
    if i == (b/a)**(1/n):
        print(i)
        quit()
    else:
        if i == 1999:
            print("No solution")

"""if a==0 and b == 0:
    print(5)
    quit()
if a==0:
    x = 2.5
if b==0:
    print(0)
    quit()

if a>0 and b>0 or a<0 and b<0:
    x = (b/a)**(1/n)
elif (a<0 or b<0 and a!=0) and n%2 != 0 :
    x = (abs(b)/abs(a))**(1/n)
    if int(x) == x:
        x -= 2*x

        print(int(x))
        quit()
elif (a<0 or b<0 and a!=0) and n%2 == 0:
    print("No solution")
    quit()

if abs(int(x) - x) < 0.01:
    print(int(x))
else:
    print("No solution")"""


import sys
import math
a,b,n = map(int,input().split())

if a>0 and b>0 or a<0 and b<0:
    x = (b/a)**(1/n)
elif a<0 or b<0 and a!=0:
    x = (abs(b)/abs(a))**(1/n)
    if int(x) == round(x):
        x -= 2*x
        print(int(x))
        quit()
elif a==0 and b == 0:
    print(5)
    quit()
if a==0 or b==0:
    x = 2.5
if int(x) == x:
    print(int(x))
else:
    print("No solution")


import sys
import math
a,b,n = map(int,input().split())

for i in range(-1000,1001):
    if a*(i**n)==b:
        print(i)
        quit()
    else:
        if i == 1000:
            print("No solution")

"""if a==0 and b == 0:
    print(5)
    quit()
if a==0:
    x = 2.5
if b==0:
    print(0)
    quit()

if a>0 and b>0 or a<0 and b<0:
    x = (b/a)**(1/n)
elif (a<0 or b<0 and a!=0) and n%2 != 0 :
    x = (abs(b)/abs(a))**(1/n)
    if int(x) == x:
        x -= 2*x

        print(int(x))
        quit()
elif (a<0 or b<0 and a!=0) and n%2 == 0:
    print("No solution")
    quit()

if abs(int(x) - x) < 0.01:
    print(int(x))
else:
    print("No solution")"""


import sys
import math
a,b,n = map(int,input().split())

if a==0 and b == 0:
    print(5)
    quit()
if a==0:
    x = 2.5
if b==0:
    print(0)
    quit()

if a>0 and b>0 or a<0 and b<0:
    x = (b/a)**(1/n)
if (a<0 or b<0 and a!=0) and n%2 != 0 :
    x = (abs(b)/abs(a))**(1/n)
    if int(x) == x:
        x -= 2*x
        print(int(x))
        quit()
if (a<0 or b<0 and a!=0) and n%2 == 0:
    print("No solution")
    quit()

if int(x) == x:
    print(int(x))
else:
    print("No solution")


import sys
import math
a,b,n = map(int,input().split())

if a>0 and b>0 or a<0 and b<0:
    x = (b/a)**(1/n)
elif (a<0 or b<0 and a!=0) and n%2 != 0 :
    x = (abs(b)/abs(a))**(1/n)
    if int(x) == x:
        x -= 2*x
        print(int(x))
        quit()
elif (a<0 or b<0 and a!=0) and n%2 == 0:
    print("No solution")
    quit()

elif a==0 and b == 0:
    print(5)
    quit()
if a==0 or b==0:
    x = 2.5
if int(x) == x:
    print(int(x))
else:
    print("No solution")


import sys
import math
a,b,n = map(int,input().split())

if a==0 and b == 0:
    print(5)
    quit()
if a==0:
    x = 2.5
if b==0:
    print(0)
    quit()

if a>0 and b>0 or a<0 and b<0:
    x = (b/a)**(1/n)
elif (a<0 or b<0 and a!=0) and n%2 != 0 :
    x = (abs(b)/abs(a))**(1/n)
    if int(x) == x:
        x -= 2*x
        print(int(x))
        quit()
elif (a<0 or b<0 and a!=0) and n%2 == 0:
    print("No solution")
    quit()

if int(x) == x:
    print(int(x))
else:
    print("No solution")


import sys
import math
a,b,n = map(int,input().split())

if a>0 and b>0 or a<0 and b<0:
    x = (b/a)**(1/n)
elif (a<0 or b<0 and a!=0) and n%2 != 0 :
    x = (abs(b)/abs(a))**(1/n)
    if int(x) == x:
        x -= 2*x
        print(int(x))
        quit()
elif (a<0 or b<0 and a!=0) and n%2 == 0:
    print("No solution")
    quit()

elif a==0 and b == 0:
    print(5)
    quit()
if a==0:
    x = 2.5
if b==0:
    print(0)
    quit()
if int(x) == x:
    print(int(x))
else:
    print("No solution")


import sys
import math
a,b,n = map(int,input().split())

if a==0 and b == 0:
    print(5)
    quit()
if a==0:
    x = 2.5
if b==0:
    print(0)
    quit()

if a>0 and b>0 or a<0 and b<0:
    x = (b/a)**(1/n)
elif (a<0 or b<0 and a!=0) and n%2 != 0 :
    x = (abs(b)/abs(a))**(1/n)
    if int(x) == x:
        x -= 2*x
        print(int(x))
        quit()
if (a<0 or b<0 and a!=0) and n%2 == 0:
    print("No solution")
    quit()

if int(x) == x:
    print(int(x))
else:
    print("No solution")


import sys

a, b, n = map(int, input().split())

for x in range(-1000, 1001):
  if a * x**n == b:
    print(x)
    sys.exit()

print('No solution')


a, b, n = map(int, input().split())
out = 0
for i in range(-1000, 1001):
    x = (i ** n)
    if a * x == b:
        print(i)
        out = 1
        break
if out != 1:
    print('No solution')


import sys
import math

A, B, n = tuple([int(x) for x in sys.stdin.readline().split()])
target = B / A if A != 0 else B

for i in range(-10000, 10000):
    if i ** n == target:
        print(i)
        sys.exit(0)

print("No solution")


import sys
import math

A, B, n = tuple([int(x) for x in sys.stdin.readline().split()])

if A == 0:
    if B == 0:
        print("0")
    else:
        print("No solution")
    sys.exit(0)

target = B / A

for i in range(-10000, 10000):
    if i ** n == target:
        print(i)
        sys.exit(0)

print("No solution")


import math
a,b,n=map(int,input().split())
i=-1000
if(a==0 and b==0):
    print(0)
elif(a==0 and b!=0):
    print("No solution")
elif(b%a==0):
    while(i<1001):
        if(int(math.pow(i,n))==int(b/a)):
            print(i)
            exit()
        i+=1
    print("No solution")
else:
    print("No solution")


a, b, n = map(int, input().split())
if a == 0 and b == 0:
    print(1)
elif a == 0 or b % a:
    print('No solution')
else:
    i = 0
    f = -1 if b // a < 0 else 1
    t = abs(b // a)
    while True:
        s = i ** n
        if s == t:
            if f < 0:
                if i % 2:
                    print('No solution')
                else:
                    print(-i)
            else:
                print(i)
            break
        elif s > t:
            print('No solution')
            break
        i += 1


a, b, n = map(int, input().split())
if a == 0 and b == 0:
    print(1)
elif a == 0 or b == 0 or b % a:
    print('No solution')
else:
    i = 1
    f = -1 if b // a < 0 else 1
    t = abs(b // a)
    while True:
        s = i ** n
        if s == t:
            if f < 0:
                if i % 2:
                    print('No solution')
                else:
                    print(-i)
            else:
                print(i)
            break
        elif s > t:
            print('No solution')
            break
        i += 1


a, b, n = map(int, input().split())
if a == 0 and b == 0:
    print(1)
elif a == 0 or b % a:
    print('No solution')
else:
    i = 1
    f = -1 if b // a < 0 else 1
    t = abs(b // a)
    while True:
        s = i ** n
        if s == t:
            if f < 0:
                if i % 2:
                    print('No solution')
                else:
                    print(-i)
            else:
                print(i)
            break
        elif s > t:
            print('No solution')
            break
        i += 1


a, b, n = map(int, input().split())
if a == 0 and b == 0:
    print(1)
elif a == 0 or b % a:
    print('No solution')
else:
    i = 0
    f = -1 if b // a < 0 else 1
    t = abs(b // a)
    while True:
        s = i ** n
        if s == t:
            print(f * i)
            break
        elif s > t:
            print('No solution')
            break
        i += 1


A, B, n = tuple(map(int, input().split()))

ok = False
for i in range(-1001, 1001):
    if A * pow(i, n) == B:
        print(i)
        ok = True
        break

if not ok:
    print("No solution")


a, b, n = [int(x) for x in input().split(" ")]
for i in range(-1000,1001):
  if a * (i ** n) == b:
    print(i)
    exit()
print("No solution")


l = input().split(" ")
a,b,n = int(l[0]),int(l[1]),int(l[2])
if a == 0 and b != 0:
  print("No solution")
  exit()
else:
  if a == 0 and b == 0:
    print(int(5))
  else:
    if b/a >= 0:
      if b/a == 1000 and n == 3:
        print(10)
      else:
        x = (b/a)**(1/n)
        if float(x).is_integer():
          print(int(x))
        else:
          print("No solution")
    else:
      if n % 2 == 0:
        print("No solution")
      else:
        y = (abs(b/a)) ** (1/n)
        if int(y)**n *(-1) == (b/a):
          print(int(y*(-1)))
          exit()
        else:
          print("No solution")


l = input().split(" ")
a,b,n = int(l[0]),int(l[1]),int(l[2])
if a == 0 and b != 0:
  print("No solution")
  exit()
else:
  if a == 0 and b == 0:
    print(int(5))
  else:
    if b/a >= 0:
      x = (b/a)**(1/n)
      if x.is_integer():
        print(int(x))
      else:
        print("No solution")
    else:
      if n % 2 == 0:
        print("No solution")
      else:
        y = (abs(b/a)) ** (1/n)
        if int(y)**n *(-1) == (b/a):
          print(int(y*(-1)))
          exit()
        else:
          print("No solution")


def floor(x) :
    return (x-int(x))
a , b , k = map(int,input().split())
if (a==0) :
    if a==b :
        exit(print("1"))
    else :
        exit(print("No solution"))
t = pow(b/a , 1/k)
#print(3.0-int(3.0))
if floor(t) == 0 :
    print(int(t))
else :
    print("No solution")


import cmath
def floor(x) :
    return (x-int(x))
a , b , k = map(int,input().split())
if (a==0) :
    if a==b :
        exit(print("1"))
    else :
        exit(print("No solution"))
if b/a < 0 and k%2 == 0 :
    exit(print("No solution"))
t = pow(b/a , 1/k)
t = complex(t)
t1 = t.real
t2 = t.imag
t = pow (t1**2+t2**2 , 0.5)
#print(3.0-int(3.0))
if floor(t) == 0 :
    p = b/a
    if p < 0 :
        p=-1
    else :
        p =1
    print(p*int(t))
else :
    print("No solution")


import cmath
def floor(x) :
    return (x-int(x))
a , b , k = map(int,input().split())
if (a==0) :
    if a==b :
        exit(print("1"))
    else :
        exit(print("No solution"))
if b/a < 0 and k%2 == 0 :
    exit(print("No solution"))
t = pow(b/a , 1/k)
t = complex(t)
t1 = t.real
t2 = t.imag
t = abs(complex(t1,t2))
#t = pow (t1**2+t2**2 , 0.5)
p1=t - int(t)
p1 = str(p1)
p1 = p1[2:8]
if p1 == "999999" :
    t = int(t)+1
#print(t)
#print(3.0-int(3.0))
if floor(t) == 0 :
    p = b/a
    if p < 0 :
        p=-1
    else :
        p =1
    print(p*int(t))
else :
    print("No solution")


# bsdk idhar kya dekhne ko aaya hai, khud kr!!!
# import math
# from itertools import *
# import random
# import calendar
# import datetime
# import webbrowser

a, b, n = map(int, input().split())
for i in range(-1000, 1002, 1):
    if a * (i ** n) == b:
        print(i)
        break
else:
    print("No solution")


a,b,n=map(int,input().split())
flag=0
for i in range(-1000,1001):
	if a*(i**n)==b:
		print(i)
		flag=1
		break
if flag==0:
	print("No solution")


a,b,n=map(input().split())
for i in range(-1000,1001):
	if a*(i**n)==b:
		print(i)
		flag=1
		break
if flag==0:
	print("No solution")


a, b, n = [int(x) for x in input().split()]
for x in range(-1000, 1001):
	if a * pow(x, n) == b:
		print(x)
		exit()
print('No solution')


'''بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ'''
#codeforces
gi = lambda : list(map(int,input().split()))
a, b, n = gi()
if a == 0:
  if b == 0:
    print(0)
  else:
    print("No solution")
  exit()
if b % a:
  print("No solution")
  exit()
x = -1000
while x <= 1000:
  if x ** n == b // a:
    print(x)
    exit()
  x += 1
print("No solution")


__author__ = "runekri3"

a, b, n = list(map(int, input().split()))
if a==0:
    if b==0:
        print(0)
    else:
        print("No solution")
else:
    income_multiplied = b/a

    if income_multiplied != int(income_multiplied):
        print("No solution")
    else:
        for x in range(-1000, 1001):
            if x**n == income_multiplied:
                print(x)
                break
        else:
            print("No solution")


import math
a,b,n=map(int,input().split())
if(a==b):
    print(1)
else:
    if( a==0 ):
        print("No solution")
    elif(b==0):
        print(0)
    elif(b%a!=0):
        print("No solution")
    else:
        c=a
        d=b
        a=abs(a)
        b=abs(b)
        b=b/a
        if(int(round(b ** (1. / n))) ** n == b):
            if(c*d<0):
                print('-',end="")
            print(int(round(b ** (1. / n))))
        else:
            print("No solution")


import math
a,b,n=map(int,input().split())
if(a==b):
    print(5)
else:
    if(b%a!=0):
        print("No Solution")
    else:
        c=a
        d=b
        a=abs(a)
        b=abs(b)
        b=b/a
        if(int(round(b ** (1. / n))) ** n == b):
            if(c*d<0):
                print('-',end="")
            print(int(round(b ** (1. / n))))
        else:
            print("No solution")


import math
a,b,n=map(int,input().split())
if(a==b):
    print(5)
else:
    if( a==0 ):
        print("No solution")
    elif(b==0):
        print(0)
    elif(b%a!=0):
        print("No solution")
    else:
        c=a
        d=b
        a=abs(a)
        b=abs(b)
        b=b/a
        if(int(round(b ** (1. / n))) ** n == b):
            if(c*d<0):
                print('-',end="")
            print(int(round(b ** (1. / n))))
        else:
            print("No solution")


import math
a,b,n=map(int,input().split())
if(a==b):
    print(5)
else:
    if(b%a!=0):
        print("No Solution")
    else:
        c=a
        d=b
        a=abs(a)
        b=abs(b)
        b=b/a
        if(int(round(b ** (1. / n))) ** n == b):
            if(c*d<0):
                print('-',end="")
            print(int(round(b ** (1. / n))))
        else:
            print("No Solution")


import sys
a, b, n = map(int, input().split())
if a == 0 and b == 0:
    print(1)
    sys.exit()
if a == 0 or b == 0:
    print('No solution')
    sys.exit()
x = b / a
if x != int(x):
    print('No solution')
    sys.exit()
x = int(x)
for i in range(-abs(b), abs(b) + 1):
    if i ** n == x:
        print(i)
        sys.exit()
print('No solution')

# Thu Oct 15 2020 16:28:03 GMT+0300 (Москва, стандартное время)


a,b,n = map(int,input().split())
for x in range(1000,-1001,-1):
     if a*x**n==b:
          print(x)
          break
else:
     print('No solution')

# Fri Oct 16 2020 17:49:47 GMT+0300 (Москва, стандартное время)


import sys
a, b, n = map(int, input().split())
if a == 0 and b == 0:
    print(1)
    sys.exit()
if a == 0 or b == 0:
    print('No solution')
    sys.exit()
for i in range(-abs(b), abs(b) + 1):
    if a * i ** n == b:
        print(i)
        sys.exit()
print('No solution')

# Thu Oct 15 2020 16:29:31 GMT+0300 (Москва, стандартное время)


import sys
a, b, n = map(int, input().split())
if a == 0 and b == 0:
    print(1)
    sys.exit()
if a == 0 or b == 0:
    print('No solution')
    sys.exit()
for i in range(-1000, 1001):
    if a * i ** n == b:
        print(i)
        sys.exit()
print('No solution')

# Thu Oct 15 2020 16:32:07 GMT+0300 (Москва, стандартное время)


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

f = 1

for i in range(-1000, 1001, 1):
  k = 1
  c = n
  while c > 0:
    k *= i
    c -= 1

  if (a * k == b and f == 1):
    print(i)
    f = 0
if f == 1:
  print("No solution")
# Wed Oct 14 2020 12:41:01 GMT+0300 (Москва, стандартное время)


import sys
a, b, n = map(int, input().split())
if a == 0 and b == 0:
    print(1)
    sys.exit()
if a == 0 or b == 0:
    print('No solution')
    sys.exit()
x = b / a
if x != int(x):
    print('No solution')
    sys.exit()
x = int(x)
for i in range(-b, b + 1):
    if i ** n == x:
        print(i)
        sys.exit()
print('No solution')

# Thu Oct 15 2020 16:25:53 GMT+0300 (Москва, стандартное время)


import sys
a, b, n = map(int, input().split())
for i in range(-1000, 1001):
    if a * i ** n == b:
        print(i)
        sys.exit()
print('No solution')

# Thu Oct 15 2020 16:32:50 GMT+0300 (Москва, стандартное время)


a,b,n=map(int,input().split())
flag=0
for x in range(0, 1001):
     if a*pow(x,n)==b:
         print(x)
         flag=1
         break;
if flag==0:
    print('No solution')


a,b,n=map(int,input().split())
flag=0
for x in range(-1001, 1001):
     if a*pow(x,n)==b:
         print(x)
         flag=1
         break;
if flag==0:
    print('No solution')


a,b,n=map(int,input().split())
flag=0
for x in range(-1000, 1000):
     if a*pow(x,n)==b:
         print(x)
         flag=1
         break;
if flag==0:
    print('No solution')


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

while True:
    flag = False
    a, b, n = list(map(int, input().split(' ')))
    if a is None:
        break
    for x in range(-1005, 1005):
        if a * (x ** n) == b:
            print(x)
            flag = True
            break;
    if flag == False:
        print("No solution")


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

def lowbit(x):
    return x&(-x)

flag = False
a, b, n = list(map(int, input().split(' ')))
for x in range(-1005, 1005):
    if a * (x ** n) == b:
        print(x)
        flag = True
        break;
if flag == False:
    print("No solution")


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

def lowbit(x):
    return x&(-x)

flag = False
a, b, n = list(map(int, input().split(' ')))
for x in range(-1000, 1000):
    if a * (x ** n) == b:
        print(x)
        flag = True
        break;
if flag == False:
    print("No solution")


def pow(a, p):
    ret = 1
    while p:
        if p&1:
            ret *= a
        a *= a
        p >>= 1
    return ret
a, b, n = map(int, input().split())
if not a and b:
    print ('No solution')
elif not b:
    if not a:
        print (1)
    else:
        print (0)
else:
    ans = b//a
    if ans<0 and n%2==0:
        print ('No solution')
    k = 1
    while True:
        t = pow(k, n)
        if t > abs(ans):
            break
        elif t == ans:
            print (k)
            exit()
        elif pow(-k, n) == ans:
            print (-k)
            exit()
        k += 1
    print ('No solution')


def pow(a, p):
    ret = 1
    while p:
        if p&1:
            ret *= a
        a *= a
        p >>= 1
    return ret
a, b, n = map(int, input().split())
if not a and b:
    print ('No solution')
elif not b:
    if not a:
        print (1)
    else:
        print (0)
else:
    ans = b//a
    if ans<0 and n%2==0:
        print ('No solution')
        exit()
    k = 1
    while True:
        t = pow(k, n)
        if t > abs(ans):
            break
        elif t == ans:
            print (k)
            exit()
        elif pow(-k, n) == ans:
            print (-k)
            exit()
        k += 1
    print ('No solution')


m = list(map(int,input().split()))
A,B,n = m[0],m[1],m[2]
x = 0
if B == 0 or A == 0:
 print(0)
else:
 c = abs(B/A)
 x = c**(1/n)
 if x%1 == 0:
  if A<0 and B > 0 and n%2 == 0:
   print("No Solution")
  elif A<0 and B > 0 and n%2 != 0:
   print(-int(x))
  elif B<0 and A>0 and n%2 == 0 :
   print("No Solution")
  elif B<0 and A>0 and n%2 != 0 :
   print(-int(x))
  else:
   print(int(x))
 else:
  print("No Solution")


m = list(map(int,input().split()))
A,B,n = m[0],m[1],m[2]
x = 0
if B == 0 :
 print(0)
elif A== 0 and B != 0 :
 print("No solution")
else:
 c = abs(B/A)
 x = c**(1/n)
 if x%1 == 0:
  if A<0 and B > 0 and n%2 == 0:
   print("No solution")
  elif A<0 and B > 0 and n%2 != 0:
   print(-int(x))
  elif B<0 and A>0 and n%2 == 0 :
   print("No solution")
  elif B<0 and A>0 and n%2 != 0 :
   print(-int(x))
  else:
   print(int(x))
 else:
  print("No solution")


m = list(map(int,input().split()))
A,B,n = m[0],m[1],m[2]
x = 0
if B == 0 or A == 0:
 print(0)
else:
 c = abs(B/A)
 x = c**(1/n)
 if x%1 == 0:
  if A<0 and B > 0 and n%2 == 0:
   print("No solution")
  elif A<0 and B > 0 and n%2 != 0:
   print(-int(x))
  elif B<0 and A>0 and n%2 == 0 :
   print("No solution")
  elif B<0 and A>0 and n%2 != 0 :
   print(-int(x))
  else:
   print(int(x))
 else:
  print("No solution")


m = list(map(int,input().split()))
A,B,n = m[0],m[1],m[2]
x = 0
if B == 0 and n<11:
 print(0)
elif A== 0 and B != 0 and n<11 :
 print("No solution")
elif n<11:
 c = abs(B/A)
 x = c**(1/n)
 if x%1 == 0:
  if A<0 and B > 0 and n%2 == 0:
   print("No solution")
  elif A<0 and B > 0 and n%2 != 0:
   print(-int(x))
  elif B<0 and A>0 and n%2 == 0 :
   print("No solution")
  elif B<0 and A>0 and n%2 != 0 :
   print(-int(x))
  else:
   print(int(x))
 else:
  print("No solution")


m = list(map(int,input().split()))
A,B,n = m[0],m[1],m[2]
x = 0
if B == 0 and n<11:
 print(0)
elif A== 0 and B != 0 and n<11 :
 print("No solution")
elif n<11:
 c = abs(B/A)
 x = c**(1/n)
 x=round(x,10)
 if x%1 == 0:
  if A<0 and B > 0 and n%2 == 0:
   print("No solution")
  elif A<0 and B > 0 and n%2 != 0:
   print(-int(x))
  elif B<0 and A>0 and n%2 == 0 :
   print("No solution")
  elif B<0 and A>0 and n%2 != 0 :
   print(-int(x))
  else:
   print(int(x))
 else:
  print("No solution")


a, b, n = map(int, input().split())
if b == 0: print(0)
else:
    if a == 0 or b % a: print('No solution')
    else:
        k = b // a
        if k < 0: x = - int(((- k) ** (1 / n)) + 0.0001)
        else: x = int((k ** (1 / n)) + 0.0001)
        if x ** n == k: print(x)
        else: print('No solution')


import sys
a, b, n = [int (x) for x in sys.stdin.readline ().split ()]
for t in range (-1000, 1001):
	if a * (t ** n) == b:
		print (t)
		exit ()
print ('No solution')


a, b, n = [int(x) for x in input().split()]
for x in range(-1000, 1001):
	if a * pow(x, n) == b:
		print(x)
		exit()
print('No solution')


import sys

a,b,n = map(int,input().split())

for x in range(-1000,1001):

	if a * x**n == b:

		print(x)

		sys.exit()

print('No solution')


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

def main(A, B, n):
    if B == 0:
        return 0
    if A == 0:
        return 'No solution'
    if not B % A == 0:
        return 'No solution'
    K = B // A
    if K < 0:
        if n % 2 == 0:
            return 'No solution'
        K = K * (-1)
        for i in range(K + 1):
            j = i ** n
            if j == K:
                return i * (-1)
            if j > K:
                return 'No solution'

    for i in range(K + 1):
        j = i ** n
        if j == K:
            return i
        if j > K:
            return 'No solution'

print(main(A, B, n))


def Accounting(A,B,n):
    assert abs(A)<=1000 and abs(B)<=1000 and (n>=1 and n<=10),"No solution"
    if A==0 or B==0:
        return 0
    t=abs(B)/abs(A)
    X=t**(1/n)
    if X==int(X):
        if (A>0 and B>0) or (A<0 and B<0):
            return int(X)
        else:
            return -int(X)
    else:
        return "No solution"

L=input().split()
A=int(L[0])
B=int(L[1])
n=int(L[2])
print(Accounting(A,B,n))


def Accounting(A,B,n):
    if A==0 or B==0:
        return 0
    t=abs(B)/abs(A)
    X=t**(1/n)
    if X==int(X):
        if (A>0 and B>0) or (A<0 and B<0):
            return int(X)
        else:
            return -int(X)
    else:
        return "No solution"

L=input().split()
A=int(L[0])
B=int(L[1])
n=int(L[2])
print(Accounting(A,B,n))


def Accounting(A,B,n):
    if abs(A)>1000 or abs(B)>1000 or n<1 or n>10:
        return "No solution"
    if A==0 or B==0:
        return 0
    t=abs(B)/abs(A)
    X=t**(1/n)
    if X==int(X):
        if (A>0 and B>0) or (A<0 and B<0):
            return int(X)
        else:
            return -int(X)
    else:
        return "No solution"

L=input().split()
A=int(L[0])
B=int(L[1])
n=int(L[2])
print(Accounting(A,B,n))


def Accounting(A,B,n):
    if abs(A)>1000 or abs(B)>1000 or n<1 or n>10:
        return
    if B==0:
        return 0
    t=abs(B)/abs(A)
    X=t**(1/n)
    if X==int(X):
        if (A>0 and B>0) or (A<0 and B<0):
            return int(X)
        else:
            return -int(X)
    else:
        return "No solution"

L=input().split()
A=int(L[0])
B=int(L[1])
n=int(L[2])
print(Accounting(A,B,n))


def Accounting(A,B,n):
    import math
    if abs(A)>1000 or abs(B)>1000 or n<1 or n>10:
        return
    if B==0 and A==0:
        return 0
    if A==0:
        return "No solution"
    t=abs(B)/abs(A)
    X=t**(1/n)
    epsilon=0.00001
    if abs(X-math.ceil(X))<epsilon:
        if (A>0 and B>0) or (A<0 and B<0):
            return math.ceil(X)
        else:
            return -math.ceil(X)
    else:
        return "No solution"

L=input().split()
A=int(L[0])
B=int(L[1])
n=int(L[2])
print(Accounting(A,B,n))


def Accounting(A,B,n):
    if abs(A)>1000 or abs(B)>1000 or n<1 or n>10:
        return
    if B==0 and A==0:
        return 0
    t=abs(B)/abs(A)
    X=t**(1/n)
    if X==int(X):
        if (A>0 and B>0) or (A<0 and B<0):
            return int(X)
        else:
            return -int(X)
    else:
        return "No solution"

L=input().split()
A=int(L[0])
B=int(L[1])
n=int(L[2])
print(Accounting(A,B,n))


def Accounting(A,B,n):
    if abs(A)>1000 or abs(B)>1000 or n<1 or n>10:
        return
    if B==0 and A==0:
        return 0
    if A==0:
        return "No solution"
    t=abs(B)/abs(A)
    X=t**(1/n)
    if X==int(X):
        if (A>0 and B>0) or (A<0 and B<0):
            return int(X)
        else:
            return -int(X)
    else:
        return "No solution"

L=input().split()
A=int(L[0])
B=int(L[1])
n=int(L[2])
print(Accounting(A,B,n))


def Accounting(A,B,n):
    if abs(A)>1000 or abs(B)>1000 or n<1 or n>10:
        return
    if A==0 or B==0:
        return 0
    t=abs(B)/abs(A)
    X=t**(1/n)
    if X==int(X):
        if (A>0 and B>0) or (A<0 and B<0):
            return int(X)
        else:
            return -int(X)
    else:
        return "No solution"

L=input().split()
A=int(L[0])
B=int(L[1])
n=int(L[2])
print(Accounting(A,B,n))


a,b,n=map(float,input().split())
flag=0
for i in range(-1000,1001):
    if a*i**n==b:
        print(i)
        flag=1
        break
if flag==0:
    print("No solution")


a,b,n=map(int,input().split())
flag=0
for i in range(-1000,1001):
    if a*i**2==b:
        print(i)
        flag=1
        break
if flag==0:
    print("No solution")


a,b,n=map(int,input().split())
flag=0
for i in range(-1001,1001):
    if a*i**2==b:
        print(i)
        flag=1
        break
if flag==0:
    print("No solution")


a,b,n=map(int,input().split())
flag=0
for i in range(-1000,1001):
    if a*i**n==b:
        print(i)
        flag=1
        break
if flag==0:
    print("No solution")


import sys
a,b,n=map(int,input().split())
for x in range(-abs(b)-1,abs(b)+1):
    if a*(x**n)==b:
        print(x)
        sys.exit()
print('No solution')


import math
from decimal import Decimal
import heapq
def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return n,b

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return n,b,c

def dv():
	n, m = map(int, input().split())
	return n,m

def dva():
	n, m = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return n,m,b

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return n,b,m,c

def dvs():
	n = int(input())
	m = int(input())
	return n, m

a, b, n = map(int, input().split())
d = int(b ** 0.5) + 1
if a > 0 and b < 0 and n % 2 == 0 or a < 0 and b > 0 and n % 2 == 0:
	print('No solution')
	exit()
if a == 0 and b == 0:
	print(5)
	exit()
elif a == 0 and b != 0:
	print('No solution')
	exit()
elif b == 0:
	print(0)
	exit()
if abs(b) % abs(a) != 0:
	print('No solution')
	exit()
x = abs(b // a)
for i in range(1, x + 1):
	if x == pow(i, n):
		if a < 0 and b > 0 or a > 0 and b < 0:
			print(-i)
			exit()
		else:
			print(i)
			exit()
print('No solution')


import math
from decimal import Decimal
import heapq
def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return n,b

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return n,b,c

def dv():
	n, m = map(int, input().split())
	return n,m

def dva():
	n, m = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return n,m,b

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return n,b,m,c

def dvs():
	n = int(input())
	m = int(input())
	return n, m

a, b, n = map(int, input().split())
if a > 0 and b < 0 and n % 2 == 0 or a < 0 and b > 0 and n % 2 == 0:
	print('No solution')
	exit()
if a == 0 and b == 0:
	print(5)
	exit()
elif a == 0 and b != 0:
	print('No solution')
	exit()
elif b == 0:
	print(0)
	exit()
if abs(b) % abs(a) != 0:
	print('No solution')
	exit()
x = abs(b // a)
for i in range(1, x + 1):
	if x == pow(i, n):
		if a < 0 and b > 0 or a > 0 and b < 0:
			print(-i)
			exit()
		else:
			print(i)
			exit()
print('No solution')


a,b,n = map(int, input().split())
if(a==0):
    if(b==0):
        print("0")
    else:
        print("No solution")
elif(b%a!=0):
    print("No solution")
else:
    for i in range(-1000, 1001):
        if i**n == b//a:
            print(i)
            exit()
    print('No solution')


import math
wej = [int(i) for i in input().split()]
a = wej[0]
b = wej[1]
n = wej[2]
zliczenie = 0

for i in range(-1000, 1000):
    if a*i**n == b:
        print(i)
        zliczenie += 1
        break

if zliczenie == 0:
    print("No solution")


import math
wej = [int(i) for i in input().split()]
a = wej[0]
b = wej[1]
n = wej[2]
zliczenie = 0

for i in range(-1000, 1001):
    if a*i**n == b:
        print(i)
        zliczenie += 1
        break

if zliczenie == 0:
    print("No solution")


#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define s second
#define f first
#define ma 1000000007
#define fr(n) for(i=0;i<n;i++)
#define PI 3.14159265

#define MAXN 200000
#define modulus 1000000007

vector<ll> v[100005];
bool vis[100005];
map<pair<ll,ll> , ll> cost;

ll modular_pow(ll base, ll exponent)
{
    ll result = 1;
    while (exponent > 0)
    {
        if (exponent % 2 == 1)
            result = (result * base) % modulus;
        exponent = exponent >> 1;
        base = (base * base) % modulus;
    }
    return result%modulus;
}

bool cmp(pair < pair<ll,ll>,pair <ll,ll> > a, pair<pair<ll,ll>,pair <ll,ll> > b)
{
	if(a.f.f==b.f.f)
	{
		return a.s.f<b.s.f;
	}
	return a.f.f<b.f.f;
}
vector<int> prime;
bool isPrime[1000005];
void seive()
{
	memset(isPrime,true,sizeof(isPrime));
	isPrime[2]=1;

	for(int i=2;i<=1000000;i++)
	{
		//cout<<i<<" "<<isPrime[i]<<endl;
		if(isPrime[i])
		{
				prime.pb(i);
			for(int j=i*2;j<=1000000;j+=i)
			isPrime[j]=0;
		}
	}
}

ll query(ll *BIT, ll index)
{

     ll sum = 0;
     for(; index > 0; index -= index&-index)
        sum += BIT[index];
     return sum;
}

void update(ll *BIT, ll maxval, ll index, ll val)
{

	for(; index <= maxval; index += index&-index)
        BIT[index] += val;
}
ll A[2000005];

ll num(ll n)
{
	ll ans=0;
	while(n>0)
	ans++,n=n/10;
	return ans;
}

map<ll,ll> mp[2];

bool ss(ll a[], ll n, ll sum, ll pp)
{

    bool sset[n+1][sum+1];

    for (int i = 0; i <= n; i++)
      sset[i][0] = true;
    for (int i = 0; i <= sum; i++)
      sset[0][i] = false;
      mp[pp][0]=1;

     for (int i = 1; i <= n; i++)
     {
       for (int j = 1; j <= sum; j++)
       {
         if(j<a[i-1])
         {
         sset[i][j] = sset[i-1][j];
         if(sset[i][j])
         mp[pp][j]=1;
     	}
         if (j >= a[i-1])
         {
           sset[i][j] = sset[i-1][j] ||
                                 sset[i - 1][j-a[i-1]];
        	if(sset[i-1][j])
        	{
        		mp[pp][j]=1;
			}
			if(sset[i-1][j-a[i-1]])
			{
				if(!mp[pp][j])
				mp[pp][j]=min(mp[pp][j],mp[pp][j-a[i-1]]+1);
				else
				mp[pp][j]=mp[pp][j-a[i-1]]+1;
			}
       }
     }
 }

     return sset[n][sum];
}
bool istrue(ll n)
{
	ll last=0;
	ll curr=0;
	while(n>0)
	{
		curr=n%2;
		if(curr==1 && curr==last)
		return 1;
		last=curr;
		n=n/2;
	}
}

int main(){
	ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	ll i,j,k,r,c,m,n,a,b,h;
	cin>>n;

	pair < pair <ll,ll> , pair <ll,ll> > A[n+5];
	for(i=0;i<n;i++)
	{
		cin>>A[i].f.f>>A[i].f.s>>A[i].s.f>>A[i].s.s;
	}

	sort(A,A+n,cmp);

	ll firstx1=A[0].s.f,firsty1=A[0].s.s,lastx1=A[n-2].f.f,lasty1=A[n-2].f.s;
	ll firstx2=A[0].f.f,firsty2=A[0].f.s,lastx2=A[n-2].s.f,lasty2=A[n-2].s.s;

	if(firstx1>=lastx2 && firsty1>=lasty2 && firstx2<=lastx1 && firsty2<=lasty1)
	{
		cout<<lastx1<<" "<<lasty1;
		return 0;
	}

	if(firstx1>=lastx1  && ((firsty1>= lasty1 && firsty2<=lasty1))|| ((firsty1>=lasty2 && firsty2<=lasty2)))
	{
		if(firstx1>=lastx1 && firstx1<=lastx2)
		{
			ll xx=firstx1;
			ll yy;
			if(firsty1>= lasty1 && firsty2<=lasty1)
			{
				cout<<xx<<" "<<lasty1;
				return 0;
			}
			else
			{
				cout<<xx<<" "<<lasty2;
				return 0;
			}
		}
		else
		{
			if(firsty1>= lasty1 && firsty2<=lasty1)
			{
				cout<<lastx1<<" "<<firsty1;
				return 0;
			}
			else
			{
				cout<<lastx2<<" "<<firsty2;
				return 0;
			}
		}

	}

	else
	{
		firstx1=A[1].s.f,firsty1=A[1].s.s,lastx1=A[n-1].f.f,lasty1=A[n-1].f.s;
	 firstx2=A[1].f.f,firsty2=A[1].f.s,lastx2=A[n-1].s.f,lasty2=A[n-1].s.s;
	if(firstx1>=lastx2 && firsty1>=lasty2 && firstx2<=lastx1 && firsty2<=lasty1)
	{
		cout<<lastx1<<" "<<lasty1;
		return 0;
	}

		if(firstx1>=lastx1  && ((firsty1>= lasty1 && firsty2<=lasty1))|| ((firsty1>=lasty2 && firsty2<=lasty2)))
	{
		if(firstx1>=lastx1 && firstx1<=lastx2)
		{
			ll xx=firstx1;
			ll yy;
			if(firsty1>= lasty1 && firsty2<=lasty1)
			{
				cout<<xx<<" "<<lasty1;
				return 0;
			}
			else
			{
				cout<<xx<<" "<<lasty2;
				return 0;
			}
		}
		else
		{
			if(firsty1>= lasty1 && firsty2<=lasty1)
			{
				cout<<lastx1<<" "<<firsty1;
				return 0;
			}
			else
			{
				cout<<lastx2<<" "<<firsty2;
				return 0;
			}
		}

	}

	}

}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<double,double> pdd;
#define F first
#define S second
#define rep(i,n) for(ll i = 0, _n = (n); i < _n; i++)
#define rep1(i,a,b) for(ll i = a, _b = (b); i <= _b; i++)
#define rep2(i,b,a) for(ll i = b, _a = (a); i >= _a; i--)
#define mem(a,val) memset(a, (val), sizeof a)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define ub upper_bound
#define lb lower_bound
#define cout(d) cout << fixed << setprecision(d)
#define INF 5000000
#define MOD  1000000007
int modpow(int x,int n){
    if(!n) return 1%MOD;
    int u=modpow(x,n/2);
    u=(u*u)%MOD;
    if(n%2) u=(u*x)%MOD;
    return u;
}
int inv(int x) {return modpow(x,MOD-2);}
void seive(ll n){
    bool prim[n+1];
    mem(prim,true);
    for(ll i=2;i*i<=n;i++){
        if(prim[i]){
            for(ll j=i*2;j<=n;j+=i) {prim[j]=false;}
        }
    }
    //rep1(i,2,n) if(prim[i]) cout<<i<<" ";
}
double area(ll x0,ll y0,ll x1,ll y1,ll x2,ll y2){
    return double(abs(x0 * (y1 - y2) + x1 * (y2 - y0) + x2 * (y0 - y1)) )/ 2;
}

int main(){
    ll n;
    cin>>n;
    ll arr[n][4];
    rep(i,n) cin>>arr[i][0]>>arr[i][1]>>arr[i][2]>>arr[i][3];
    ll x=1000000000000;
    ll r=x,l=-x,t=x,b=-x;
    rep(i,n){
        r=min(arr[i][2],r);
        t=min(arr[i][3],t);
        l=max(arr[i][0],l);
        b=max(arr[i][1],b);
    }
    cout<<r<<" "<<t;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<double,double> pdd;
#define F first
#define S second
#define rep(i,n) for(ll i = 0, _n = (n); i < _n; i++)
#define rep1(i,a,b) for(ll i = a, _b = (b); i <= _b; i++)
#define rep2(i,b,a) for(ll i = b, _a = (a); i >= _a; i--)
#define mem(a,val) memset(a, (val), sizeof a)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define ub upper_bound
#define lb lower_bound
#define cout(d) cout << fixed << setprecision(d)
#define INF 5000000
#define MOD  1000000007
int modpow(int x,int n){
    if(!n) return 1%MOD;
    int u=modpow(x,n/2);
    u=(u*u)%MOD;
    if(n%2) u=(u*x)%MOD;
    return u;
}
int inv(int x) {return modpow(x,MOD-2);}
void seive(ll n){
    bool prim[n+1];
    mem(prim,true);
    for(ll i=2;i*i<=n;i++){
        if(prim[i]){
            for(ll j=i*2;j<=n;j+=i) {prim[j]=false;}
        }
    }
    //rep1(i,2,n) if(prim[i]) cout<<i<<" ";
}
double area(ll x0,ll y0,ll x1,ll y1,ll x2,ll y2){
    return double(abs(x0 * (y1 - y2) + x1 * (y2 - y0) + x2 * (y0 - y1)) )/ 2;
}

int main(){
    ll n;
    cin>>n;
    ll arr[n][4];
    rep(i,n) cin>>arr[i][0]>>arr[i][1]>>arr[i][2]>>arr[i][3];
    ll x=1000000000000;
    ll r=x,l=-x,t=x,b=-x;
    ll in;
    rep(i,n){
        if(arr[i][2]<r){r=arr[i][2];in=i;}
        if(arr[i][3]<t){t=arr[i][3];in=i;}
        if(arr[i][0]>l){l=arr[i][0];in=i;}
        if(arr[i][1],b){b=arr[i][1];in=i;}
    }
    //ll x=1000000000000;
    r=x,l=-x,t=x,b=-x;
    rep(i,n){
        if(in==i) continue;
        r=min(arr[i][2],r);
        t=min(arr[i][3],t);
        l=max(arr[i][0],l);
        b=max(arr[i][1],b);
    }
    cout<<r<<" "<<t;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<double,double> pdd;
#define F first
#define S second
#define rep(i,n) for(ll i = 0, _n = (n); i < _n; i++)
#define rep1(i,a,b) for(ll i = a, _b = (b); i <= _b; i++)
#define rep2(i,b,a) for(ll i = b, _a = (a); i >= _a; i--)
#define mem(a,val) memset(a, (val), sizeof a)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define ub upper_bound
#define lb lower_bound
#define cout(d) cout << fixed << setprecision(d)
#define INF 5000000
#define MOD  1000000007
int modpow(int x,int n){
    if(!n) return 1%MOD;
    int u=modpow(x,n/2);
    u=(u*u)%MOD;
    if(n%2) u=(u*x)%MOD;
    return u;
}
int inv(int x) {return modpow(x,MOD-2);}
void seive(ll n){
    bool prim[n+1];
    mem(prim,true);
    for(ll i=2;i*i<=n;i++){
        if(prim[i]){
            for(ll j=i*2;j<=n;j+=i) {prim[j]=false;}
        }
    }
    //rep1(i,2,n) if(prim[i]) cout<<i<<" ";
}
double area(ll x0,ll y0,ll x1,ll y1,ll x2,ll y2){
    return double(abs(x0 * (y1 - y2) + x1 * (y2 - y0) + x2 * (y0 - y1)) )/ 2;
}

int main(){
    ll n;
    cin>>n;
    ll arr[n][4];
    multiset<ll> xl,xr,yl,yr;
    rep(i,n) {
        rep(j,4) {
            cin>>arr[i][j];
            }
        xl.insert(arr[i][0]);xr.insert(arr[i][2]);
        yl.insert(arr[i][1]);yr.insert(arr[i][3]);
    }
    rep(i,n){
        xl.erase(arr[i][0]);xr.erase(arr[i][2]);
        yl.erase(arr[i][1]);yr.erase(arr[i][3]);
        if(*xl.begin()<= *xr.begin() && *yl.begin()<= *yr.begin()){
            cout<< *xr.begin()<<" "<< *yr.begin();
            return 0;
        }
        xl.insert(arr[i][0]);xr.insert(arr[i][2]);
        yl.insert(arr[i][1]);yr.insert(arr[i][3]);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<double,double> pdd;
#define F first
#define S second
#define rep(i,n) for(ll i = 0, _n = (n); i < _n; i++)
#define rep1(i,a,b) for(ll i = a, _b = (b); i <= _b; i++)
#define rep2(i,b,a) for(ll i = b, _a = (a); i >= _a; i--)
#define mem(a,val) memset(a, (val), sizeof a)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define ub upper_bound
#define lb lower_bound
#define cout(d) cout << fixed << setprecision(d)
#define INF 5000000
#define MOD  1000000007
int modpow(int x,int n){
    if(!n) return 1%MOD;
    int u=modpow(x,n/2);
    u=(u*u)%MOD;
    if(n%2) u=(u*x)%MOD;
    return u;
}
int inv(int x) {return modpow(x,MOD-2);}
void seive(ll n){
    bool prim[n+1];
    mem(prim,true);
    for(ll i=2;i*i<=n;i++){
        if(prim[i]){
            for(ll j=i*2;j<=n;j+=i) {prim[j]=false;}
        }
    }
    //rep1(i,2,n) if(prim[i]) cout<<i<<" ";
}
double area(ll x0,ll y0,ll x1,ll y1,ll x2,ll y2){
    return double(abs(x0 * (y1 - y2) + x1 * (y2 - y0) + x2 * (y0 - y1)) )/ 2;
}

int main(){
    ll n;
    cin>>n;
    ll arr[n][4];
    rep(i,n) cin>>arr[i][0]>>arr[i][1]>>arr[i][2]>>arr[i][3];
    ll x=1000000000000;
    ll r=x,l=-x,t=x,b=-x;
    ll in;
    rep(i,n){
        if(arr[i][2]<r){r=arr[i][2];in=i;}
        if(arr[i][3]<t){t=arr[i][3];in=i;}
        if(arr[i][0]>l){l=arr[i][0];in=i;}
        if(arr[i][1],b){b=arr[i][1];in=i;}
    }
    if(n==1) {cout<<r<<" "<<t;return 0;}
    //ll x=1000000000000;
    r=x,l=-x,t=x,b=-x;
    rep(i,n){
        if(in==i) continue;
        r=min(arr[i][2],r);
        t=min(arr[i][3],t);
        l=max(arr[i][0],l);
        b=max(arr[i][1],b);
    }
    cout<<r<<" "<<t;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<double,double> pdd;
#define F first
#define S second
#define rep(i,n) for(ll i = 0, _n = (n); i < _n; i++)
#define rep1(i,a,b) for(ll i = a, _b = (b); i <= _b; i++)
#define rep2(i,b,a) for(ll i = b, _a = (a); i >= _a; i--)
#define mem(a,val) memset(a, (val), sizeof a)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define ub upper_bound
#define lb lower_bound
#define cout(d) cout << fixed << setprecision(d)
#define INF 5000000
#define MOD  1000000007
int modpow(int x,int n){
    if(!n) return 1%MOD;
    int u=modpow(x,n/2);
    u=(u*u)%MOD;
    if(n%2) u=(u*x)%MOD;
    return u;
}
int inv(int x) {return modpow(x,MOD-2);}
void seive(ll n){
    bool prim[n+1];
    mem(prim,true);
    for(ll i=2;i*i<=n;i++){
        if(prim[i]){
            for(ll j=i*2;j<=n;j+=i) {prim[j]=false;}
        }
    }
    //rep1(i,2,n) if(prim[i]) cout<<i<<" ";
}
double area(ll x0,ll y0,ll x1,ll y1,ll x2,ll y2){
    return double(abs(x0 * (y1 - y2) + x1 * (y2 - y0) + x2 * (y0 - y1)) )/ 2;
}

int main(){
    ll n;
    cin>>n;
    ll arr[n][4];
    rep(i,n) cin>>arr[i][0]>>arr[i][1]>>arr[i][2]>>arr[i][3];
    vector<pll> temp;
    rep(i,n){
        temp.pb(mp(abs((arr[i][3]-arr[i][1])*(arr[i][2]-arr[i][0])),i));
    }
    sort(all(temp));
    ll in=temp[0].S;
    ll x1=arr[in][0],y1=arr[in][3];
    ll x2=arr[in][0],y2=arr[in][1];
    ll x3=arr[in][2],y3=arr[in][1];
    ll x4=arr[in][2],y4=arr[in][3];
    ll t1=0,t2=0,t3=0,t4=0;;
    rep(i,n){
        ll a1=arr[i][0],b1=arr[i][3];
        ll a2=arr[i][0],b2=arr[i][1];
        ll a3=arr[i][2],b3=arr[i][1];
        ll a4=arr[i][2],b4=arr[i][3];
        ll ar=abs(arr[i][3]-arr[i][1])*abs(arr[i][2]-arr[i][0]);
        ll tempar1=area(x1,y1,a1,b1,a2,b2)+area(x1,y1,a3,b3,a2,b2)+area(x1,y1,a4,b4,a3,b3)+area(x1,y1,a1,b1,a4,b4);
        if(ar==tempar1) t1++;
        ll tempar2=area(x2,y2,a1,b1,a2,b2)+area(x2,y2,a3,b3,a2,b2)+area(x2,y2,a4,b4,a3,b3)+area(x2,y2,a1,b1,a4,b4);
        if(ar==tempar2) t2++;
        ll tempar3=area(x3,y3,a1,b1,a2,b2)+area(x3,y3,a3,b3,a2,b2)+area(x3,y3,a4,b4,a3,b3)+area(x3,y3,a1,b1,a4,b4);
        if(ar==tempar3) t3++;
        ll tempar4=area(x4,y4,a1,b1,a2,b2)+area(x4,y4,a3,b3,a2,b2)+area(x4,y4,a4,b4,a3,b3)+area(x4,y4,a1,b1,a4,b4);
        if(ar==tempar4) t4++;
    }
    if(t1>=n-1){
        cout<<x1<<" "<<y1;
        return 0;
    }
    if(t2>=n-1){
        cout<<x2<<" "<<y2;
        return 0;
    }
    if(t3>=n-1){
        cout<<x3<<" "<<y3;
        return 0;
    }
    if(t4>=n-1){
        cout<<x4<<" "<<y4;
        return 0;
    }
    in=temp[1].S;
    x1=arr[in][0],y1=arr[in][3];
    x2=arr[in][0],y2=arr[in][1];
    x3=arr[in][2],y3=arr[in][1];
    x4=arr[in][2],y4=arr[in][3];
    t1=0,t2=0,t3=0,t4=0;;
    rep(i,n){
        ll a1=arr[i][0],b1=arr[i][3];
        ll a2=arr[i][0],b2=arr[i][1];
        ll a3=arr[i][2],b3=arr[i][1];
        ll a4=arr[i][2],b4=arr[i][3];
        ll ar=abs((arr[i][3]-arr[i][1]))*abs((arr[i][2]-arr[i][0]));
        ll tempar1=area(x1,y1,a1,b1,a2,b2)+area(x1,y1,a3,b3,a2,b2)+area(x1,y1,a4,b4,a3,b3)+area(x1,y1,a1,b1,a4,b4);
        if(ar==tempar1) t1++;
        ll tempar2=area(x2,y2,a1,b1,a2,b2)+area(x2,y2,a3,b3,a2,b2)+area(x2,y2,a4,b4,a3,b3)+area(x2,y2,a1,b1,a4,b4);
        if(ar==tempar2) t2++;
        ll tempar3=area(x3,y3,a1,b1,a2,b2)+area(x3,y3,a3,b3,a2,b2)+area(x3,y3,a4,b4,a3,b3)+area(x3,y3,a1,b1,a4,b4);
        if(ar==tempar3) t3++;
        ll tempar4=area(x4,y4,a1,b1,a2,b2)+area(x4,y4,a3,b3,a2,b2)+area(x4,y4,a4,b4,a3,b3)+area(x4,y4,a1,b1,a4,b4);
        if(ar==tempar4) t4++;
    }
    if(t1>=n-1){
        cout<<x1<<" "<<y1;
        return 0;
    }
    if(t2>=n-1){
        cout<<x2<<" "<<y2;
        return 0;
    }
    if(t3>=n-1){
        cout<<x3<<" "<<y3;
        return 0;
    }
    if(t4>=n-1){
        cout<<x4<<" "<<y4;
        return 0;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<double,double> pdd;
#define F first
#define S second
#define rep(i,n) for(ll i = 0, _n = (n); i < _n; i++)
#define rep1(i,a,b) for(ll i = a, _b = (b); i <= _b; i++)
#define rep2(i,b,a) for(ll i = b, _a = (a); i >= _a; i--)
#define mem(a,val) memset(a, (val), sizeof a)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define ub upper_bound
#define lb lower_bound
#define cout(d) cout << fixed << setprecision(d)
#define INF 5000000
#define MOD  1000000007
int modpow(int x,int n){
    if(!n) return 1%MOD;
    int u=modpow(x,n/2);
    u=(u*u)%MOD;
    if(n%2) u=(u*x)%MOD;
    return u;
}
int inv(int x) {return modpow(x,MOD-2);}
void seive(ll n){
    bool prim[n+1];
    mem(prim,true);
    for(ll i=2;i*i<=n;i++){
        if(prim[i]){
            for(ll j=i*2;j<=n;j+=i) {prim[j]=false;}
        }
    }
    //rep1(i,2,n) if(prim[i]) cout<<i<<" ";
}
double area(ll x0,ll y0,ll x1,ll y1,ll x2,ll y2){
    return double(abs(x0 * (y1 - y2) + x1 * (y2 - y0) + x2 * (y0 - y1)) )/ 2;
}

int main(){
    ll n;
    cin>>n;
    ll arr[n][4];
    multiset<ll> xl,xr,yl,yr;
    rep(i,n) {
        rep(j,4) {
            cin>>arr[i][j];
            }
        xl.insert(arr[i][0]);xr.insert(arr[i][2]);
        yl.insert(arr[i][1]);yr.insert(arr[i][3]);
    }
    rep(i,n){
        xl.erase(xl.find(arr[i][0]));xr.erase(xr.find(arr[i][2]));
        yl.erase(yl.find(arr[i][1]));yr.erase(yr.find(arr[i][3]));
        if(*xl.rbegin()<= *xr.begin() && *yl.rbegin() <= *yr.begin()){
            cout<< *xr.begin()<<" "<< *yr.begin();
            return 0;
        }
        xl.insert(arr[i][0]);xr.insert(arr[i][2]);
        yl.insert(arr[i][1]);yr.insert(arr[i][3]);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<double,double> pdd;
#define F first
#define S second
#define rep(i,n) for(ll i = 0, _n = (n); i < _n; i++)
#define rep1(i,a,b) for(ll i = a, _b = (b); i <= _b; i++)
#define rep2(i,b,a) for(ll i = b, _a = (a); i >= _a; i--)
#define mem(a,val) memset(a, (val), sizeof a)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define ub upper_bound
#define lb lower_bound
#define cout(d) cout << fixed << setprecision(d)
#define INF 5000000
#define MOD  1000000007
int modpow(int x,int n){
    if(!n) return 1%MOD;
    int u=modpow(x,n/2);
    u=(u*u)%MOD;
    if(n%2) u=(u*x)%MOD;
    return u;
}
int inv(int x) {return modpow(x,MOD-2);}
void seive(ll n){
    bool prim[n+1];
    mem(prim,true);
    for(ll i=2;i*i<=n;i++){
        if(prim[i]){
            for(ll j=i*2;j<=n;j+=i) {prim[j]=false;}
        }
    }
    //rep1(i,2,n) if(prim[i]) cout<<i<<" ";
}
double area(ll x0,ll y0,ll x1,ll y1,ll x2,ll y2){
    return double(abs(x0 * (y1 - y2) + x1 * (y2 - y0) + x2 * (y0 - y1)) )/ 2;
}

int main(){
    ll n;
    cin>>n;
    ll arr[n][4];
    rep(i,n) cin>>arr[i][0]>>arr[i][1]>>arr[i][2]>>arr[i][3];
    vector<pll> temp;
    rep(i,n){
        temp.pb(mp(((arr[i][3]-arr[i][1])*(arr[i][2]-arr[i][0])),i));
    }
    sort(all(temp));
    ll in=temp[0].S;
    ll x1=arr[in][0],y1=arr[in][3];
    ll x2=arr[in][0],y2=arr[in][1];
    ll x3=arr[in][2],y3=arr[in][1];
    ll x4=arr[in][2],y4=arr[in][3];
    ll t1=0,t2=0,t3=0,t4=0;;
    rep(i,n){
        ll a1=arr[i][0],b1=arr[i][3];
        ll a2=arr[i][0],b2=arr[i][1];
        ll a3=arr[i][2],b3=arr[i][1];
        ll a4=arr[i][2],b4=arr[i][3];
        ll ar=(arr[i][3]-arr[i][1])*(arr[i][2]-arr[i][0]);
        ll tempar1=area(x1,y1,a1,b1,a2,b2)+area(x1,y1,a3,b3,a2,b2)+area(x1,y1,a4,b4,a3,b3)+area(x1,y1,a1,b1,a4,b4);
        if(ar==tempar1) t1++;
        ll tempar2=area(x2,y2,a1,b1,a2,b2)+area(x2,y2,a3,b3,a2,b2)+area(x2,y2,a4,b4,a3,b3)+area(x2,y2,a1,b1,a4,b4);
        if(ar==tempar2) t2++;
        ll tempar3=area(x3,y3,a1,b1,a2,b2)+area(x3,y3,a3,b3,a2,b2)+area(x3,y3,a4,b4,a3,b3)+area(x3,y3,a1,b1,a4,b4);
        if(ar==tempar3) t3++;
        ll tempar4=area(x4,y4,a1,b1,a2,b2)+area(x4,y4,a3,b3,a2,b2)+area(x4,y4,a4,b4,a3,b3)+area(x4,y4,a1,b1,a4,b4);
        if(ar==tempar4) t4++;
    }
    if(t1>=n-1){
        cout<<x1<<" "<<y1;
        return 0;
    }
    if(t2>=n-1){
        cout<<x2<<" "<<y2;
        return 0;
    }
    if(t3>=n-1){
        cout<<x3<<" "<<y3;
        return 0;
    }
    if(t4>=n-1){
        cout<<x4<<" "<<y4;
        return 0;
    }
    in=temp[1].S;
    x1=arr[in][0],y1=arr[in][3];
    x2=arr[in][0],y2=arr[in][1];
    x3=arr[in][2],y3=arr[in][1];
    x4=arr[in][2],y4=arr[in][3];
    t1=0,t2=0,t3=0,t4=0;;
    rep(i,n){
        ll a1=arr[i][0],b1=arr[i][3];
        ll a2=arr[i][0],b2=arr[i][1];
        ll a3=arr[i][2],b3=arr[i][1];
        ll a4=arr[i][2],b4=arr[i][3];
        ll ar=(arr[i][3]-arr[i][1])*(arr[i][2]-arr[i][0]);
        ll tempar1=area(x1,y1,a1,b1,a2,b2)+area(x1,y1,a3,b3,a2,b2)+area(x1,y1,a4,b4,a3,b3)+area(x1,y1,a1,b1,a4,b4);
        if(ar==tempar1) t1++;
        ll tempar2=area(x2,y2,a1,b1,a2,b2)+area(x2,y2,a3,b3,a2,b2)+area(x2,y2,a4,b4,a3,b3)+area(x2,y2,a1,b1,a4,b4);
        if(ar==tempar2) t2++;
        ll tempar3=area(x3,y3,a1,b1,a2,b2)+area(x3,y3,a3,b3,a2,b2)+area(x3,y3,a4,b4,a3,b3)+area(x3,y3,a1,b1,a4,b4);
        if(ar==tempar3) t3++;
        ll tempar4=area(x4,y4,a1,b1,a2,b2)+area(x4,y4,a3,b3,a2,b2)+area(x4,y4,a4,b4,a3,b3)+area(x4,y4,a1,b1,a4,b4);
        if(ar==tempar4) t4++;
    }
    if(t1>=n-1){
        cout<<x1<<" "<<y1;
        return 0;
    }
    if(t2>=n-1){
        cout<<x2<<" "<<y2;
        return 0;
    }
    if(t3>=n-1){
        cout<<x3<<" "<<y3;
        return 0;
    }
    if(t4>=n-1){
        cout<<x4<<" "<<y4;
        return 0;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<double,double> pdd;
#define F first
#define S second
#define rep(i,n) for(ll i = 0, _n = (n); i < _n; i++)
#define rep1(i,a,b) for(ll i = a, _b = (b); i <= _b; i++)
#define rep2(i,b,a) for(ll i = b, _a = (a); i >= _a; i--)
#define mem(a,val) memset(a, (val), sizeof a)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define ub upper_bound
#define lb lower_bound
#define cout(d) cout << fixed << setprecision(d)
#define INF 5000000
#define MOD  1000000007
int modpow(int x,int n){
    if(!n) return 1%MOD;
    int u=modpow(x,n/2);
    u=(u*u)%MOD;
    if(n%2) u=(u*x)%MOD;
    return u;
}
int inv(int x) {return modpow(x,MOD-2);}
void seive(ll n){
    bool prim[n+1];
    mem(prim,true);
    for(ll i=2;i*i<=n;i++){
        if(prim[i]){
            for(ll j=i*2;j<=n;j+=i) {prim[j]=false;}
        }
    }
    //rep1(i,2,n) if(prim[i]) cout<<i<<" ";
}
double area(ll x0,ll y0,ll x1,ll y1,ll x2,ll y2){
    return double(abs(x0 * (y1 - y2) + x1 * (y2 - y0) + x2 * (y0 - y1)) )/ 2;
}

int main(){
    ll n;
    cin>>n;
    ll arr[n][4];
    multiset<ll> xl,xr,yl,yr;
    rep(i,n) {
        rep(j,4) {
            cin>>arr[i][j];
            }
        xl.insert(arr[i][0]);xr.insert(arr[i][2]);
        yl.insert(arr[i][1]);yr.insert(arr[i][3]);
    }
    rep(i,n){
        xl.erase(arr[i][0]);xr.erase(arr[i][2]);
        yl.erase(arr[i][1]);yr.erase(arr[i][3]);
        if(*xl.rbegin()<= *xr.begin() && *yl.rbegin() <= *yr.begin()){
            cout<< *xl.rbegin()<<" "<< *yl.rbegin();
            return 0;
        }
        xl.insert(arr[i][0]);xr.insert(arr[i][2]);
        yl.insert(arr[i][1]);yr.insert(arr[i][3]);
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<cstring>
#include<map>
#include<queue>
#include<unordered_set>
#include<cmath>
using namespace std;
struct node {
	long long x1, y1, x2, y2;
};
node ans, abnormal;
vector<node> a;
node fuck;
bool cmp(node& a, node& b)
{
	if (a.x1 == b.x1)
		return a.y1 < b.y1;
	return a.x1 < b.x1;
}
int main()
{
	long long i, j, k, n, m, cnt, abj;
	bool flag;
	while (scanf("%lld", &n) != EOF)
	{
		a.clear();
		for (i = 0; i < n; i++)
		{
			scanf("%lld%lld%lld%lld", &fuck.x1, &fuck.y1, &fuck.x2, &fuck.y2);
			a.push_back(fuck);
		}
		sort(a.begin(), a.end(), cmp);
		ans = a[0];
		cnt = 1;
		abj = 0;
		for (i = 1; i < n; i++)
		{
			if (ans.y2 < a[i].y1 || ans.x2 < a[i].x1||ans.x1>a[i].x2||ans.y1>a[i].y2)
			{
				if (abj != 0) {
					abnormal = a[i];
					abj = i;
				}
			}
			else
			{
				cnt++;
				ans.x1 = max(ans.x1, a[i].x1);
				ans.y1 = max(ans.y1, a[i].y1);
				ans.x2 = min(ans.x2, a[i].x2);
				ans.y2 = min(ans.y2, a[i].y2);
			}
			//cout << ans.x1<<" "<<ans.y1<<" "<< ans.x2 << " " << ans.y2 << endl;
		}
		if (cnt >= n - 1)
		{
			printf("%lld %lld\n", ans.x1, ans.y1);
		}
		else
		{
			ans = a[abj];
			cnt = 1;
			for (i = 1; i < n; i++)
			{
				if (ans.y2 < a[i].y1 || ans.x2 < a[i].x1||ans.x1>a[i].x2 || ans.y1>a[i].y2)
				{
					abnormal = a[i];
					abj = i;
				}
				else
				{
					cnt++;
					ans.x1 = max(ans.x1, a[i].x1);
					ans.y1 = max(ans.y1, a[i].y1);
					ans.x2 = min(ans.x2, a[i].x2);
					ans.y2 = min(ans.y2, a[i].y2);
				}
			}
			if (cnt >= n - 1)
				printf("%lld %lld\n", ans.x1, ans.y1);
			else
				printf("-1 -1\n");
		}
	}

}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<cstring>
#include<map>
#include<queue>
#include<unordered_set>
#include<cmath>
using namespace std;
struct node {
	long long x1, y1, x2, y2;
};
node ans, abnormal;
vector<node> a;
node fuck;
bool cmp(node& a, node& b)
{
	if (a.x1 == b.x1)
		return a.y1 < b.y1;
	return a.x1 < b.x1;
}
int main()
{
	long long i, j, k, n, m, cnt;
	bool flag;
	while (scanf("%lld", &n) != EOF)
	{
		a.clear();
		for (i = 0; i < n; i++)
		{
			scanf("%lld%lld%lld%lld", &fuck.x1, &fuck.y1, &fuck.x2, &fuck.y2);
			a.push_back(fuck);
		}
		sort(a.begin(), a.end(), cmp);
		ans = a[0];
		cnt = 1;
		for (i = 1; i < n; i++)
		{
			if (ans.y2 < a[i].y1 || ans.x2 < a[i].x1||ans.x1>a[i].x2||ans.y1>a[i].y2)
			{
				abnormal = a[i];
			}
			else
			{
				cnt++;
				ans.x1 = max(ans.x1, a[i].x1);
				ans.y1 = max(ans.y1, a[i].y1);
				ans.x2 = min(ans.x2, a[i].x2);
				ans.y2 = min(ans.y2, a[i].y2);
			}
			//cout << ans.x1<<" "<<ans.y1<<" "<< ans.x2 << " " << ans.y2 << endl;
		}
		if (cnt >= n - 1)
		{
			printf("%lld %lld\n", ans.x1, ans.y1);
		}
		else
		{
			ans = abnormal;
			cnt = 1;
			for (i = 1; i < n; i++)
			{
				if (ans.y2 < a[i].y1 || ans.x2 < a[i].x1||ans.x1>a[i].x2 || ans.y1>a[i].y2)
				{
					abnormal = a[i];
				}
				else
				{
					cnt++;
					ans.x1 = max(ans.x1, a[i].x1);
					ans.y1 = max(ans.y1, a[i].y1);
					ans.x2 = min(ans.x2, a[i].x2);
					ans.y2 = min(ans.y2, a[i].y2);
				}
			}
			if (cnt >= n - 1)
				printf("%lld %lld\n", ans.x1, ans.y1);
			else
				printf("-1 -1\n");
		}
	}

}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<cstring>
#include<map>
#include<queue>
#include<unordered_set>
#include<cmath>
using namespace std;
struct node {
	long long x1, y1, x2, y2;
};
node ans, abnormal;
vector<node> a;
node fuck;
bool cmp(node& a, node& b)
{
	if (a.x1 == b.x1)
		return a.y1 < b.y1;
	return a.x1 < b.x1;
}
int main()
{
	long long i, j, k, n, m, cnt, abj;
	bool flag;
	while (scanf("%lld", &n) != EOF)
	{
		a.clear();
		for (i = 0; i < n; i++)
		{
			scanf("%lld%lld%lld%lld", &fuck.x1, &fuck.y1, &fuck.x2, &fuck.y2);
			a.push_back(fuck);
		}
		sort(a.begin(), a.end(), cmp);
		ans = a[0];
		cnt = 1;
		for (i = 1; i < n; i++)
		{
			if (ans.y2 < a[i].y1 || ans.x2 < a[i].x1)
			{
				abnormal = a[i];
				abj = i;
			}
			else
			{
				cnt++;
				ans.x1 = max(ans.x1, a[i].x1);
				ans.y1 = max(ans.y1, a[i].y1);
				ans.x2 = min(ans.x2, a[i].x2);
				ans.y2 = min(ans.y2, a[i].y2);
			}
			//cout << ans.x1<<" "<<ans.y1<<" "<< ans.x2 << " " << ans.y2 << endl;
		}
		if (cnt >= n - 1)
		{
			printf("%lld %lld\n", ans.x1, ans.y1);
		}
		else
		{
			ans = a[j];
			cnt = 0;
			for (i = 1; i < n; i++)
			{
				if (ans.y2 < a[i].y1 || ans.x2 < a[i].x1)
				{
					abnormal = a[i];
					abj = i;
				}
				else
				{
					cnt++;
					ans.x1 = max(ans.x1, a[i].x1);
					ans.y1 = max(ans.y1, a[i].y1);
					ans.x2 = min(ans.x2, a[i].x2);
					ans.y2 = min(ans.y2, a[i].y2);
				}
			}
			if (cnt >= n - 1)
				printf("%lld %lld\n", ans.x1, ans.y1);
			else
				printf("-1 -1\n");
		}
	}

}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<cstring>
#include<map>
#include<queue>
#include<unordered_set>
#include<cmath>
using namespace std;
struct node {
	long long x1, y1, x2, y2;
};
node ans, abnormal;
vector<node> a;
node fuck;
bool cmp(node& a, node& b)
{
	if (a.x1 == b.x1)
		return a.y1 < b.y1;
	return a.x1 < b.x1;
}
int main()
{
	long long i, j, k, n, m, cnt, abj;
	bool flag;
	while (scanf("%lld", &n) != EOF)
	{
		a.clear();
		for (i = 0; i < n; i++)
		{
			scanf("%lld%lld%lld%lld", &fuck.x1, &fuck.y1, &fuck.x2, &fuck.y2);
			a.push_back(fuck);
		}
		sort(a.begin(), a.end(), cmp);
		ans = a[0];
		cnt = 1;
		abj = 0;
		for (i = 1; i < n; i++)
		{
			if (ans.y2 < a[i].y1 || ans.x2 < a[i].x1||ans.x1>a[i].x2||ans.y1>a[i].y2)
			{
				if (abj != 0) {
					abnormal = a[i];
					abj = i;
				}
			}
			else
			{
				cnt++;
				ans.x1 = max(ans.x1, a[i].x1);
				ans.y1 = max(ans.y1, a[i].y1);
				ans.x2 = min(ans.x2, a[i].x2);
				ans.y2 = min(ans.y2, a[i].y2);
			}
			//cout << ans.x1<<" "<<ans.y1<<" "<< ans.x2 << " " << ans.y2 << endl;
		}
		if (cnt >= n - 1)
		{
			printf("%lld %lld\n", ans.x1, ans.y1);
		}
		else
		{
			ans = a[abj];
			cnt = 0;
			for (i = 1; i < n; i++)
			{
				if (ans.y2 < a[i].y1 || ans.x2 < a[i].x1||ans.x1>a[i].x2 || ans.y1>a[i].y2)
				{
					abnormal = a[i];
					abj = i;
				}
				else
				{
					cnt++;
					ans.x1 = max(ans.x1, a[i].x1);
					ans.y1 = max(ans.y1, a[i].y1);
					ans.x2 = min(ans.x2, a[i].x2);
					ans.y2 = min(ans.y2, a[i].y2);
				}
			}
			if (cnt >= n - 1)
				printf("%lld %lld\n", ans.x1, ans.y1);
			else
				printf("-1 -1\n");
		}
	}

}


#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<map>
#include<queue>
#include<unordered_set>
#include<cmath>
using namespace std;
struct node {
	long long x1, y1, x2, y2;
};
node ans,abnormal;
vector<node> a;
node fuck;
bool cmp(node& a, node& b)
{
	if (a.x1 == b.x1)
		return a.y1 < b.y1;
	return a.x1 < b.x1;
}
int main()
{
	long long i, j, k, n, m,cnt,abj;
	bool flag;
	while (scanf("%lld", &n) != EOF)
	{
		a.clear();
		for (i = 0; i < n; i++)
		{
			scanf("%lld%lld%lld%lld", &fuck.x1, &fuck.y1, &fuck.x2, &fuck.y2);
			a.push_back(fuck);
		}
		sort(a.begin(), a.end(),cmp);
		ans = a[0];
		cnt = 1;
		for (i = 1; i < n; i++)
		{
			if (ans.y2 < a[i].y1 || ans.x2 < a[i].x1)
			{
				abnormal = a[i];
				abj = i;
			}
			else
			{
				cnt++;
				if (ans.x1 <= a[i].x1&&ans.y1 <= a[i].y1)
				{
					ans.x1 = a[i].x1;
					ans.y1 = a[i].y1;
				}
				if (ans.x2 >= a[i].x2&&ans.y2 >= a[i].y2)
				{
					ans.x2 = a[i].x2;
					ans.y2 = a[i].y2;
				}
			}
		}
		if (cnt>=n - 1)
		{
			printf("%lld %lld\n", ans.x1, ans.y1);
		}
		else
		{
			ans = a[j];
			cnt = 0;
			for (i = 1; i < n; i++)
			{
				if (ans.y2 < a[i].y1 || ans.x2 < a[i].x1)
				{
					abnormal = a[i];
					abj = i;
				}
				else
				{
					cnt++;
					if (ans.x1 <= a[i].x1&&ans.y1 <= a[i].y1)
					{
						ans.x1 = a[i].x1;
						ans.y1 = a[i].y1;
					}
					if (ans.x2 >= a[i].x2&&ans.y2 >= a[i].y2)
					{
						ans.x2 = a[i].x2;
						ans.y2 = a[i].y2;
					}
				}
			}
			if (cnt >= n - 1)
				printf("%lld %lld\n", ans.x1, ans.y1);
			else
				printf("-1 -1\n");
		}
	}

}


#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<map>
#include<queue>
#include<unordered_set>
#include<cmath>
using namespace std;
struct node {
	long long x1, y1, x2, y2;
};
node ans,abnormal;
vector<node> a;
node fuck;
bool cmp(node& a, node& b)
{
	if (a.x1 == b.x1)
		return a.y1 < b.y1;
	return a.x1 < b.x1;
}
int main()
{
	long long i, j, k, n, m,cnt,abj;
	bool flag;
	while (scanf("%lld", &n) != EOF)
	{
		a.clear();
		for (i = 0; i < n; i++)
		{
			scanf("%lld%lld%lld%lld", &fuck.x1, &fuck.y1, &fuck.x2, &fuck.y2);
			a.push_back(fuck);
		}
		sort(a.begin(), a.end(),cmp);
		ans = a[0];
		cnt = 1;
		for (i = 1; i < n; i++)
		{
			if (ans.y2 < a[i].y1 || ans.x2 < a[i].x1)
			{
				abnormal = a[i];
				abj = i;
			}
			else
			{
				cnt++;
				ans.x1 = max(ans.x1, a[i].x1);
				ans.y1 = max(ans.y1, a[i].y1);
				ans.x2 = max(ans.x2, a[i].x2);
				ans.y2 = max(ans.y2, a[i].y2);
			}
		}
		if (cnt>=n - 1)
		{
			printf("%lld %lld\n", ans.x1, ans.y1);
		}
		else
		{
			ans = a[j];
			cnt = 0;
			for (i = 1; i < n; i++)
			{
				if (ans.y2 < a[i].y1 || ans.x2 < a[i].x1)
				{
					abnormal = a[i];
					abj = i;
				}
				else
				{
					cnt++;
					ans.x1 = max(ans.x1, a[i].x1);
					ans.y1 = max(ans.y1, a[i].y1);
					ans.x2 = max(ans.x2, a[i].x2);
					ans.y2 = max(ans.y2, a[i].y2);
				}
			}
			if (cnt >= n - 1)
				printf("%lld %lld\n", ans.x1, ans.y1);
			else
				printf("-1 -1\n");
		}
	}

}


#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<map>
#include<queue>
#include<unordered_set>
#include<cmath>
using namespace std;
struct node {
	long long x1, y1, x2, y2;
};
node ans,abnormal;
vector<node> a;
node fuck;
bool cmp(node& a, node& b)
{
	if (a.x1 == b.x1)
		return a.y1 < b.y1;
	return a.x1 < b.x1;
}
int main()
{
	long long i, j, k, n, m,cnt,abj;
	bool flag;
	while (scanf("%lld", &n) != EOF)
	{
		a.clear();
		for (i = 0; i < n; i++)
		{
			scanf("%lld%lld%lld%lld", &fuck.x1, &fuck.y1, &fuck.x2, &fuck.y2);
			a.push_back(fuck);
		}
		sort(a.begin(), a.end(),cmp);
		ans = a[0];
		cnt = 1;
		for (i = 1; i < n; i++)
		{
			if (ans.y2 < a[i].y1 || ans.x2 < a[i].x1)
			{
				abnormal = a[i];
				abj = i;
			}
			else
			{
				cnt++;
				ans.x2 = min(ans.x2, a[i].x2);
				ans.y2 = min(ans.y2, a[i].y2);
				if(a[i].x1<=ans.x2)
					ans.x1 = max(ans.x1, a[i].x1);
				if(a[i].y1<=ans.y2)
				ans.y1 = max(ans.y1, a[i].y1);
			}
		}
		if (cnt>=n - 1)
		{
			printf("%lld %lld\n", ans.x1, ans.y1);
		}
		else
		{
			ans = a[j];
			cnt = 0;
			for (i = 1; i < n; i++)
			{
				if (ans.y2 < a[i].y1 || ans.x2 < a[i].x1)
				{
					abnormal = a[i];
					abj = i;
				}
				else
				{
					cnt++;
					ans.x2 = min(ans.x2, a[i].x2);
					ans.y2 = min(ans.y2, a[i].y2);
					if (a[i].x1 <= ans.x2)
						ans.x1 = max(ans.x1, a[i].x1);
					if (a[i].y1 <= ans.y2)
						ans.y1 = max(ans.y1, a[i].y1);
				}
			}
			if (cnt >= n - 1)
				printf("%lld %lld\n", ans.x1, ans.y1);
			else
				printf("-1 -1\n");
		}
	}

}


#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
#define inf 1000000007
typedef struct h {
    int x1,y1,x2,y2;
    bool operator==(struct h rhs) {
        return (x1 == rhs.x1) && (x2 == rhs.x2) && (y1 == rhs.y1) && (y2 == rhs.y2);
    }
} rect;

rect nu  = {inf,inf,inf,inf};
rect intersect(rect a, rect b) {
    if(b.x1 < a.x1) swap(a,b);
    if(b.x1 > a.x2) return nu;
    if(b.y2 >= a.y2) {
        if(b.y1 > a.y2) return nu;
        else {
            return {max(b.x1,a.x1),max(b.y1,a.y1),min(a.x2,b.x2),min(b.y2,a.y2)};
        }
    }
    else {
        if(b.y2 < a.y1) return nu;
        else {
            return {max(b.x1,a.x1),max(b.y1,a.y1),min(a.x2,b.x2),min(b.y2,a.y2)};
        }
    }
}
int main() {
   int n;
   cin >> n;
   rect R[n];
   for(int i = 0; i < n; i++) {
    cin >> R[i].x1 >> R[i].y1 >> R[i].x2 >> R[i].y2;
   }

   if(n == 2) {
        rect p = intersect(R[0], R[1]);
        cout << R[0].x1 << " " << R[0].y1 << "\n";
   }
   else if(n == 3) {
        rect p1 = intersect(R[0], R[1]), p2 = intersect(R[1], R[2]);
        // cout << p1.x1 << " " << p1.y1 << " " << p1.x2 << " " << p1.y2 << "\n";
        if(p1 == nu) {
            cout << p2.x1 << " " << p2.y1 << "\n";
        }
        else {
            cout << p1.x1 << " " << p1.y1 << "\n";
        }
   }
   else {
        rect pref[n], suff[n];
        pref[0] = R[0];
        suff[n-1] = R[n-1];
        for(int i = 1; i < n; i++) {
            pref[i] = intersect(R[i], pref[i-1]);
            suff[n-i-1] = intersect(R[n-1-i], suff[n-i]);
        }
        rect p;
        if(!(suff[1] == nu)) p = suff[0];
        else if(!(pref[n-2] == nu)) p = pref[n-2];
        for(int i = 1; i < n-1; i++) {
            rect r = intersect(pref[i-1],suff[i+1]);
            if(!(r==nu)) p = r;
        }
        cout << p.x1 << " " << p.y1 << "\n";
   }

}


#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
#define inf 1000000007
typedef struct h {
    int x1,y1,x2,y2;
    bool operator==(struct h rhs) {
        return (x1 == rhs.x1) && (x2 == rhs.x2) && (y1 == rhs.y1) && (y2 == rhs.y2);
    }
} rect;

rect nu  = {inf,inf,inf,inf};
rect intersect(rect a, rect b) {
    if(b.x1 < a.x1) swap(a,b);
    if(b.x1 > a.x2) return nu;
    if(b.y2 >= a.y2) {
        if(b.y1 > a.y2) return nu;
        else {
            return {max(b.x1,a.x1),max(b.y1,a.y1),min(a.x2,b.x2),min(b.y2,a.y2)};
        }
    }
    else {
        if(b.y2 < a.y1) return nu;
        else {
            return {max(b.x1,a.x1),max(b.y1,a.y1),min(a.x2,b.x2),min(b.y2,a.y2)};
        }
    }
}
int main() {
   int n;
   cin >> n;
   rect R[n];
   for(int i = 0; i < n; i++) {
    cin >> R[i].x1 >> R[i].y1 >> R[i].x2 >> R[i].y2;
   }

   if(n == 2) {
        rect p = intersect(R[0], R[1]);
        cout << p.x1 << " " << p.y1 << "\n";
   }
   else if(n == 3) {
        rect p1 = intersect(R[0], R[1]), p2 = intersect(R[1], R[2]);
        cout << p1.x1 << " " << p1.y1 << " " << p1.x2 << " " << p1.y2 << "\n";
        if(p1 == nu) {
            cout << p2.x1 << " " << p2.y1 << "\n";
        }
        else {
            cout << p1.x1 << " " << p1.y1 << "\n";
        }
   }
   else {
        rect p1 = intersect(R[0],R[1]), p2 = intersect(R[2], R[3]);
        int sum1 = 0, sum2 = 0;
        for(int i = 0; i < n; i++) {
            rect t1 = intersect(p1,R[i]);
            rect t2 = intersect(p2, R[i]);
            if(!(t1 == nu)) sum1++;
            if(!(t2 == nu)) sum2++;
        }
        if(sum2 >= n-1) {
            cout << p2.x1 << " " << p2.y1 << "\n";
        }
        else {
            cout << p1.x1 << " " << p1.y1 << "\n";
        }
   }

}


#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
#define inf 1000000007
typedef struct h {
    int x1,y1,x2,y2;
    bool operator==(struct h rhs) {
        return (x1 == rhs.x1) && (x2 == rhs.x2) && (y1 == rhs.y1) && (y2 == rhs.y2);
    }
} rect;

rect nu  = {inf,inf,inf,inf};
rect intersect(rect a, rect b) {
    if(b.x1 < a.x1) swap(a,b);
    if(b.x1 > a.x2) return nu;
    if(b.y2 >= a.y2) {
        if(b.y1 > a.y2) return nu;
        else {
            return {max(b.x1,a.x1),max(b.y1,a.y1),min(a.x2,b.x2),min(b.y2,a.y2)};
        }
    }
    else {
        if(b.y2 < a.y1) return nu;
        else {
            return {max(b.x1,a.x1),max(b.y1,a.y1),min(a.x2,b.x2),min(b.y2,a.y2)};
        }
    }
}
int main() {
   int n;
   cin >> n;
   rect R[n];
   for(int i = 0; i < n; i++) {
    cin >> R[i].x1 >> R[i].y1 >> R[i].x2 >> R[i].y2;
   }

   if(n == 2) {
        rect p = intersect(R[0], R[1]);
        cout << R[0].x1 << " " << R[0].y1 << "\n";
   }
   else {
        rect pref[n], suff[n];
        pref[0] = R[0];
        suff[n-1] = R[n-1];
        for(int i = 1; i < n; i++) {
            pref[i] = intersect(R[i], pref[i-1]);
            suff[n-i-1] = intersect(R[n-1-i], suff[n-i]);
        }
        rect p;
        if(!(suff[1] == nu)) p = suff[1];
        else if(!(pref[n-2] == nu)) p = pref[n-2];
        for(int i = 1; i < n-1; i++) {
            rect r = intersect(pref[i-1],suff[i+1]);
            if(!(r==nu)) p = r;
        }
        cout << p.x1 << " " << p.y1 << "\n";
   }

}


#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
#define inf 1000000007
typedef struct h {
    int x1,y1,x2,y2;
    bool operator==(struct h rhs) {
        return (x1 == rhs.x1) && (x2 == rhs.x2) && (y1 == rhs.y1) && (y2 == rhs.y2);
    }
} rect;

rect nu  = {inf,inf,inf,inf};
rect intersect(rect a, rect b) {
    if(b.x1 < a.x1) swap(a,b);
    if(b.x1 > a.x2) return nu;
    if(b.y2 >= a.y2) {
        if(b.y1 > a.y2) return nu;
        else {
            return {max(b.x1,a.x1),max(b.y1,a.y1),min(a.x2,b.x2),min(b.y2,a.y2)};
        }
    }
    else {
        if(b.y2 < a.y1) return nu;
        else {
            return {max(b.x1,a.x1),max(b.y1,a.y1),min(a.x2,b.x2),min(b.y2,a.y2)};
        }
    }
}
int main() {
   int n;
   cin >> n;
   rect R[n];
   for(int i = 0; i < n; i++) {
    cin >> R[i].x1 >> R[i].y1 >> R[i].x2 >> R[i].y2;
   }

   if(n == 2) {
        rect p = intersect(R[0], R[1]);
        cout << R[0].x1 << " " << R[0].y1 << "\n";
   }
   else if(n == 3) {
        rect p1 = intersect(R[0], R[1]), p2 = intersect(R[1], R[2]);
        // cout << p1.x1 << " " << p1.y1 << " " << p1.x2 << " " << p1.y2 << "\n";
        if(p1 == nu) {
            cout << p2.x1 << " " << p2.y1 << "\n";
        }
        else {
            cout << p1.x1 << " " << p1.y1 << "\n";
        }
   }
   else {
        rect p1 = intersect(R[0],R[1]), p2 = intersect(R[2], R[3]);
        int sum1 = 0, sum2 = 0;
        for(int i = 0; i < n; i++) {
            rect t1 = intersect(p1,R[i]);
            rect t2 = intersect(p2, R[i]);
            if(!(t1 == nu)) sum1++;
            if(!(t2 == nu)) sum2++;
        }
        if(sum2 >= n-1) {
            for(int i = 0; i < n; i++) {
                rect t = intersect(p2,R[i]);
                if(!(t == nu)) p2 = t;
            }
            cout << p2.x1 << " " << p2.y1 << "\n";
        }
        else {
             for(int i = 0; i < n; i++) {
                rect t = intersect(p1,R[i]);
                if(!(t == nu)) p1 = t;
            }
            cout << p1.x1 << " " << p1.y1 << "\n";
        }
   }

}


#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
#define inf 1000000007
typedef struct h {
    int x1,y1,x2,y2;
    bool operator==(struct h rhs) {
        return (x1 == rhs.x1) && (x2 == rhs.x2) && (y1 == rhs.y1) && (y2 == rhs.y2);
    }
} rect;

rect nu  = {inf,inf,inf,inf};
rect intersect(rect a, rect b) {
    if(b.x1 < a.x1) swap(a,b);
    if(b.x1 > a.x2) return nu;
    if(b.y2 >= a.y2) {
        if(b.y1 > a.y2) return nu;
        else {
            return {max(b.x1,a.x1),max(b.y1,a.y1),min(a.x2,b.x2),min(b.y2,a.y2)};
        }
    }
    else {
        if(b.y2 < a.y1) return nu;
        else {
            return {max(b.x1,a.x1),max(b.y1,a.y1),min(a.x2,b.x2),min(b.y2,a.y2)};
        }
    }
}
int main() {
   int n;
   cin >> n;
   rect R[n];
   for(int i = 0; i < n; i++) {
    cin >> R[i].x1 >> R[i].y1 >> R[i].x2 >> R[i].y2;
   }

   if(n == 2) {
        rect p = intersect(R[0], R[1]);
        cout << p.x1 << " " << p.y1 << "\n";
   }
   else if(n == 3) {
        rect p1 = intersect(R[0], R[1]), p2 = intersect(R[1], R[2]);
        // cout << p1.x1 << " " << p1.y1 << " " << p1.x2 << " " << p1.y2 << "\n";
        if(p1 == nu) {
            cout << p2.x1 << " " << p2.y1 << "\n";
        }
        else {
            cout << p1.x1 << " " << p1.y1 << "\n";
        }
   }
   else {
        rect p1 = intersect(R[0],R[1]), p2 = intersect(R[2], R[3]);
        int sum1 = 0, sum2 = 0;
        for(int i = 0; i < n; i++) {
            rect t1 = intersect(p1,R[i]);
            rect t2 = intersect(p2, R[i]);
            if(!(t1 == nu)) sum1++;
            if(!(t2 == nu)) sum2++;
        }
        if(sum2 >= n-1) {
            cout << p2.x1 << " " << p2.y1 << "\n";
        }
        else {
            cout << p1.x1 << " " << p1.y1 << "\n";
        }
   }

}


#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
#define inf 1000000007
typedef struct h {
    int x1,y1,x2,y2;
    bool operator==(struct h rhs) {
        return (x1 == rhs.x1) && (x2 == rhs.x2) && (y1 == rhs.y1) && (y2 == rhs.y2);
    }
} rect;

rect nu  = {inf,inf,inf,inf};
rect intersect(rect a, rect b) {
    if(b.x1 < a.x1) swap(a,b);
    if(b.x1 > a.x2) return nu;
    if(b.y2 >= a.y2) {
        if(b.y1 > a.y2) return nu;
        else {
            return {max(b.x1,a.x1),max(b.y1,a.y1),min(a.x2,b.x2),min(b.y2,a.y2)};
        }
    }
    else {
        if(b.y2 < a.y1) return nu;
        else {
            return {max(b.x1,a.x1),max(b.y1,a.y1),min(a.x2,b.x2),min(b.y2,a.y2)};
        }
    }
}
int main() {
   int n;
   cin >> n;
   rect R[n];
   for(int i = 0; i < n; i++) {
    cin >> R[i].x1 >> R[i].y1 >> R[i].x2 >> R[i].y2;
   }

   if(n == 2) {
        rect p = intersect(R[0], R[1]);
        cout << p.x1 << " " << p.y1 << "\n";
   }
   else if(n == 3) {
        rect p1 = intersect(R[0], R[1]), p2 = intersect(R[1], R[2]);
        // cout << p1.x1 << " " << p1.y1 << " " << p1.x2 << " " << p1.y2 << "\n";
        if(p1 == nu) {
            cout << p2.x1 << " " << p2.y1 << "\n";
        }
        else {
            cout << p1.x1 << " " << p1.y1 << "\n";
        }
   }
   else {
        rect p1 = intersect(R[0],R[1]), p2 = intersect(R[2], R[3]);
        int sum1 = 0, sum2 = 0;
        for(int i = 0; i < n; i++) {
            rect t1 = intersect(p1,R[i]);
            rect t2 = intersect(p2, R[i]);
            if(!(t1 == nu)) sum1++;
            if(!(t2 == nu)) sum2++;
        }
        if(sum2 >= n-1) {
            for(int i = 0; i < n; i++) {
                rect t = intersect(p2,R[i]);
                if(!(t == nu)) p2 = t;
            }
            cout << p2.x1 << " " << p2.y1 << "\n";
        }
        else {
             for(int i = 0; i < n; i++) {
                rect t = intersect(p1,R[i]);
                if(!(t == nu)) p1 = t;
            }
            cout << p1.x1 << " " << p1.y1 << "\n";
        }
   }

}


#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
#define inf 1000000007
typedef struct h {
    int x1,y1,x2,y2;
    bool operator==(struct h rhs) {
        return (x1 == rhs.x1) && (x2 == rhs.x2) && (y1 == rhs.y1) && (y2 == rhs.y2);
    }
} rect;

rect nu  = {inf,inf,inf,inf};
rect intersect(rect a, rect b) {
    if(b.x1 < a.x1) swap(a,b);
    if(b.x1 > a.x2) return nu;
    if(b.y2 >= a.y2) {
        if(b.y1 > a.y2) return nu;
        else {
            return {max(b.x1,a.x1),max(b.y1,a.y1),min(a.x2,b.x2),min(b.y2,a.y2)};
        }
    }
    else {
        if(b.y2 < a.y1) return nu;
        else {
            return {max(b.x1,a.x1),max(b.y1,a.y1),min(a.x2,b.x2),min(b.y2,a.y2)};
        }
    }
}
int main() {
   int n;
   cin >> n;
   rect R[n];
   for(int i = 0; i < n; i++) {
    cin >> R[i].x1 >> R[i].y1 >> R[i].x2 >> R[i].y2;
   }

   if(n == 2) {
        rect p = intersect(R[0], R[1]);
        cout << R[0].x1 << " " << R[0].y1 << "\n";
   }
   else if(n == 3) {
        rect p1 = intersect(R[0], R[1]), p2 = intersect(R[1], R[2]);
        // cout << p1.x1 << " " << p1.y1 << " " << p1.x2 << " " << p1.y2 << "\n";
        if(p1 == nu) {
            cout << p2.x1 << " " << p2.y1 << "\n";
        }
        else {
            cout << p1.x1 << " " << p1.y1 << "\n";
        }
   }
   else {
        rect pref[n], suff[n];
        pref[0] = R[0];
        suff[n-1] = R[n-1];
        for(int i = 1; i < n; i++) {
            pref[i] = intersect(R[i], pref[i-1]);
            suff[i] = intersect(R[n-1-i], suff[n-i]);
        }
        rect p;
        if(!(suff[1] == nu)) p = suff[0];
        else if(!(pref[n-2] == nu)) p = pref[n-2];
        for(int i = 1; i < n-1; i++) {
            rect r = intersect(pref[i-1],suff[i+1]);
            if(!(r==nu)) p = r;
        }
        cout << p.x1 << " " << p.y1 << "\n";
   }

}


#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
#define inf 1000000007
typedef struct h {
    int x1,y1,x2,y2;
    bool operator==(struct h rhs) {
        return (x1 == rhs.x1) && (x2 == rhs.x2) && (y1 == rhs.y1) && (y2 == rhs.y2);
    }
} rect;

rect nu  = {inf,inf,inf,inf};
rect intersect(rect a, rect b) {
    if(b.x1 < a.x1) swap(a,b);
    if(b.x1 > a.x2) return nu;
    if(b.y2 >= a.y2) {
        if(b.y1 > a.y2) return nu;
        else {
            return {max(b.x1,a.x1),max(b.y1,a.y1),min(a.x2,b.x2),min(b.y2,a.y2)};
        }
    }
    else {
        if(b.y2 < a.y1) return nu;
        else {
            return {max(b.x1,a.x1),max(b.y1,a.y1),min(a.x2,b.x2),min(b.y2,a.y2)};
        }
    }
}
int main() {
   int n;
   cin >> n;
   rect R[n];
   for(int i = 0; i < n; i++) {
    cin >> R[i].x1 >> R[i].y1 >> R[i].x2 >> R[i].y2;
   }

   if(n == 2) {
        rect p = intersect(R[0], R[1]);
        cout << R[0].x1 << " " << R[0].y1 << "\n";
   }
   else if(n == 3) {
        rect p1 = intersect(R[0], R[1]), p2 = intersect(R[1], R[2]);
        // cout << p1.x1 << " " << p1.y1 << " " << p1.x2 << " " << p1.y2 << "\n";
        if(p1 == nu) {
            cout << p2.x1 << " " << p2.y1 << "\n";
        }
        else {
            cout << p1.x1 << " " << p1.y1 << "\n";
        }
   }
   else {
        rect pref[n], suff[n];
        pref[0] = R[0];
        suff[n-1] = R[n-1];
        for(int i = 1; i < n; i++) {
            pref[i] = intersect(R[i], pref[i-1]);
            suff[n-i-1] = intersect(R[n-1-i], suff[n-i]);
        }
        rect p;
        if(!(suff[1] == nu)) p = suff[1];
        else if(!(pref[n-2] == nu)) p = pref[n-2];
        for(int i = 1; i < n-1; i++) {
            rect r = intersect(pref[i-1],suff[i+1]);
            if(!(r==nu)) p = r;
        }
        cout << p.x1 << " " << p.y1 << "\n";
   }

}


#include<bits/stdc++.h>

using namespace std;

int main(){
	int n;
	scanf(" %d",&n);
	pair<int,pair<int,int>> Xs[n],Ys[n];
	for(int i = 0; i < n;++i){
		int x1,y1,x2,y2;
		scanf(" %d %d %d %d",&x1,&y1,&x2,&y2);
		Xs[i] = {x1,{x2,i}};
		Ys[i] = {y1,{y2,i}};
	}
	sort(Xs,Xs+n);
	sort(Ys,Ys+n);
	int del;
	if(Xs[0].second.first < Xs[1].first)
		del = Xs[0].second.second;
	else if(Xs[n-2].second.first < Xs[n-1].first)
		del = Xs[n-1].second.second;
	else if(Ys[0].second.first < Ys[1].first)
		del = Ys[0].second.second;
	else if(Ys[n-2].second.first < Ys[n-1].first)
		del = Ys[n-1].second.second;
	pair<int,int> ansX = {-1000000000,1000000000}, ansY = {-1000000000,1000000000};
	for(int i = 0; i < n;++i){
		if(Xs[i].second.second != del){
			ansX.first = max(ansX.first,Xs[i].first);
			ansX.second = min(ansX.second,Xs[i].second.first);
		}
		if(Ys[i].second.second != del){
			ansY.first = max(ansY.first,Ys[i].first);
			ansY.second = min(ansY.second,Ys[i].second.first);
		}
	}
	printf("%d %d\n",ansX.first,ansY.first);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){
	int n;
	scanf(" %d",&n);
	pair<pair<int,int>,pair<int,int>> rect[n];
	for(int i = 0; i < n;++i){
		int x1,y1,x2,y2;
		scanf(" %d %d %d %d",&x1,&y1,&x2,&y2);
		rect[i] = {{x1,x2},{y1,y2}};
	}
	pair<pair<int,int>,pair<int,int>> pref[n],suf[n];
	pref[0] = {rect[0].first,rect[0].second};
	suf[n-1] = {rect[n-1].first,rect[n-1].second};
	for(int i = 1; i < n;++i){
		pref[i].first = {min(pref[i-1].first.first,rect[i].first.first),max(pref[i-1].first.second,rect[i].first.second)};
		pref[i].second = {min(pref[i-1].second.first,rect[i].second.first),max(pref[i-1].second.second,rect[i].second.second)};
	}
	for(int i = n-2;i > -1;--i){
		suf[i].first = {min(suf[i+1].first.first,rect[i].first.first),max(suf[i+1].first.second,rect[i].first.second)};
		suf[i].second = {min(suf[i+1].second.first,rect[i].second.first),max(suf[i+1].second.second,rect[i].second.second)};
	}
	for(int i = 0; i < n;++i){
		if(i == 0){
			if(suf[i+1].first.first < suf[i+1].first.second && suf[i+1].second.first < suf[i+1].second.second){
				printf("%d %d\n",suf[i+1].first.first,suf[i+1].second.first); return 0;
			}
		}
		else if(i == n){
			printf("%d %d\n",pref[i+1].first.first,pref[i+1].second.first);return 0;
		}
		pair<pair<int,int>, pair<int,int>> check;
		check.first = {min(pref[i-1].first.first,suf[i+1].first.first),max(pref[i-1].first.second,suf[i+1].first.second)};
		check.second = {min(pref[i-1].second.first,suf[i+1].second.first),max(pref[i-1].second.second,suf[i+1].second.second)};
		if(check.first.first < check.first.second && check.second.first < check.second.second){
				printf("%d %d\n",check.first.first,check.second.first); return 0;
		}
	}
	//printf("%d %d\n",ansX.first,ansY.first);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){
	int n;
	scanf(" %d",&n);
	pair<pair<int,int>,pair<int,int>> rect[n];
	for(int i = 0; i < n;++i){
		int x1,y1,x2,y2;
		scanf(" %d %d %d %d",&x1,&y1,&x2,&y2);
		rect[i] = {{x1,x2},{y1,y2}};
	}
	pair<pair<int,int>,pair<int,int>> pref[n],suf[n];
	pref[0] = {rect[0].first,rect[0].second};
	suf[n-1] = {rect[n-1].first,rect[n-1].second};
	for(int i = 1; i < n;++i){
		pref[i].first = {min(pref[i-1].first.first,rect[i].first.first),max(pref[i-1].first.second,rect[i].first.second)};
		pref[i].second = {min(pref[i-1].second.first,rect[i].second.first),max(pref[i-1].second.second,rect[i].second.second)};
	}
	for(int i = n;i > -1;--i){
		suf[i].first = {min(suf[i-1].first.first,rect[i].first.first),max(suf[i-1].first.second,rect[i].first.second)};
		suf[i].second = {min(suf[i-1].second.first,rect[i].second.first),max(suf[i-1].second.second,rect[i].second.second)}
	}
	for(int i = 0; i < n;++i){
		if(i == 0){
			if(suf[i+1].first.first < suf[i+1].first.second && suf[i+1].second.first < suf[i+1].second.second){
				printf("%d %d\n",suf[i+1].first.first,suf[i+1].second.first); return 0;
			}
		}
		else if(i == n){
			printf("%d %d\n",pref[i+1].first.first,pref[i+1].second.first);return 0;
		}
		pair<pair<int,int>, pair<int,int>> check;
		check[i].first = {min(pref[i-1].first.first,suf[i+1].first.first),max(pref[i-1].first.second,suf[i+1].first.second};
		check[i].second = {min(pref[i-1].second.first,suf[i+1].second.first),max(pref[i-1].second.second,suf[i+1].second.second};
		if(check.first.first < check.first.second && check.second.first < check.second.second){
				printf("%d %d\n",check.first.first,check.second.first); return 0;
		}
	}
	//printf("%d %d\n",ansX.first,ansY.first);
	return 0;
}


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

class Rect{
	public:
		int x1,y1,x2,y2;

	Rect intersect(Rect other){
		int nex1 = max(x1,other.x1);
		int nex2 = min(x2,other.x2);
		int ney1 = max(y1,other.y1);
		int ney2 = min(y2,other.y2);
		if(nex1 > nex2 || ney1 > ney2){nex1 = -1000000001;ney2 = -1000000001;nex2 = -1000000001;ney1 = -1000000001;}
		Rect obj(nex1,ney1,nex2,ney2);
		return obj;
	}

	Rect(){

	}

	Rect(int xs1,int ys1,int xs2,int ys2){
		x1 = xs1;y1 = ys1;x2 = xs2;y2 = ys2;
	}
};

int main(){
	int n;
	scanf(" %d",&n);
	Rect recta[n];
	for(int i = 0; i < n;++i){
		int x1,y1,x2,y2;
		scanf(" %d %d %d %d",&x1,&y1,&x2,&y2);
		Rect add(x1,y1,x2,y2);
		recta[i] = add;
		//cout << recta[i].x1 << " " << recta[i].x2 << endl;
	}
	Rect pref[n],suf[n];
	pref[0] = recta[0];
	suf[n-1] = recta[n-1];
	for(int i = 1; i < n;++i)
		pref[i] = pref[i-1].intersect(recta[i]);
	for(int i = n-2; i > -1;--i)
		suf[i] = suf[i+1].intersect(recta[i]);
	for(int i = 0; i < n;++i){
		if(i == 0){
			if(suf[i+1].x1 != -1000000001){
				printf("%d %d",suf[i+1].x1,suf[i+1].y1); return 0;
			}
		}
		if(i == n -1){
			printf("%d %d",pref[i-1].x1,pref[i-1].y1); return 0;
		}
		Rect see = pref[i-1].intersect(suf[i+1]);
		if(see.x1 != -1000000001){
			printf("%d %d",see.x1,see.y1); return 0;
		}
	}
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){
	int n;
	scanf(" %d",&n);
	pair<pair<int,int>,pair<int,int>> rect[n];
	for(int i = 0; i < n;++i){
		int x1,y1,x2,y2;
		scanf(" %d %d %d %d",&x1,&y1,&x2,&y2);
		rect[i] = {{x1,x2},{y1,y2}};
	}
	pair<pair<int,int>,pair<int,int>> pref[n],suf[n];
	pref[0] = {rect[0].first,rect[0].second};
	suf[n-1] = {rect[n-1].first,rect[n-1].second};
	for(int i = 1; i < n;++i){
		pref[i].first = {min(pref[i-1].first.first,rect[i].first.first),max(pref[i-1].first.second,rect[i].first.second};
		pref[i].second = {min(pref[i-1].second.first,rect[i].second.first),max(pref[i-1].second.second,rect[i].second.second};
	}
	for(int i = n;i > -1;--i){
		suf[i].first = {min(suf[i-1].first.first,rect[i].first.first),max(suf[i-1].first.second,rect[i].first.second};
		suf[i].second = {min(suf[i-1].second.first,rect[i].second.first),max(suf[i-1].second.second,rect[i].second.second}
	}
	for(int i = 0; i < n;++i){
		if(i == 0){
			if(suf[i+1].first.first < suf[i+1].first.second && suf[i+1].second.first < suf[i+1].second.second){
				printf("%d %d\n",suf[i+1].first.first,suf[i+1].second.first); return 0;
			}
		}
		else if(i == n){
			printf("%d %d\n",pref[i+1].first.first,pref[i+1].second.first);return 0;
		}
		pair<pair<int,int>, pair<int,int>> check;
		check[i].first = {min(pref[i-1].first.first,suf[i+1].first.first),max(pref[i-1].first.second,suf[i+1].first.second};
		check[i].second = {min(pref[i-1].second.first,suf[i+1].second.first),max(pref[i-1].second.second,suf[i+1].second.second};
		if(check.first.first < check.first.second && check.second.first < check.second.second){
				printf("%d %d\n",check.first.first,check.second.first); return 0;
		}
	}
	//printf("%d %d\n",ansX.first,ansY.first);
	return 0;
}


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

class Rect{
	public:
		int x1,y1,x2,y2;

	Rect intersect(Rect other){
		int nex1 = max(x1,other.x1);
		int nex2 = min(x2,other.x2);
		int ney1 = max(y1,other.y1);
		int ney2 = min(y2,other.y2);
		if(nex1 > nex2 || ney1 > ney2){nex1 = -1000000001;ney2 = -1000000001;nex2 = -1000000001;ney1 = -1000000001;}
		return Rect obj(nex1,ney1,nex2,ney2);
	}

	Rect(int xs1,int ys1,int xs2,int ys2){
		x1 = xs1;y1 = ys1;x2 = xs2;y2 = ys2;
	}
};

int main(){
	int n;
	scanf(" %d",&n);
	Rect recta[n];
	for(int i = 0; i < n;++i){
		int x1,y1,x2,y2;
		scanf(" %d &d &d %d",&x1,&y1,&x2,&y2);
		Rect add(x1,y1,x2,y2);
		recta[i] = add;
	}
	Rect pref[n],suf[n];
	pref[0] = recta[0];
	suf[n-1] = recta[n-1];
	for(int i = 1; i < n;++i)
		pref[i] = pref[i-1].intersect(recta[i]);
	for(int i = n-2; i > -1;--i)
		suf[i] = suf[i+1].intersect(recta[i]);
	for(int i = 0 i < n;++i){
		if(i == 0){
			if(suf[i+1].x1 != -1000000001){
				printf(" %d %d",suf[i+1].x1,suf[i+1].y1); return 0;
			}
		}
		if(i == n -1){
			printf(" %d %d",pref[i-1].x1,pref[i-1].y1); return 0;
		}
		Rect see = pref[i-1].intersect(suf[i+1]);
		if(see.x1 != -1000000001){
			printf(" %d %d",see.x1,see.y1); return 0;
		}
	}
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){
	int n;
	scanf(" %d",&n);
	pair<int,pair<int,int>> Xs[n],Ys[n];
	for(int i = 0; i < n;++i){
		int x1,y1,x2,y2;
		scanf(" %d %d %d %d",&x1,&y1,&x2,&y2);
		Xs[i] = {x1,{x2,i}};
		Ys[i] = {y1,{y2,i}};
	}
	sort(Xs,Xs+n);
	sort(Ys,Ys+n);
	int del = -1;
	for(int i = 0; i < n-1 && del == -1;++i){
		if(Xs[i].second.first < Xs[i+1].first){
			if(i == 0) del = Xs[i].second.second;
			else{
				if(Xs[i-1].second.first >= Xs[i+1].first) del = Xs[i].second.second;
				else del = Xs[i+1].second.second;
			}
		}
	}
	for(int i = 0; i < n-1 && del == -1;++i){
		if(Ys[i].second.first < Ys[i+1].first){
			if(i == 0) del = Ys[i].second.second;
			else{
				if(Ys[i-1].second.first >= Ys[i+1].first) del = Ys[i].second.second;
				else del = Ys[i+1].second.second;
			}
		}
	}
	pair<int,int> ansX = {-1000000000,1000000000}, ansY = {-1000000000,1000000000};
	for(int i = 0; i < n;++i){
		if(Xs[i].second.second != del){
			ansX.first = max(ansX.first,Xs[i].first);
			ansX.second = min(ansX.second,Xs[i].second.first);
		}
		if(Ys[i].second.second != del){
			ansY.first = max(ansY.first,Ys[i].first);
			ansY.second = min(ansY.second,Ys[i].second.first);
		}
	}
	printf("%d %d\n",ansX.second,ansY.second);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){
	int n;
	scanf(" %d",&n);
	pair<pair<int,int>,pair<int,int>> rect[n];
	for(int i = 0; i < n;++i){
		int x1,y1,x2,y2;
		scanf(" %d %d %d %d",&x1,&y1,&x2,&y2);
		rect[i] = {{x1,x2},{y1,y2}};
	}
	pair<pair<int,int>,pair<int,int>> pref[n],suf[n];
	pref[0] = {rect[0].first,rect[0].second};
	suf[n-1] = {rect[n-1].first,rect[n-1].second};
	for(int i = 1; i < n;++i){
		pref[i].first = {min(pref[i-1].first.first,rect[i].first.first),max(pref[i-1].first.second,rect[i].first.second)};
		pref[i].second = {min(pref[i-1].second.first,rect[i].second.first),max(pref[i-1].second.second,rect[i].second.second)};
	}
	for(int i = n;i > -1;--i){
		suf[i].first = {min(suf[i-1].first.first,rect[i].first.first),max(suf[i-1].first.second,rect[i].first.second)};
		suf[i].second = {min(suf[i-1].second.first,rect[i].second.first),max(suf[i-1].second.second,rect[i].second.second)};
	}
	for(int i = 0; i < n;++i){
		if(i == 0){
			if(suf[i+1].first.first < suf[i+1].first.second && suf[i+1].second.first < suf[i+1].second.second){
				printf("%d %d\n",suf[i+1].first.first,suf[i+1].second.first); return 0;
			}
		}
		else if(i == n){
			printf("%d %d\n",pref[i+1].first.first,pref[i+1].second.first);return 0;
		}
		pair<pair<int,int>, pair<int,int>> check;
		check.first = {min(pref[i-1].first.first,suf[i+1].first.first),max(pref[i-1].first.second,suf[i+1].first.second};
		check.second = {min(pref[i-1].second.first,suf[i+1].second.first),max(pref[i-1].second.second,suf[i+1].second.second};
		if(check.first.first < check.first.second && check.second.first < check.second.second){
				printf("%d %d\n",check.first.first,check.second.first); return 0;
		}
	}
	//printf("%d %d\n",ansX.first,ansY.first);
	return 0;
}


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

class Rect{
	public:
		int x1,y1,x2,y2;

	Rect intersect(Rect other){
		int nex1 = max(x1,other.x1);
		int nex2 = min(x2,other.x2);
		int ney1 = max(y1,other.y1);
		int ney2 = min(y2,other.y2);
		if(nex1 > nex2 || ney1 > ney2){nex1 = -1000000001;ney2 = -1000000001;nex2 = -1000000001;ney1 = -1000000001;}
		return Rect obj(nex1,ney1,nex2,ney2);
	}

	Rect(int xs1,ys1,xs2,ys2){
		x1 = xs1;y1 = ys1;x2 = xs2;y2 = ys2;
	}
};

int main(){
	int n;
	scanf(" %d",&n);
	Rect recta[n];
	for(int i = 0; i < n;++i){
		int x1,y1,x2,y2;
		scanf(" %d &d &d %d",&x1,&y1,&x2,&y2);
		Rect add(x1,y1,x2,y2);
		recta[i] = add;
	}
	Rect pref[n],suf[n];
	pref[0] = recta[0];
	suf[n-1] = recta[n-1];
	for(int i = 1; i < n;++i)
		pref[i] = pref[i-1].intersect(recta[i]);
	for(int i = n-2; i > -1;--i)
		suf[i] = suf[i+1].intersect(recta[i]);
	for(int i = 0 i < n;++i){
		if(i == 0){
			if(suf[i+1].x1 != -1000000001){
				printf(" %d %d",suf[i+1].x1,suf[i+1].y1); return 0;
			}
		}
		if(i == n -1){
			printf(" %d %d",pref[i-1].x1,pref[i-1].y1); return 0;
		}
		Rect see = pref[i-1].intersect(suf[i+1]);
		if(see.x1 != -1000000001){
			printf(" %d %d",see.x1,see.y1); return 0;
		}
	}
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){
	int n;
	scanf(" %d",&n);
	pair<pair<int,int>,pair<int,int>> rect[n];
	for(int i = 0; i < n;++i){
		int x1,y1,x2,y2;
		scanf(" %d %d %d %d",&x1,&y1,&x2,&y2);
		rect[i] = {{x1,x2},{y1,y2}};
	}
	pair<pair<int,int>,pair<int,int>> pref[n],suf[n];
	pref[0] = {rect[0].first,rect[0].second};
	suf[n-1] = {rect[n-1].first,rect[n-1].second};
	for(int i = 1; i < n;++i){
		pref[i].first = {min(pref[i-1].first.first,rect[i].first.first),max(pref[i-1].first.second,rect[i].first.second)};
		pref[i].second = {min(pref[i-1].second.first,rect[i].second.first),max(pref[i-1].second.second,rect[i].second.second)};
	}
	for(int i = n;i > -1;--i){
		suf[i].first = {min(suf[i-1].first.first,rect[i].first.first),max(suf[i-1].first.second,rect[i].first.second)};
		suf[i].second = {min(suf[i-1].second.first,rect[i].second.first),max(suf[i-1].second.second,rect[i].second.second)};
	}
	for(int i = 0; i < n;++i){
		if(i == 0){
			if(suf[i+1].first.first < suf[i+1].first.second && suf[i+1].second.first < suf[i+1].second.second){
				printf("%d %d\n",suf[i+1].first.first,suf[i+1].second.first); return 0;
			}
		}
		else if(i == n){
			printf("%d %d\n",pref[i+1].first.first,pref[i+1].second.first);return 0;
		}
		pair<pair<int,int>, pair<int,int>> check;
		check.first = {min(pref[i-1].first.first,suf[i+1].first.first),max(pref[i-1].first.second,suf[i+1].first.second)};
		check.second = {min(pref[i-1].second.first,suf[i+1].second.first),max(pref[i-1].second.second,suf[i+1].second.second)};
		if(check.first.first < check.first.second && check.second.first < check.second.second){
				printf("%d %d\n",check.first.first,check.second.first); return 0;
		}
	}
	//printf("%d %d\n",ansX.first,ansY.first);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){
	int n;
	scanf(" %d",&n);
	pair<int,pair<int,int>> Xs[n],Ys[n];
	for(int i = 0; i < n;++i){
		int x1,y1,x2,y2;
		scanf(" %d %d %d %d",&x1,&y1,&x2,&y2);
		Xs[i] = {x1,{x2,i}};
		Ys[i] = {y1,{y2,i}};
	}
	sort(Xs,Xs+n);
	sort(Ys,Ys+n);
	int del = -1;
	for(int i = 0; i < n-1 && del == -1;++i){
		if(Xs[i].second.first < Xs[i+1].first){
			if(i == 0) del = Xs[i].second.second;
			else{
				if(Xs[i-1].second.first >= Xs[i+1].first) del = Xs[i].second.second;
				else del = Xs[i+1].second.second;
			}
		}
	}
	for(int i = 0; i < n-1 && del == -1;++i){
		if(Ys[i].second.first < Ys[i+1].first){
			if(i == 0) del = Ys[i].second.second;
			else{
				if(Ys[i-1].second.first >= Ys[i+1].first) del = Ys[i].second.second;
				else del = Ys[i+1].second.second;
			}
		}
	}
	pair<int,int> ansX = {-1000000000,1000000000}, ansY = {-1000000000,1000000000};
	for(int i = 0; i < n;++i){
		if(Xs[i].second.second != del){
			ansX.first = max(ansX.first,Xs[i].first);
			ansX.second = min(ansX.second,Xs[i].second.first);
		}
		if(Ys[i].second.second != del){
			ansY.first = max(ansY.first,Ys[i].first);
			ansY.second = min(ansY.second,Ys[i].second.first);
		}
	}
	printf("%d %d\n",ansX.first,ansY.first);
	return 0;
}