program gls;
var
ans:longint;
a,b,n,k:longint;
ss,st:array[1..1000]of longint;
f,g:text;
function min(a,b:longint):longint;
begin
if a>b then min:=b else min:=a;
end;
function max(a,b:longint):longint;
begin
if a>b then max:=a else max:=b;
end;
begin
assign(f,'ppg.in');
reset(f);
assign(g,'ppg.out');
rewrite(g);
readln(f,n);
for k:=1 to n do
begin
readln(f,a,b);
ss[k]:=a;
st[k]:=b;end;
for k:=1 to n do
ans:=max(ans,min(ss[k],st[k]));
writeln(g,ans);
close(f);close(g);
end.