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

C++: #include <iosteam>
#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=0i<12;i++){
			cin >> money[i][0] >> money[i][1];
		}
		for(int i=0;i<12;i++){
			saving+=money[i][0]-[i][1];
			if(cost<=saving){
				cout << i+1 << endl;
				break;
			}
		}
		if(money<saving) cout << "NA" << endl;
		money.clear();
	}
	return 0;
}

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

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

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 <vector>
#include <functional>
#include <algorithm>
using namespace std;

#define rep(i,a) for(int i=0;i<(a);++i)

int main()
{
    int L, M, N, sum;
    while(cin >> L && L) {
        bool ok = false;
        sum = 0;
        rep(i, 12) {
            cin >> M >> N;
            sum += M - N;
            if(!ok && sum >= L) {
                cout << i + 1 << endl;
                ok = true;
            }
        }
        if(!ok) 
            cout << "NA" << endl;
    }
}

C++: #include <iostream>

using namespace std;

int main() {
    while(true) {
        int L;
        cin >> L;
        if(!L) break;

        int amt = 0;
        int ans = 0;
        for(int i = 0; i < 12; ++i) {
            int M, N;
            cin >> M >> N;
            amt += M-N;
            if(ans == 0 && amt >= L) ans = i+1;
        }
        if(ans > 0) cout << ans << endl;
        else cout << "NA" << endl;
    }
    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 = 0; i < 12; i++) {
			temp += info[i];
			
			if (temp > L) {
				cout << i+1 << endl;
				break;
			}
		}
		
		if (temp < L) {
			cout << "NA" << endl;
		}
	}
	
	return 0;
}

C++: #include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int l,m,n,s,a;
	while(cin>>l,l){
		s=0,a=1;
		rep(i,12){
			cin>>m>>n; s+=m-n;
			if(s<l)a++;
		}
		if(a<=12)cout<<a<<endl;
		else cout<<"NA"<<endl;
	}
	return 0;
}

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

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

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

  while(true){
    cin >> l;
    if(!l)break;

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

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

int main(){
    int n;
    while(cin >>n){
        if(n == 0) break;
        int i, ans = -1;
        bool fnd = false;
        for(i = 1; i <= 12; i++){
            int a, b; cin >>a >>b;
            n -= (a - b);
            if(n <= 0 && fnd == false){
                ans = i;
                fnd = true;
            }
        }
        if(fnd == false) cout <<"NA" <<endl;
        else cout <<ans <<endl;
    }
    return 0;
}

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

int main(){
    int L,m,n;
    while(cin>>L, L){
        int s = 0;
        bool ok =false;
        int ans = -1;
        for(int i=0; i<12; i++){
            cin>>m>>n;
            s +=(m-n);
            if(s>=L && !ok){
                ok =true;
                ans = i+1;
            }
        }
        if(ok){
            cout << ans << endl;
        } else {
            cout << "NA" << endl;
        }
    }
}

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

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

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

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);


int main(){
	int l;
	while(cin>>l,l){
	int sum=0;
	int i;
	vi m(12),n(12);
	for(i=0;i<12;i++){
		cin>>m[i]>>n[i];
	}
	for(i=0;i<12;i++){
		sum+=m[i]-n[i];
		if(sum>=l){
			break;
		}
	}
	if(i==12){
		cout<<"NA"<<endl;
	}else{
		cout<<i+1<<endl;
	}}
}

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

int main(void){

  int i,L,M,N,bank=0,min=99;

  while(1){
    min = 99;
    bank = 0;  
    cin >> L;
    if(L == 0) break;

    for(i = 1; i <= 12; i++){
      cin >> M >> N;
      bank += M - N;
      if(bank >= L){
	if(i < min) min = i;
      }
    }
    
    if(bank >= L) cout << min << endl;
    else cout << "NA" << endl;
  }
  
  
  return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;
typedef pair<int,int> P;
const int INF = 1<<29;


int main(){
    while(1){
        int L;
        scanf("%d",&L);
        if(L==0)break;

        int chokin = 0, ans = 0;
        for(int i=0;i<12;i++){
            int M,N;
            scanf("%d %d",&M,&N);
            if(ans)continue;
            chokin += M-N;
            if(L <= chokin) ans = i+1;
        }
        if(ans)cout << ans << endl;
        else cout << "NA" << endl;
    }

    return 0;
}

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