Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		L, _ := strconv.Atoi(scanner.Text())
		if L == 0 {
			break
		}
		for i := 0; i < 12; i++ {
			scanner.Scan()
			buf := strings.Split(scanner.Text(), " ")
			M, _ := strconv.Atoi(buf[0])
			N, _ := strconv.Atoi(buf[1])
			L -= (M-N)
			if L <= 0 {
				fmt.Println(i+1)
				break
			}
		}
		fmt.Println("NA")
	}
}

C++: #include <cstdio>
#include <vector>

using namespace std;

int main(){
	int self;
	int l,m,n;
	int c;
	bool flag;
	while(1){
		scanf("%d",&l);
		if(l == 0){break;}
		c = 0;
		flag = false;
		for(int i = 0;i < 12; i++){
			scanf("%d %d",&m,&n);
			c += m - n;
			if(!flag && c >= l){
				printf("%d\n",i+1);
				flag = true;
			}
		}
		if(!flag){
			printf("NA\n");
		}
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
 
int main()
{
int L,i,count;
int M,N;
while(cin>>L,L){
count = 0;
for(i=0;i<12;i++){
cin>>M>>N;
L -= (M-N);
if(L<=0 && !count)count=i+1;
}
if(L<=0)cout<<count<<endl;
else cout<<"NA"<<endl;
}
return 0;
}

C++: #include<iostream>
using namespace std;

int main(){
  int n,m,l;
  while(true){
    cin >> l;
    if(l==0)break;

    bool f = false;
    for(int i=0;i<12;i++){
      cin >> m >> n;
      l -= m-n;
      if(l<=0 && !f){
	cout << i+1 << endl;
	f = true;
      }
    }
  
    if(!f)cout << "NA" << endl;
  }
}

C++: #include <iostream>
using namespace std;

int main(){
	long l,m,n,t,b,s;
	
	while(cin >> l,l){
		t=0,s=0;
		
		for(int i=1;i<=12;i++){
			cin >> m >> n;
			
			t+=(m-n);
			
			if(l<t && s==0){
				b=i;
				s++;
			}
		}
		if(s==1){
			cout << b << endl;
		}
		else{
			cout << "NA" << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
using namespace std;

int main() {
	int i, L, M, N, sum = 0;
	
	for(;;){
		L = M = N = sum = 0;
		cin >> L;
		if(L == 0)	break;
		for(i = 1; i <= 12; i++){
			cin >> M >> N;
			sum += M - N;
			if(sum >= L)break;
		}
		if(sum < L)
			cout << "NA"<< endl;
		else 
			cout << i << endl;
		
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int main()
{
	int n;
	int M,N;
	int i,j;
	int ans;
	
	for(;cin >> n;)
	{
		if(n==0)
			break;
			
		ans=0;
		
		for(i=0;i<12;i++)
		{
			cin >> M >> N ;
			n-=M-N;
			if(ans==0 && n<=0)
				ans=i+1;
		}
		
		if(ans!=0)
			cout << ans <<endl;
		else
			cout << "NA" << endl;
	}
}

C++: #include <bits/stdc++.h>

using namespace std;

int main()
{
	int L;
	while(cin >> L && L)
	{
		int n,m;
		int flag=0;
		for(int i=0;i<12;i++)
		{
			cin >> n >> m;
			L-=(n-m);
			if(L<=0 && !flag)
			{
				flag=1;
				cout << i+1 << endl;
			}
		}
		if(L>0)cout << "NA" << endl;
	}

    return 0;
}

C++: #include <iostream>
using namespace std;

int main(){
	long long int price,a,b,n,month;
	bool judge;
	while(cin >> n && n){
		price = 0;
		judge = false;
		for(int i = 0;i< 12 ;i++){
			cin >> a >> b;
			price += (a-b);
			if(price >= n && judge == false) {
				month = i + 1;
				judge = true;
			}
		}
		if(judge == true) cout << month << endl;
		else cout << "NA" << endl;
	}
	return 0;
}

C++: // AOJ0206.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include <iostream>

using namespace std;


int main()
{
	int l = 0, m = 0, n = 0, cash = 0, ans=0;
	cin >> l;
	while (l){
		for (int i = 1; i <= 12; i++){
			cin >> m >> n;
			cash += m - n;
			if (cash >= l){
				ans = i;
			}
		}
		if (ans){
			cout << ans << endl;
		} else{
			cout << "NA" << endl;
		}
		m = n = cash = ans = 0;
		cin >> l;
	}
	return 0;
}

C++: #include<stdio.h>

int main(void){
	int L,M,N,k[12],i,kai;

	while(0==0){
		scanf("%d",&L);
		if(L==0) break;

		kai=0;

		for(i=1;i<13;i++){
			scanf("%d %d\n",&M,&N);
			k[i]=M-N;
		}

        for(i=1;i<1;i++){
			L-=k[i];
			  if(L<=0){
				  kai=i;
				  break;
			  }
		}

		if(kai==0) printf("NA\n");
	    else printf("%d\n",kai);
	}
  return 0;
}

C++: #include <cstdio>

int main() {
	int L, M, N;
	while (scanf("%d", &L)) {
		if (L == 0) break;
		int res = 0;
		bool flag = true;
		for (int i=0; i<12; i++) {
			scanf("%d%d", &M, &N);
			L -= (M - N);
			if (flag) {
				res++;
			}
			if (L <= 0) flag = false;
		}
		if (res == 12 && L > 0) {
			printf("NA\n");
		} else {
			printf("%d\n", res);
		}
	}
}

C++: int main(){
    int L;
    cin >> L;
    int t;
    t = 0;
    for(int i=0;i<12;++i){
        int Plus;
        int Minus;
        cin >> Plus >> Minus;
        t += Plus - Minus
        if (t>=L){
            cout << i+1 << endl;
            break;
        }
        };
    if (t<L){
        cout << "NA" << endl;
    }
    return 0;
    }

C++: #include <iostream>

using namespace std;


int main()
{
	int l = 0, m = 0, n = 0, cash = 0, ans = 0;
	cin >> l;
	while (l){
		for (int i = 1; i <= 12; i++){
			cin >> m >> n;
			cash += m - n;
			if (cash >= l){
				ans = i;
				break;
			}
		}
		if (ans){
			for (int i = ans + 1; i <= 12; i++){
				cin >> m >> n;
			}
			cout << ans << endl;
		} else{
			cout << "NA" << endl;
		}
		m = n = cash = ans = 0;
		cin >> l;
	}
	return 0;
}

C++: #include<iostream>

using namespace std;
int main(void){

	int L,M,N,wa=0,mo=-1;
	while(1){
		wa=0,mo=-1;
		cin>>L;
		if(L==0) break;
		for(int i=1;i<=12;i++){
			cin>>M>>N;
			wa+=M-N;
			if(wa>=L&&mo==-1) mo=i;
		}
		if(mo!=-1) cout<<mo<<endl;
		else cout<<"NA"<<endl;
	}
	return 0;
}

C++: // #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 10????????? cout << setprecision(10) << double;
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (???test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// ??\??????push_back(d)???array[d]???????????????1?????§?????????
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN(){T d;cin>>d;return d;}
// ?????§??¬?´???°???Greatest Common Divisor???
LL gcd(LL a, LL b){ return (b > 0) ? gcd(b, a%b) : a; }
// ????°???¬?????°???Least Common Multiple???
LL lcm(LL a, LL b){ return a / gcd(a, b) * b; }

// ------------------- include, typedef, define END. -------------------

int main(){
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;
	
	//??????????????????????????????.
	int L=0;
	while(cin>>L,L){
		int ans = 0;
		LL nowChochiku = 0;
		FOR(i,0,12){
			int M=0,N=0;
			cin>>M>>N;
			nowChochiku += (M-N);

			if(ans == 0 && nowChochiku>=L){
				ans = i+1;
			}
		}
		// ans??????
		if(ans)	cout << ans << endl;
		else	cout << "NA" << endl;
	}
	
	return 0;
}

C++: #include <iostream>
using namespace std;

int money(int n){
	int sum = 0;
	int month = 0;
	for(int i=0; i<12; ++i){
		int a,b;
		cin >> a >> b;
		sum += a-b;
		if(sum >= n){
			month = i+1;
		}
	}
	return month;
}

int main(){
	int n;
	int result;
	while(cin >> n&& n){
		result = money(n);
		if(result == 0){
			cout << "NA" << endl;
		} else {
			cout << result << endl;
		}
	}
	return 0;
}