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 M = 0;
	int N = 0;
	int L = 0;
	
	while (true)
	{
		int ans = 0;

		cin >> L;
		if (L == 0)	{	return 0; }


		int i = 0;

		for (i = 0; i < 12; i++)
		{
			if (L < 0)
			{
				;
			}
			else
			{
				ans++;
			}
	
			cin >> M >> N;
			L = L + N - M;
		}

		if (L > 0)
		{
			cout << "NA" << endl;
			continue;
		}

		cout << ans << endl;
	}

	return 0;
}

C++: #include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;


int main(){

	int L,M,N,sum,ans;
	bool FLG;

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

		sum = 0;
		FLG = false;

		for(int i = 0; i < 12; i++){
			scanf("%d %d",&M,&N);

			if(!FLG){
				sum += M-N;

				if(sum >= L){
					ans = i+1;
					FLG = true;
				}
			}
		}

		if(!FLG)printf("NA\n");
		else{
			printf("%d\n",ans);
		}

	}

    return 0;
}

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

int main(){
	int l,m,n;
	int sum,month;
	bool flag = false;
	
	while(cin >> l,l){
		flag = false;
		month = 0;
		sum = 0;
		for(int i=0;i<12;i++){
			cin >> m >> n;
			sum += (m-n);
			if(sum > l && flag == false){
				month = i + 1;
				flag = true;
			}
		}
		
		if(!month)	cout << "NA" << endl;
		else	cout << month << endl;
	}
	return 0;
}

C++:  #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int main()
 {
   int travel;
   while(cin>>travel&&travel)
   {
     int sum=0;
     int sign;
     bool flag=false;
     for(int i=0;i<12;i++)
     {
       int a,b;
       cin>>a>>b;
       sum+=(a-b);
       if(sum>=travel) 
       {
         flag=true;
         sign=i+1;          
       }        
     }            
     if(flag) cout<<sign<<endl;
     else cout<<"NA"<<endl;                
   }
   //while(1);
   return 0;
 }

C++: #include<iostream>
int main(){
	while(1){
		int a;
		std::cin>>a;
		if(a==0)break;
		int b,c=0;
		for(int i=1;i<13;i++){
			int n,m;
			std::cin>>n>>m;
			b+=n;
			b-=m;
			if(b>=a){
				std::cout<<i<<std::endl;
				c=1;
				break;
			}
		}
		if(c==0)std::cout<<"NA"<<std::endl;
	}
	return 0;
}

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

int main() {
	// your code goes here
	int n,m,s,sum;
	while(cin >> n && n!=0){
		sum=0;
		int i;
		for(i=0;i<12;i++){
			cin >> m >> s;
			sum+=m-s;
		if(sum>=n){
		cout << i+1 << endl;
		break;
		}
		}
		for(;i<12;i++)
		cin >> m >> s;
		if(sum<n)
		cout << "NA" << endl;
	}
	return 0;
}

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

int main() {
    int L, m, n, brk, i, j;
    while (cin >> L && L) {
        brk = -1;
        for (i=1; i<13; i++) {
            cin >> m >> n;
            L -= m - n;
            if (L <= 0 && brk == -1) {
                brk = i;
            }
        }
        if (brk == -1) {
            cout << "NA" << endl;
        } else {
            cout << brk << endl;
        }
    }
    return 0;
}

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

int main() {

    int L, m, n, res;

    for (; ;) {
        scanf("%d", &L);
        res = -1;
        if (L == 0) break;
        for (int i = 0; i < 12; i++) {
            scanf("%d %d", &m, &n);
            L-= m-n;
            if (L <= 0 && res < 0) res = i+1;
        }
        (L > 0) ? printf("NA\n") : printf("%d\n", res);
    }
    return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
int main(){
    int n;
    while(cin>>n&&n){
        int sum=0; int hoge=INF;bool s=true;
        rep(i,12){pii p; cin>>p.first>>p.second;sum+=p.first-p.second;if(sum>=n&&s){hoge=i+1;s=false;}}
        if(hoge==INF){cout<<"NA"<<endl;}else cout<<hoge<<endl;
    }
    return 0;
}

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

C++: #include <iostream>

using namespace std;

static const int MAX_L = 1000000;
static const int MAX_M = 100000;
static const int MAX_N = 100000;

int main(int argc, char** argv)
{
	int L, M, N;
	int c, save;
	bool is_ok;

	while( 1 )
	{
		cin >> L;
		if(L==0) break;
		
		save = 0;
		c = 0;
		is_ok = false;
		for(int i=0; i<12; i++)
		{
			cin >> M;
			cin >> N;
			save += M - N;

			if(save >= L)
			{
				if(!is_ok) c = i+1;
				is_ok = true;
			}
		}

		if(is_ok) cout << c << endl;
		else cout << "NA" << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int l;
        cin >> l;
        if(l == 0)
            return 0;

        int ret = -1;
        for(int i=1; i<=12; ++i){
            int m, n;
            cin >> m >> n;
            l -= m;
            l += n;
            if(ret == -1 && l <= 0)
                ret = i;
        }

        if(ret == -1)
            cout << "NA" << endl;
        else
            cout << ret << endl;
    }
}

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 L,M,N,tmp,ans;

int main(){
	while(true){
		cin >> L;
		if(!L)
			return 0;
		tmp = 0;
		ans = 0;
		for(int i=0; i<12; i++){
			cin >> M >> N;
			tmp += M-N;
			if(tmp >= L && !ans)
				ans = i+1; 
		}
		if(ans)
			cout << ans << endl;
		else
			cout << "NA\n";
	}
}

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