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;

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

C++: #include<stdio.h>

int main ()
{
int M,N,w,m;
int num[12]={};
long R;
w=0;m=0;
while(1)
{
w=0;m=0;
scanf("%ld",&R);
if(R==0)break;
for(int i=0;i<12;i++){
scanf("%d %d",&M,&N);
w=w+(M-N);
if(w>=R){num[m]=(i+1);m++;}
}
if(w>=R)printf("%d\n",num[0]);
else printf("NA\n");

}
return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int L;
  int m,n;
  while(1){
    int sum=0;
    cin>>L;
    if(L==0) break;
    for(int i=0;i<12;i++){
      cin>>m>>n;
      sum+=m-n;
      if(sum>=L){
	cout<<i+1<<endl;
	break;
      }
    }
    if(sum<L){
      cout<<"NA"<<endl;
    }
  }
}

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

int main()
{
	int N;
	int h[12],L[12];
	while (cin >> N) {
		if (N == 0)
			break;
		for (int i = 0; i < 12; i++) {
			cin >> h[i]>>L[i];
		}
		int cont = 0;
		for (int i = 0; i < 12; i++) {
			cont += h[i] - L[i];
			if (cont >= N) {
				cout << i+1 << endl;
				break;
			}
		}
		if (cont < N)
			cout << "NA" << endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int n;
	for(;n=in();){
		int a,b,i,res=-1;
		for(i=0;i<12;i++){
			a=in();b=in();
			n-=a-b;
			if(n<=0)if(res==-1)res=i+1;
		}
		if(res!=-1)cout<<res<<endl;
		else cout<<"NA\n";
	}
}

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

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

C++: #include<stdio.h>

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

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

int main () {

  int L;
  int sum;
  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 )
	mon = i+1;
      
    }

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

}

C++: //Next Trip
#include <iostream>

using namespace std;

int main(){
	int aimL;//旅行費用
	int nowL;//現在貯蓄
	int M, N;//貯蓄額/出費額
	bool isoutput;
	while (1){
		cin >> aimL;
		if (aimL == 0)break;

		nowL = 0;
		isoutput = false;
		for (int i = 0; i < 12; ++i){
			cin >> M >> N;
			nowL += (M - N);
			if (nowL >= aimL && !isoutput){
				cout << (i + 1) << endl;
				isoutput = true;
			}
		}
		if (!isoutput)cout << "NA" << endl;
	}


	return 0;
}

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

	while(true){
		int num = 0;
		cin >> l;

		if(l==0)
			break;

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

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

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main(){
  int i ,n ,m ,L ,savings=0;
  while( scanf( "%d" ,&L ) != EOF ){             // 目標金額
    if( L == 0 ){
      break;
    }
    
    for( i=1 ; i<=12 ; i++ ){
      cin >> m >> n;      // 小遣い　使用金額
      savings = savings + ( m - n );
      if( savings >= L ){ // 目標金額に達したら
	break;
      }
    }
    
    if( savings >= L ){
      cout << i << endl;
    }
    
    else{
      cout << "NA" << endl;
    }
    savings = 0;
  }

  return 0;
}

C++: #include <bits/stdc++.h>

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("%lld", &x); return (x); }

int main()
{
	int m, n, l;
	int nowMoney;
	int completeMonth;

	while( 1 )
	{
		l = in();
		if( l == 0 )break;
		
		nowMoney = 0;
		completeMonth = 13;

		loop(i, 0, 12)
		{
			scanf("%d%d", &m, &n);
			nowMoney += m - n;
			if( nowMoney >= l && i + 1 < completeMonth )
			{
				completeMonth = i + 1;
			}
		}
		if( completeMonth == 13 )
		{
			cout << "NA" << endl;
		}
		else
		{
			cout << completeMonth << endl;
		}
	}

	return (0);
}

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

int money(int n){
	int month[12];
	int sum = 0;
	for(int i=0; i<12; ++i){
		int a,b;
		cin >> a >>b;
		sum += a-b;
		if(sum >= n){
			return i+1;
		}
	}
	return 0;
}

int main(){
	int n;
	int result;
	while(cin >> n&& n){
		result = money(n);
		if(result == 0){
			cout << "NA" << endl;
		} else {
			cout << result << endl;
		}
	}
	return 0;
}

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

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	int l;

	while(cin >> l && l)
	{
		bool flag = false;
		int t,t2;
		vector<int> v;
			
		rep(i,12)
		{
			cin >> t >> t2;
			v.push_back(t-t2);
		}

		rep(i,12)
		{
			l -= v[i];
			if(l <= 0)
			{
				flag = true;
				cout << i+1 << endl;
				break;
			}
		}

		if(!flag)
		{
			cout << "NA" << endl;
		}
	}
	return 0;
}