#include<iostream>
using namespace std;
int main()
{
	freopen("traverse.in","r",stdin);
	freopen("traverse.out","w",stdout);
	int c,T;scanf("%d %d",&c,&T);
	srand(20070522);//纪念我摆烂的oi生涯，NOIP后AFO了 
	while(T--)
	{
		int n,k;
		scanf("%d %d",&n,&k);
		printf("%d\n",rand()%(n-k)+k);
		
	}
}
