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;
  while (cin >> L) {
    if (L == 0)
      break;

    int money = 0, ans = -1;
    for (int i = 0; i < 12; ++i) {
      int M, N;
      cin >> M >> N;
      money += M - N;
      if (money >= L && ans == -1)
	ans = i+1;
    }

    if (ans == -1)
      cout << "NA" << endl;
    else
      cout << ans << endl;
  }
  return 0;
}

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

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int L;
	while(cin >> L, L)
	{
		vector<P> Vec(12);
		for(int i = 0; i < 12; ++i)
		{
			cin >> Vec[i].first >> Vec[i].second;			
		}
		int sum = 0;
		for(int i = 0; i < 12; ++i)
		{
			sum += Vec[i].first - Vec[i].second;
			if(sum >= L)
			{
				cout << i + 1 << endl;
				goto NEXT;
			}
		}
		cout << "NA" << endl;
NEXT:
		;
	}
}

int main()
{
	solve();
	return(0);
}

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

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

C++: #include <iostream>
#include <vector>
using namespace std;
int main(void)
{
	int cost,saving;
	vector< vector<int> > money(12,vector<int>(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<stdio.h>
int main(void)
{
	int w,n,z,x,i,k,c;
	while(1){
	c=0;
	k=0;
		scanf("%d",&n);
		 if(n==0) break;
	for(i=0;i<12;i++){
			scanf("%d %d",&z,&x);
			k+=z-x;	
			c++;
		if(k>n) break;
	}	
	if(c==0||c>=12){
		printf("NA\n");
	}
	else{
		printf("%d\n",c);
	}
   }
	return	0;
}

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

int main(){
	long long int l,m,n,i,t,b,s;
	
	while(cin >> l,l){
		t=0,s=0;
		
		for(i=1;i<=12;i++){
			cin >> m >> n;
			
			t+=(m-n);
			
			if(l<t && s==0){
				b=i;
				s++;
			}
		}
		if(s==1){
			cout << b << endl;
		}
		else{
			cout << "NA" << endl;
		}
	}
	return 0;
}

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;
			  break;
		  }
		}
      if(k==0) printf("NA\n");
	  else printf("%d\n",k);
	}
  return 0;
}

C++: #include<iostream>
using namespace std;
int sum, n, a, b, ok;
int main() {
	while (true) {
		sum = 0;
		ok = 0;
		cin >> n;
		if (n == 0) { break; }
		for (int i = 0; i < 12; i++) {
			cin >> a >> b;
			sum += a - b;
			if (sum >= n && ok == 0) { cout << i + 1 << endl; ok = 1; }
		}
		if (ok == 0) { cout << "NA" << endl; }
	}
}

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

int main() {
	int l, m[MN], n[MN];
	while (cin >> l, l) {
		for (int i=0; i<MN; i++)
			cin >> m[i] >> n[i];

		int sum = 0;
		int ans=-1;
		for (int i=0; i<MN; i++) {
			sum += m[i]-n[i];
			if (sum >= l) { ans=i+1; break; }
		}

		if (ans!=-1)
			cout << ans << endl;
		else
			cout << "NA" << endl;
	}
	return 0;
}

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