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(){
    long int trip,sui,tou,total,flag;
    while(1){
        total = 0;
        flag = 0;
        cin >> trip;
        if(trip == 0){
            break;
        }
        for(int i=0;i<12;i++){
            cin >> sui >> tou;
            total += sui - tou;
            if(total >= trip){
                cout << i+1 << endl;
                flag = 1;
                break;
            }
        }
        if(flag == 0){
            cout << "NA" << endl;
        }
    }
}

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

int main(){
	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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int l;
	while(cin >> l && l)
	{
		int res = 0;
		rep(i, 12)
		{
			int n, m;
			cin >> n >> m;
			l -= n - m;
			

			if(l <= 0 && !res)
				res = i + 1;
		}

		if(res)
			cout << res << endl;
		else
			cout << "NA" << endl;
	}
}

C++: #include<iostream>
int main(){
	while(1){
		int a;
		std::cin>>a;
		if(a==0)break;
		int b=0,c=0,d=0;
		for(int i=1;i<13;i++){
			int n,m;
			std::cin>>n>>m;
			int h=n-m;
			b+=h;
			if(a<=b&&c==0)d=i,c=1;
		}
		if(c==0)std::cout<<"NA"<<std::endl;
		else std::cout<<d<<std::endl;
	}
	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 l;
    while(cin>>l,l){
        vi v(12,0);vi u(12,0);
        int sum=0; int hoge=INF;
        rep(i,12){cin>>v[i]>>u[i];sum+=(v[i]-u[i]);if(sum>l){hoge=i+1;break;}}
        (hoge!=INF ? cout<<hoge<<endl:cout<<"NA"<<endl);

    }
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b;
  while(cin>>n,n){
    int q=12,o=1;
    while(q--){
      cin>>a>>b;
      n-=a-b;
      if(o&&n<=0){
        cout<<12-q<<endl;
        o--;
      }
    }
    if(o)cout<<"NA"<<endl;
  }
}

C++: #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
int L,res;
int main()
{
	while(1)
	{
		res=0;
		cin >> L;
		if(L==0)break;
		int ans=-1;
		for(int i=0;i<12;i++)
		{
			int n,m;
			cin >> m >> n;
			res+=m-n;
			if(ans==-1&&res>=L)ans=i+1;
		}
		if(ans==-1)cout << "NA" << endl;
		else cout << ans << endl;
	}
	return 0;
}

C++: #include <cstdio>

#define REP(a, n) for (int i = (a); i < n; i++)

using namespace std;

int main()
{
  int l, m, n, sum = 0, month = 1;
  bool flag = true;
  
  while (scanf("%d", &l), l != 0){
    REP(0, 12){
      scanf("%d%d", &m, &n);
      sum += m - n;
      if (sum >= l) continue;
      month++;
    }
  
    if (month <= 12) printf("%d\n", month);
    else printf("NA\n");
  }

  return (0);
}

C++: #include<stdio.h>
int main(void)
{
	int w,n,z[100000],x[100000],i,k,c;
	while(1){
		scanf("%d",&n);
		 if(n==0) break;
	c=0;
	k=0;	 
	for(i=0;i<12;i++){
			scanf("%d %d",&z[i],&x[i]);
	}
	for(i=0;i<12;i++){
			k+=z[i]-x[i];
//			printf("%d\n",k);
			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(void)
{
  int L,m,n,a=0;
  while(1){
    cin >> L ;
    if(L == 0) break;
    else{
      for(int i = 0 ; i< 12;++i){
        cin >> m >> n;
        a += m-n;
        if(a >= L) cout << i+1 << endl;
      }
      if(a >= L) cout << 12 << endl;
      else cout << "NA" << endl;
    }
  }
  return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 27;
const double EPS = 1e-10;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)

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

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int L;
  int m,n;
  while(1){
    int sum=0;
    int mon;
    int flag=0;
    cin>>L;
    if(L==0) break;
    
    for(int i=0;i<12;i++){
      cin>>m>>n;
      sum=sum+(m-n);
      if(sum>=L && flag==0){
	mon=i+1;
	flag=1;
      }
    }
    if(sum>=L){
      cout<<mon<<endl;
    }else{
      cout<<"NA"<<endl;
    }
  }
}