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>
using namespace std;
int main() {
	int a, ans,moku, b, tyokin;
	while (1) {
		cin >> moku;
		if (moku == 0) {
			goto a;
		}
		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;
		}
	}
a:;
}

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

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

int main()
{
  int l;

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

C++: #include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
	while(1) {

		bool isfirst = true;
		int M, N, L, S = 0;

		cin >> L;
		if( L == 0 )
			break;
		
		for( int i = 0; i < 12; i++ ) {

			cin >> M >> N;

			S += M - N;

			if( L <= S && isfirst ) {
				cout << i+1 << endl;
				isfirst = false;
			}
		}

		cout << "NA" << endl;
	NEXT:;	

	}

    return 0;
}

C++: #include <iostream>

using namespace std;

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

C++: #include<iostream>
using namespace std;
int main() {
	int money;
	while (cin >> money&&money != 0) {
		int get[12], use[12];
		for (int i = 0; i < 12; ++i) {
			cin >> get[i] >> use[i];
		}
		int ans = -1;
		int num = 0;
		for (int i = 0; i < 12; ++i) {
			num += get[i] - use[i];
			if (num >= money) {
				ans = i + 1;
				break;
			}
		}
		if (ans != -1) {
			cout << ans << endl;
		}else{
			cout << "NA" << endl;
		}
	}
	return 0;
}

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 M,N,L,cnt,ans;
int main(){
  while(cin>>L&&L){
    ans=cnt=0;
    for(int i=0;i<12;i++){
      cin>>M>>N;
      cnt+=(M-N);
      if(cnt>=L&&ans==0)ans=i+1;
    }
    if(ans==0)cout<<"NA"<<endl;
    else cout<<ans<<endl;
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
  int L, Gain[12], Consume[12], i, saving, month;
  while(cin >> L, L){
    for(i=0; i<12; i++){
      cin >> Gain[i] >> Consume[i];
    }
    saving = 0;
    month = 0;
    for(i=0; i<12; i++){
      if(saving < L){
	month += 1;
      }
      saving += Gain[i] - Consume[i];
    }
    if(month<=12 && saving >= L){
      cout << month << endl;
    }else{
      cout << "NA" << endl;
    }
  }
}

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++){
      int m, n;
      cin >> m >> n;

      if(ans != -1) continue;

      l -= m - n;

      if(l <= 0){
        ans = i + 1;
      }
    }

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

C++: #include<iostream>

using namespace std;

int main()
{
	int n;
	int M,N;
	int i,j;
	int ans;
	
	for(;cin >> n;)
	{
		if(n==0)
			break;
			
		ans=0;
		
		for(i=0;i<12;i++)
		{
			cin >> M >> N ;
			n-=M-N;
			if(ans==0 && n<0)
				ans=i+1;
		}
		
		if(ans!=0)
			cout << ans <<endl;
		else
			cout << "NA" << endl;
	}
}

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

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

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
typedef long long int ll;

int main()
{
    int cost=0;
    int l;
	int m,n;
	bool f;
    for(;;){
		cin >> l;
		cost=0;
		f=true;
		if(l==0)break;
		for(int i=0;i<12;i++){
			cin >> m >> n;
			cost+=m;
			cost-=n;
			if(cost>=l&&f){
				printf("%d\n",i+1);
				f=false;
			}
		}
		if(f)printf("NA\n");
	}
    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 money=0 , i , ans=0;
		for( i = 0; i<12; i++)  
		{
			int n , m;
			cin >> m >> n;
			money += m-n;
			if( l < money ) {
				ans = i+1;
				l = 100000000;
			}
		}
		if( ans ) cout << ans;
		else cout << "NA";
		puts("");
	}
	return 0;
}

C++: #include<stdio.h>

int main(void){
	int L,M,N,k[12],i,kai;
	while(scanf("%d",&L)!=EOF){
		kai=0;
		for(i=1;i<13;i++){
			scanf("%d %d",&M,&N);
			k[i]=M-N;
		}
        for(i=1;i<1;i++){
			L-=k[i];
			  if(L<=0){
				  kai=i;
				  break;
			  }
		}
		if(kai==0) printf("NA\n");
	    else printf("%d\n",kai);
	}
  return 0;
}

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

int main(){
    int trip,sui,tou,total,flag;
    while(1){
        total = 0;
        flag = 0;
        cin >> trip;
        if(trip == 0){
            break;
        }
        for(int i=0;i<12;i++){
            cin >> sui >> tou;
            total += sui - tou;
            if(total >= trip){
                cout << i+1 << endl;
                flag = 1;
                break;
            }
        }
        if(flag == 0){
            cout << "NA" << endl;
        }
    }
}

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

int main(void){
  int l,m,n;
  
  for(;;){
    
    int flg = 0,cnt = 0;    
    
    cin >> l;
    if( l == 0 ) break;
    
    for( int i = 0 ; i < 12 ; i++ ){
      cin >> m >> n;
      l = l - ( m - n );
      if( flg == 0 ){
	cnt++;
	if( l <= 0 ) flg = 1;

	}
      }
      
    if( cnt == 12 ) cout << "NA" << endl;
    else cout << cnt << endl;

  }
 
  return 0;
}