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>
using namespace std;

int main(void){
  int l,i,fin,m,n,sum;
  while(cin>>l,l){
    sum=0;
    for(i=0;i<12;i++){
      cin>>m>>n;
      sum+=m-n;
      cout<<sum<<" "<<m-n<<" "<<l<<endl;
      if(l>sum)fin=i;
    }
    if(fin!=11)
      cout<<fin+1<<endl;
    else
      cout<<"NA"<<endl;
  }
}

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

int main(){
	int s;
	while(scanf("%d", &s), s){
		int x, y;
		int ans = -1;
		for(int i = 1; i <= 12; ++i){
			scanf("%d%d", &x, &y);
			s -= x - y;
			if(s <= 0 && ans == -1){
				ans = i;
			}
		}
		printf(ans == -1 ? "NA\n" : "%d\n", ans);
	}
}

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;
        }
        else if (t<L){
             if (i==11){
        cout << "NA" << 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>
using namespace std;
int main()
{
	int L, M, N, sum, i, k;
	while(1)
	{	
		sum = 0;
		cin >> L;
		if ( L == 0 )break;
		else
		{
			k = 1;
			sum = 0;
			for ( i = 1; i < 13; 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 <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;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

ll l, m, n, sum;
int f = 0;

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

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){
		i=10000;
		}
	}	
	if(c==0||c>=12){
		printf("NA\n");
	}
	else{
		printf("%d\n",c);
	}
   }
	return	0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

using namespace std;

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

C++: #include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define MP make_pair
int main(){
  int l,m,n;
  while(cin>>l&&l){
    int stack=0,ans=-1;
    for(int i=0;i<12;i++){
      cin>>m>>n;
      stack+=(m-n);
      if(stack>=l&&ans==-1)ans=i+1;
    }
    if(ans!=-1)cout<<ans<<endl;
    else cout<<"NA"<<endl;
  }
}

C++: #include <iostream>

using namespace std;

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

C++: #include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int l;
    while(1){
        cin >> l;
        if(l==0) break;

        int cnt =0;
        bool flag = false;
        rep(i,12){
            int a, b;
            cin >>a >> b;
            if(flag) continue;
            cnt += a-b;
            if(cnt >= l){
                cout << i+1 << endl;
                flag = true;
            }
        }
        
        if(cnt<l) 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;
			  L=1000000000;
		  }
		}
      if(k==0) printf("NA\n");
	  else printf("%d\n",k);
	}
  return 0;
}