Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		val := 0
		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 && val == 0 {
				val = i+1
			}
		}
		if val == 0 {
			fmt.Println("NA")
		} else {
			fmt.Println(val)
		}
	}
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <utility>
#include <set>
#include <cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define all(v) v.begin(),v.end()
#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))
using namespace std;
typedef pair<int,int> point;
typedef complex<double> P;
typedef long long ll;

const double eps = 1e-8;
const double INF = 1e12;


double dot(P a,P b){
	return a.real()*b.real()+a.imag()*b.imag();
}
double cross(P a,P b){
	return a.real()*b.imag()-a.imag()*b.real();
}

bool is_orthogonal(P a1,P a2,P b1,P b2){
	return EQ(dot(a1-a2,b1-b2),0.0);
}
bool is_parallel(P a1,P a2,P b1,P b2){
	return EQ(cross(a1-a2,b1-b2),0.0);
}

bool is_point_on_line(P a,P b,P c){
	return EQ(cross(b-a,c-a),0.0);
}

bool is_point_on_linesegment3(P a,P b,P c){
	return (abs(a-c)+abs(c-b)<abs(a-b)+EPS);
}

double distance_l_p(P a,P b,P c){
	return abs(cross(b-a,c-a))/abs(b-a);
}


double distance_ls_p(P a,P b,P c){
	if(dot(b-a,c-a)<EPS)return abs(c-a);
	if(dot(a-b,c-b)<EPS)return abs(c-b);
	return abs(cross(b-a,c-a))/abs(b-a);
}

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

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

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

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

C++: #include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

int L;
int up[12];

void solve(){
  int now = 0;

  rep(i,12){
    now += up[i];
    if(now >= L){
      cout<<i+1<<endl;
      return;
    }
  }
  cout<<"NA\n";
}

int main(){
  while(cin>>L,L){
    rep(i,12){
      int n,m;
      cin>>n>>m;
      up[i] = n - m;
    }
    solve();
  }
}

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

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

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