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<iostream>
using namespace std;
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(void){
  int cost,M,N,cnt,yatta,flg,cnt1;
   
  while(1){
    cnt = yatta = flg = cnt1 = 0;
     
    cin >> cost;
    if( cost == 0 ) break;
 
    while(1){
 
    
      if( cnt1 == 12 ) break;
 
      cin >> M >> N;
 
      if( flg == 0 ){
      yatta += (M - N);
      if( cost <= yatta ) flg = 1;
      cnt++;
      }
      cnt1++;
    }
 
    if( cost <= yatta ) cout << cnt << endl;
    else cout << "NA" << endl;
  }
  return 0;
}

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

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

C++: #define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
using namespace std;
int main(){

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

}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int L;
  while (cin >> L, L) {
    int M[12], N[12];
    for (int i = 0; i < 12; i++) {
      cin >> M[i] >> N[i];
    }
    int sum = 0, ans = -1;
    for (int i = 0; i < 12; i++) {
      sum += M[i] - N[i];
      if (sum >= L) {
        ans = i + 1;
        break;
      }
    }
    if (ans < 0) cout << "NA" << endl;
    else cout << ans << endl;
  }

  return 0;
}

C++: #include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
	int L,N,M;
	int sum;
	int answer;

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

	return 0;
}

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

int main(void){

  int i,L,M,N,bank=0,min=99;

  while(1){
    bank = 0;  
    cin >> L;
    if(L == 0) break;

    for(i = 1; i <= 12; i++){
      cin >> M >> N;
      bank += M - N;
      if(bank >= L){
	if(i < min) min = i;
      }
    }
    
    if(bank >= L) cout << min << endl;
    else cout << "NA" << endl;
    bank = 0;
  }
  
  
  return 0;
}

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

int main(void){
	int l;
	while(cin>>l,l){
		int ans = -1;
		for(int i=0;i<12;i++){
			int n,m;
			cin>>m>>n;
			l -= m - n;
			if(ans == -1 && l <= 0) ans = i + 1;
		}

		if(ans == -1) cout<<"NA\n";
		else cout<<ans<<endl;
	}

	return 0;
}

C++: #include <iostream>
#include <sstream>

using namespace std;

int main(){
	int i;
	string month;
	long int cost,sum,income,outcome;
	while(cin >> cost && cost != 0){
//		cout << cost;
		int sum = 0;
		bool flag = 1;
		for(i=0;i<12;i++){
			cin >> income >> outcome;
			sum += income - outcome;
			if(sum >= cost && flag){
				stringstream tuki;
				tuki << i+1;
				month = tuki.str();
				flag = !flag; 
			}
		}
		if(flag) month = "NA";
		cout << month << endl;
	}


}

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

int main() {
    int goal;
    while(cin >> goal, goal) {
        bool flag = false;
        int stack = 0;
        for(int i = 0; i < 12; ++i) {
            int a, b;
            cin >> a >> b;
            stack += a - b;
            if(!flag && stack >= goal) {
                cout << i + 1 << endl;
                flag = true;
            }
        }
        if(!flag) cout << "NA" << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;
int main(void) {
  int i,j;
  int l;
  while(1){
    cin>>l;
    if(l==0)break;
    vi m(12);
    vi n(12);
    rep(i,12)
      cin>>m[i]>>n[i];
    rep(i,12){
      l-=m[i]-n[i];
      if(l<=0)break;
    }
    if(i<12)
      cout<<i+1<<endl;
    else
      cout<<"NA"<<endl;
  }
}

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

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

C++: #include <cstdio>

int main(void) {
	while(true) {
		int n;
		scanf("%d", &n);
		if(n == 0)
			break;

		int ans = 0;
		for(int i = 1; i <= 12; i++) {
			int p, q;
			scanf("%d %d", &p, &q);
			n -= p - q;
			if(ans == 0 && n <= 0)
				ans = i;
		}
		if(ans != 0)
			printf("%d\n", ans);
		else
			printf("NA\n");
	}
	return 0;
}

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

int main() {
    int goal;
    while(cin >> goal, goal) {
        bool flag = false;
        int stack = 0;
        for(int i = 0; i < 12; ++i) {
            int a, b;
            cin >> a >> b;
            stack += a - b;
            if(!flag && stack >= goal) {
                cout << i + 1 << endl;
                flag = true;
            }
        }
        if(!flag) cout << "NA" << endl;
    }
    return 0;
}

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