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

}

C++: #include<stdio.h>
int main(){
	int L,M,N,t=0,c=0,i;
	for(;;t=0,c=0){
		scanf("%d",&L);
		if(L==0)break;
		for(i=1;i<13;i++){
			scanf("%d%d", &M, &N);
			t+=M-N;
			if(t>=L&&c==0){
				c=i;
			}
		}
		if(c!=0)printf("%d\n",c);
		else puts("NA");
	}
	return 0;
}

C++: #include<stdio.h>
int main(void){
	while(1){
		int l,m,n,r=0,cnt=0;
		scanf("%d",&l);
		if(l==0)return 0;
		int i;
		for(i=0;i<12;i++){
			scanf("%d%d",&m,&n);
			r+=(m-n);
		    
			if(r>=l&&cnt==0)cnt=i+1;
		}
		if(cnt!=0)printf("%d\n",cnt);
		else printf("NA\n");
	}
	return 0;
}

C++: #include<iostream>

using namespace std;


int main(void)
{
	int M[12] = {0};
	int N[12] = {0};
	int L = 0;
	
	while (true)
	{
		int ans = 0;

		cin >> L;
		if (L == 0)	{	return 0; }


		int i = 0;

		for (i = 0; i < 12; i++)
		{
			cin >> M[i] >> N[i];
		}

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

		if (i == 12)
		{
			cout << "NA" << endl;
			continue;
		}

		cout << ans << endl;
	}

	return 0;
}

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

int main(void) {
	int L, M, N;

	while(cin >> L, L) {
		int sum = 0;
		bool flag = true;

		for(int i = 0; i < 12; i++) {
			cin >> M >> N;
			sum += M - N;

			if(sum >= L && flag) {
				cout << i + 1 << endl;
				flag = false;
			}
		}

		if(flag)
			cout << "NA" << endl;
	}
}

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 != 0){
    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 ct = 0;
		for (int i = 0; i < 12; i++){
			cin >> m >> n;
			if (l > 0){
				l -= (m - n);
				ct++;
			}
		}
		if (l > 0){
			cout  << "NA";
		}
		else {
			cout << ct;
		}
		cout << endl;
	}
	return (0);
}

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", cm);
	}
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int a;
	while(cin>>a,a){
		vector<int>sa(12);
		rep(i,12){
			int b,c;
			cin>>b>>c;
			sa[i]=b-c;
		}
		int sum=0;
		rep(i,12){
			sum+=sa[i];
			if(sum>=a){
				cout<<i+1<<endl;
				break;
			}
			if(i==11)cout<<"NA"<<endl;
		}
	}
}

C++: #include<iostream>
using namespace std;
int main(){
    int L;
    cin >> L;
    int t;
    t = 0;
    for(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 l,m,n;
  
  for(;;){
    
    int flg = 0,cnt = 0,sum = 0;    
    
    cin >> l;
    if( l == 0 ) break;
    
    for( int i = 0 ; i < 12 ; i++ ){
      cin >> m >> n;
      sum +=  m - n;
      if( flg == 0 ){
	if( l <= sum ) flg = 1;
	cnt++;
	}
      }
      
    if( cnt == 12 ) cout << "NA" << endl;
    else cout << cnt << endl;

  }
 
  return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
	
	int L,M,N,Rest;
	int month;
	bool flag;
	while(cin>>L,L!=0){
		Rest=0;
		flag=false;
		for(int i=1;i<=12;i++){
			cin>>M>>N;
			Rest=Rest+(M-N);
			if(Rest>=L){
				if(flag==false){
					month=i;
				}
				flag=true;
			}
		}
		if(flag){
			cout<<month<<endl;
		}else{
			cout<<"NA"<<endl;
		}
	}
	
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
    while (true) {
        int L;
        cin >> L;
        
        if (L==0) {
            break;
        }
        
        int M[12], N[12];
        
        for (int i=0; i<12; i++) {
            cin >> M[i] >> N[i];
        }
        
        int c = 0;
        bool flag = true;
        
        for (int i=0; i<12; i++) {
            c += M[i]-N[i];
            
            if (c>=L) {
                cout << i+1 << endl;
                flag = false;
                break;
            }
        }
        
        if (flag) {
            cout << "NA" << endl;
        }
    }
}

C++: #define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair<int,string> P;

static const double eps = 1e-8;

int main(){
	int L;
	while(~scanf("%d",&L)){
		if(L==0) break;
		int sum=0;
		int res=INF;
		for(int i=0;i<12;i++){
			int M,N;
			scanf("%d %d",&M,&N);
			sum += M-N;
			if(sum >= L){
				res = min(i+1,res);
			}
		}

		if(res==INF) printf("NA\n");
		else printf("%d\n",res);
	}
}

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