#include <iostream>

using namespace std;

int main(){
	int m,n,l,f,sum;
	while(cin>>l){
	if(l==0)break;
	f=1;
	sum=0;
	while(cin>>m>>n){
	if(f>13){
	cout<<"NA"<<endl;
	break;
	}
	sum+=m-n;
	if(l<=sum)cout<<f<<endl;
	f++;
	}
}
}