#import main(){int n,x,y;for(scanf("%d%d",&x,&n);scanf("%d%d",&x,&y)&n--;printf("%d",(x>y?x:y)));}