Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		val := 0
		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 && val == 0 {
				val = i+1
			}
		}
		if val == 0 {
			fmt.Println("NA")
		} else {
			fmt.Println(val)
		}
	}
}

C++: #include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int a,b,i;
	int m[12];
	rep(i,12){
	  cin>>a>>b;
	  m[i]=a-b;
	}
	int sum=0;
	rep(i,12){
	  sum+=m[i];
	  if(n<sum)break;
	}
	if(i==12)cout<<"NA"<<endl;
	else cout<<i+1<<endl;
  }
}

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;
 }