#include<stdio.h>
int main(){
  int n,m,r,t,nt,g,i,j,a,b;
  int c[51]={0};
  while(scanf("%d %d",&n,&m),n||m){
    t=n;
    while(n)c[n]=--n;
    for(i=0;i<m;i++){
      scanf("%d %d",&a,&b);
      if(a==1)continue;
      g=t;//printf("g:%d\n",c[g]);
      for(j=2;j<a;j++)g=c[g];
      r=g;//printf("r:%d\n",r);
      //if(a-1)g=c[g];
      nt=g=c[g];
      for(j=1;j<b;j++)g=c[g];
      c[r]=c[g];
      c[g]=t;
      t=nt;
      //for(j=t;j;j=c[j])printf("%d ",j);printf("\n");
    }
    printf("%d\n",t);
    //}
  }
  return 0;
}