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 a, ans,moku, b, tyokin;
	while (1) {
		cin >> moku;
		tyokin = 0;
		ans = 0;
		for (int i = 1; i <= 12; i++) {
			cin >> a >> b;
			tyokin += a - b;
			if (moku <= tyokin) {
				ans = i;
				tyokin = -99999999;
			}
		}
		if (ans == 0) {
			cout << "NA" << endl;
		}
		else {
			cout << ans << endl;
		}
	}
}

C++: #include <cstdio>
int main(){
	int l;
	while(scanf("%d", &l), l){
		int cm = -1;
		for(int i=1;i<=12;i++){
			int m, n;
			scanf("%d%d", &m, &n);
			l -= m - n;
			if(l <= 0 && cm < 0)
				cm = i;
		}
		if(cm<0)puts("NA");
		else printf("%d\n", cm);
	}
}

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

int main(){
	int l,m,n,i,t,b,s;
	
	while(cin >> l,l){
		t=0,s=0;
		
		for(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 <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

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

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;

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

        bool ok = true;
        rep(i, 12) {
            int m, n;
            cin >> m >> n;
            if (m-n >= l) {
                if (ok) cout << i+1 << endl;
                ok = false;
            } else l -= m-n;
        }
        if (ok) cout << "NA" << endl;
    }

    return 0;
}

C++: #include <iostream>
using namespace std;
int main()
{
	int l;
	int m,n;
	int num=0;
	int a[12];

	while(true){

		cin >> l;

		if(l==0)
			break;

		for(int i=0 ;i<12 ;i++){
			cin >> m >> n;

			num += (m - n);
			a[i] = num;
		}
		for(int i=0 ;i<12 ;i++){
			
			if(a[i] >= l){
				cout << i << endl;
				break;
			}
			else if(i==11){
				cout << "NA" << endl;
			}
		}
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

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

C++: #include<iostream>

int main()
{
	int L;
	while( std::cin >> L, L )
	{
		bool f = false;
		for( int i = 0; i != 12; ++i )
		{
			int M, N;
			std::cin >> M >> N;
			L -= M - N;
			if( L <= 0 && !f )
			{
				std::cout << i + 1 << std::endl;
				f = true;
			}
		}

		if( !f )
			std::cout << "NA" << std::endl;
	}

	return 0;
}

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

int main(){
	long long int l, m, n;
	long long int savingMoney;
	bool output = true;

	while(cin >> l, l){
		savingMoney = 0;
		for(int i=1; i <= 12; i++){
			cin >> m >> n;
			savingMoney += m - n;

			if(l <= savingMoney && output){
				cout << i << endl;
				output = false;
			}
			if(i == 12 && savingMoney < l){
				cout << "NA" << endl;
			}
		}

	}
}

C++: #include<stdio.h>

int main(){
	int a[12],b[12];
	int c;
	while(1){
		scanf("%d",&c);
		if(c==0)break;
		for(int i=0;i<12;i++)scanf("%d%d",&a[i],&b[i]);
		int d=0;
		for(int i=0;i<12;i++){
			d+=a[i]-b[i];
			if(d>=c){
				printf("%d\n",i+1);
				break;
			}else if(i==11)printf("NA\n");
		}
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int L;
  while(cin>>L,L!=0){
    int chokin=0,month=0;
    for(int i=1;i<=12;i++){
      int syuueki,syouhi;
      cin>>syuueki>>syouhi;
      chokin+=(syuueki-syouhi);
      if(month!=0)
	continue;
      if(chokin>=L)
	month=i;
    }
    if(month==0)
      cout<<"NA"<<endl;
    else
      cout<<month<<endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

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

C++: #include<iostream>
#include<cmath>
#include<cstdio>

using namespace std;

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

  return 0;
}

C++: #include <iostream>
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
using namespace std;
int main(){
	int n,a[12],b[12];
	while(cin >> n, n) {
		int m = 0;
		rep(i,12) {
			cin >> a[i] >> b[i];
		}
		rep(i,12) {
			m += a[i]-b[i];
			if(m>=n) {
				cout << i+1 << endl;
				break;
			}
		}
		if(m<n) cout << "NA" << endl;
	}
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(void)
{
	int cost,saving;
	vector< vector<int> > money(12,2);
	while(1){
		cin >> cost;
		if(cost==0) break;
		saving=0;
		for(int i=0;i<12;i++){
			cin >> money[i][0] >> money[i][1];
		}
		for(int i=0;i<12;i++){
			saving+=money[i][0]-money[i][1];
			if(cost<=saving){
				cout << i+1 << endl;
				break;
			}
		}
		if(saving<cost) cout << "NA" << endl;
		money.clear();
	}
	return 0;
}

C++: #include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

const int MAX_M = 12;

int main() {
	while (true) {
		int L, M, N;
		int info[MAX_M] = {0};

		int temp = 0;

		cin >> L;
		if (L == 0) break;
		
		for (int i = 0; i < 12; i++) {
			M = 0; N = 0;
			cin >> M >> N;
			info[i] = M - N;
		}

		for (int i = 1; i <= 12; i++) {
			temp += info[i-1];
			
			if (temp >= L) {
				cout << i << endl;
				break;
			}
		}
		
		if (temp < L) {
			cout << "NA" << endl;
		}
	}
	
	return 0;
}

C++: #include<iostream>
#define N 12

using namespace std;

int main () {

  int L;
  int m,n;
  int mon;
  bool skip;

  while ( true ) {
    cin >> L;
    if ( L == 0 )
      break;
    //sum = L;
    skip = false;
    for ( int i=0; i<N; i++ ) {
      cin >> m >> n;
      L -= m-n;
      if ( L <= 0 && !skip ) {
	skip = true;
	mon = i+1;
      }
      
    }

    if ( skip )
      cout << mon << endl;
    else
      cout << "NA\n";
   }

}