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 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 (ct > 12){
			cout  << "NA";
		}
		else {
			cout << ct;
		}
		cout << 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 ){
	tmp[i] = 1;
      }
    }
    
    if( savings >= L ){
      for( i=0 ; i<12 ; i++ ){
	if( tmp[i] == 1 ){
	  cout << i << endl;
	  break;
	}
      }
    }
    
    else{
      cout << "NA" << endl;
    }
    savings = 0;
    j = 0;

  }

  return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	vector<int>l;
	long a, b, sum, need;
	while (cin >> need){
		sum = 0;
		if (need == 0){
			break;
		}
		bool b = false;
		for (int i = 0; i < 12; i++){
			cin >> a >> b;
			sum += a - b;
			if (sum >= need&&b == false) {
				b = true;
				l.push_back(i + 1);
			}
			if (i == 11 && sum < need){
				l.push_back(0);
			}
		}
	}
	for (int i = 0; i < l.size(); i++){
		if (l[i] == 0){
			cout << "NA";
		}
		else cout << l[i];
		cout << endl;
	}
}

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

int main() {
	int l;
	while (cin >> l, l) {
		int a[12][2];
		for (int i = 0;i < 12;i++) {cin >> a[i][0] >> a[i][1];}
		int c = 0;
		int m = 0;
		int flg = 1;

		for (int i = 0;i < 12;i++) {
			c += a[i][0] - a[i][1];
			m++;
			if (c >= l) {
				flg = 0;
				break;
			}
		}

		if (flg == 1)cout << "NA" << endl;
		else cout << m << endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int l;cin>>l,l;){
		vi a(12);
		rep(i,12){
			int m,n; cin>>m>>n;
			a[i]=(i==0?0:a[i-1])+m-n;
		}
		int res=lower_bound(allof(a),l)-a.begin();
		if(res==12)
			cout<<"NA"<<endl;
		else
			cout<<res+1<<endl;
	}
	
	return 0;
}

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

C++: #include <iostream>

using namespace std;

int main(void){
	for(int cost; cin >> cost, cost;){
		int result = 0;
		for(int i = 1, in, out; i <= 12; i ++){
			cin >> in >> out;
			cost -= (in - out);
			if(cost <= 0 && !result) result = i;
		}
		if(!result) cout << "NA" << endl;
		else cout << result << endl;
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int L, M, N, sum, i, k;
	while(1)
	{	
		cin >> L;
		if ( L == 0 )break;
		else
		{
			k = 0;
			sum = 0;
			for ( i = 0; i < 12; i++ )
			{
				cin >> M >> N;
				sum = (sum + (M - N));
				if ( sum <= L )k++;
			}
			k = k + 1;
			if ( sum < L )cout << "NA" << endl;
			else cout << k << endl;
		}
	}	
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

void solve(int x){
    vector<int> M(12), N(12);
    int S = 0;
    for (int i = 0; i < 12; ++i) {
        cin >> M[i] >> N[i];
    }
    for (int i = 0; i < 12; ++i) {
        S += M[i]-N[i];
        if(S >= x){
            cout << i+1 << "\n";
            return;
        }
    }
    puts("NA");
}

int main() {
    int x;
    while(cin >> x, x){
        solve(x);
    }
    return 0;
}

C++: #include<iostream>

using namespace std;

#define M 12

int main(){

  int cost,m,n;
  int sum;
  int st;
  while(1){
    sum=0;
    st=0;
    cin >>cost;
    if(cost==0) break;

    for(int i=1;i<=M;i++){
      cin >>m>>n;
      if(sum<cost){
      sum+=(m-n);
      if(sum>=cost)st=i;
      }
    }
    
    if(st!=0)cout <<st<<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 main(){
	int L;
	while(cin >> L && L){
		int last = 0 , f = 0;
		for(int i = 1 ; i <= 12 ; i++){
			int a,b;
			cin >> a >> b;
			int c = a-b;
			last += c;
			if( last < L ){
				f = i;
			}
		}
		if( last < L ){
			cout << "NA" << endl;
		}else{
			cout << f+1 << 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 <iostream>
#include <sstream>

using namespace std;

int main(){
	int i;
	string month;
	long int cost,sum,income,outcome;
	while(cin >> cost && cost != 0){
//		cout << cost;
		int sum = 0;
		bool flag = 1;
		for(i=0;i<12;i++){
			cin >> income >> outcome;
			sum += income - outcome;
			if(sum > cost && flag){
				stringstream tuki;
				tuki << i+1;
				month = tuki.str();
				flag = !flag; 
			}
		}
		if(flag) month = "NA";
		cout << month << endl;
	}


}