Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
Here:
	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)
				continue Here
			}
		}
		fmt.Println("NA")
	}
}

C++: #include<iostream>
using namespace std;
int main(){
    int L;
    while(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;
        }
        else if (t<L){
             if (i==11){
        cout << "NA" << endl;
        }
    }
    }
    }
    return 0;
    }

C++: #include<iostream>
using namespace std;
int main(){
long l,m,n,s,i,ii,f;
while(cin>>l){
if(l==0)break;
for(s=ii=f=0,i=0;i<12;i++){
cin>>m>>n;
s+=m-n;
if(f==0&&s>=l){ii=i+1;f=1;}
}
if(ii==0)cout<<"NA"<<endl;
else cout<<ii<<endl;
}
return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <sstream>

#define mp make_pair
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define ll long long

using namespace std;

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

C++: #include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	int L;
	while(scanf("%d", &L), L){
		int M, N;
		int money = 0;
		int ans = -1;
		rep(i, 12){
			scanf("%d%d", &M, &N);
			money += M - N;
			if(ans == -1 && money >= L){
				ans = i + 1;
			}
		}
		if(ans == -1)
			puts("NA");
		else
			printf("%d\n", ans);
	}

	return 0;
}

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

int main() {
	int i, L, M, N, sum = 0;
	
	for(;;){
		i = 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(L != 0){
			if(sum >= L){
				cout << i << endl;
			}else { 
				cout << "NA" << endl;
			}
		}
		
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

typedef long long ll;

main(){
  while(1){
    ll L;
    cin >> L;
    if(L==0) break;
    bool first=true;
    ll sum=0;
    for(int i=0;i<12;i++){
      ll M, N;
      cin >> M >> N;
      sum+=M-N;
      if(first && sum>=L){
	first=false;
	cout << i+1 << endl;
      }
    }
    if(first) cout << "NA" << endl;
  }
  return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int w,n,z,x,i,k,c;
	while(1){
	c=0;
	k=0;
		scanf("%d",&n);
		 if(n==0) break;
	for(i=0;i<12;i++){
			scanf("%d %d",&z,&x);
			k+=z-x;	
//			printf("%d\n",k);
		if(k>n){
			c++;	
		}			
	}
	if(c==0||c>12){
		printf("NA\n");
	}
	else{
		printf("%d\n",c-1);
	}
  }	
	return	0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <map>
#include <functional>
#include <cmath>
#include <cstdio>
using namespace std;

int main(){
  unsigned long int L, N, M;
  while(cin >> L, L){
    int ans = 0;
    unsigned long int sum = 0;
    for(int i = 0; i < 12; i++){
      cin >> M >> N;
      sum += (M - N);
      if(sum >= L && !ans){
        ans = i + 1;
      }
    }
    if(sum < L)cout << "NA" << endl;
    else cout << ans << endl;
  }
}

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

int l;
typedef pair<int,int> pii;
vector<pii> data;
void init(){
  data.clear();
}


bool input(){
  if(!(cin>>l))return false;
  if(l==0)return false;
  for(int i=0;i<12;i++){
    int m,n;
    cin>>m>>n;
    data.push_back(pii(m,n));
  }
  return true;
}

int  solve(){
  int m=0;
  for(int i=0;i<data.size();i++){
    m+=data[i].first-data[i].second;
    if(!(m<l)){
      return i+1;
    }
  }
  return -1;
}

int main(){
  while(init(),input()){
    int ans= solve();
    if(ans==-1){
      cout<<"NA"<<endl;
    }else{
      cout<<ans<<endl;
    }
  }
}

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

int main(void)
{
  int L,m,n,q=0,r=0;
  while(1){
    cin >> L;
    if(L == 0) break;
    else{
      for(int i= 0;i < 12;++i){
        cin >> m >> n;
        q +=m-n;
        ++r;
        if(q >= L) break;
      }
      if(q < L) cout << "NA" << endl;
      else{
        cout << r << endl;
      }
    }
  }
}

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

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

C++: #include <cstdio>

#define REP(a, n) for (int i = (a); i < n; i++)

using namespace std;

int main()
{
  int l, m, n, sum = 0, month = 1;
  
  while (scanf("%d", &l), l){
    REP(0, 12){
      scanf("%d%d", &m, &n);
      sum += m - n;
      if (sum < l) month++;
    }
  
    if (month <= 12) printf("%d\n", month);
    else printf("NA\n");
  }

  return (0);
}

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

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

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

int main(){
	int L;
	while(cin >> L && L){
		int ok = 0 , oktime = 1e9;
		for(int i = 1 ; i <= 12 ; i++){
			int M,N;
			cin >> M >> N;
			ok += M - N;
			if( ok >= L ) oktime = min(oktime,i);
		}
		if( oktime > 1000 ) cout << "NA" << endl;
		else cout << oktime << endl;
	}
}

C++:  #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int main()
 {
   int travel;
   while(cin>>travel&&travel)
   {
     int sum=0;
     for(int i=0;i<12;i++)
     {
       int a,b;
       cin>>a>>b;
       sum+=(a-b);
       if(sum>=travel) 
       {
         cout<<(i+1)<<endl;
         break;                
       }        
     }                            
   }
   //while(1);
   return 0;
 }

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
int main(){
    int l;
    while(cin>>l,l){
        vi v(12,0);vi u(12,0);
        int sum=0; int hoge=INF;
        rep(i,12){cin>>v[i]>>u[i];sum+=(v[i]-u[i]);if(sum>l){hoge=i+1;break;}}
        (hoge!=INF ? cout<<hoge<<endl:cout<<"NA"<<endl);

    }
}