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)
				continue
			}
		}
		fmt.Println("NA")
	}
}

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

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main(){
  int i ,j=0 ,n ,m ,L ,tmp[13] ,savings=0;
  while( 1 ){  // 目標金額
    cin >> L;
    if( L == 0 ){
      break;
    }
    for( i=0 ; i<12 ; i++ ){
      tmp[i] = 0;
    }
    if( L == 0 ){
      break;
    }
    
    for( i=1 ; i<=12 ; i++ ){
      cin >> m >> n;       // 小遣い　使用金額
      savings = savings + ( m - n );
      if( savings > L && j == 0 ){
	tmp[0] = i;
	j++;
      }
    }
    
    if( savings >= L ){
      cout << tmp[0] << endl;
    }

    else{
      cout << "NA" << endl;
    }
    j=0;
  }

  return 0;
}

C++: #include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

int main() {
  while( 1 ) {
    int l;
    cin >> l;
    if( !l ) { return EXIT_SUCCESS; }
    
    int mth = -1;
    for( int i = 1; i <= 12; i++ ) {
      int m, n;
      cin >> m >> n;
      l -= ( m - n );
      if( mth == -1 && l < 0 ) { mth = i; }
    }
    cout << ( mth == -1 ? "NA" : to_string( mth ) ) << endl;
  }
}

C++: #include <iostream>
using namespace std;
int main( void )
{
	int L;
	while ( cin >> L && L )
	{
		int kotae = 0;
		int now = 0;
		int M, N;
		for ( int i = 0; i < 12; i++ )
		{
			cin >> M >> N;

			now += M - N;
			if ( kotae == 0 && now >= L )
			{
				kotae = i + 1;
			}
		}

		if ( kotae )
			cout << kotae << endl;
		else
			cout << "NA" << endl;
	}

	return 0;
}