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<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 <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);
			}
		}
		if (!flag) {
			printf("NA\n");
		}
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int l,m,n,ans;
  while(cin>>l){
    if(l==0) break;
    ans = 0;
    for(int i=1;i<=12;i++){
      cin >> m >> n;
      ans += m - n;
      if(ans>=l){
	cout << i << endl;
	for(int j=i+1;j<=12;j++) cin >> m >> n;
	break;
      } 
      else if(i==12) cout << "NA" << endl;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int l;

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

C++: #include<iostream>

using namespace std;

int main(){
  int L, Gain[12], Consume[12], i, saving, month;
  while(cin >> L, L){
    for(i=0; i<12; i++){
      cin >> Gain[i] >> Consume[i];
    }
    saving = 0;
    month=0;
    while(saving < L){
      saving += Gain[month] - Consume[month];
      month+=1;
    }
    cout << month << endl;
  }
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef pair<double,double> P;
typedef complex<double> CP;
typedef long long ll;

ll L,N,M;

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

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

int main()
{
  int L;
  while (cin >> L && L != 0) {
    vector<int> ds(12);
    for (int i = 0; i < 12; i++) {
      int M, N;
      cin >> M >> N;
      ds[i] = M-N;
    }

    int s = 0;
    int ans = 0;
    for (int i = 0; i < 12; i++) {
      s += ds[i];
      if (s >= L) {
        ans = i+1;
        break;
      }
    }
    if (ans == 0) {
      cout << "NA" << endl;
    } else {
      cout << ans << endl;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>
using namespace std;

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

C++: #include<iostream>
#include<cmath>
#include<cstdio>

using namespace std;

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

  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 && flag) month++;
      else flag = false;
    }
  
    if (month <= 12) printf("%d\n", month);
    else printf("NA\n");
  }

  return (0);
}

C++: #include<iostream>
using namespace std;
int main(){
    int L;
    while(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 <cstdio>
#include <vector>

using namespace std;

int main(){
	int self;
	int l,m,n;
	int c;
	bool flag;
	while(1){
		scanf("%d",&l);
		if(l == 0){break;}
		c = 0;
		flag = false;
		for(int i = 0;i < 12; i++){
			scanf("%d %d",&m,&n);
			c += m - n;
			if(!flag && c > l){
				printf("%d\n",i+1);
				flag = true;
			}
		}
		if(!flag){
			printf("NA\n");
		}
	}
	return 0;
}

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

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

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

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

int main() {
  for (;;) {
      int L; cin >> L; if (L == 0) break;
      int ans = -1;
      int have = 0;
      REP(step, 12) {
          int a, b; cin >> a >> b;

          have += a;
          have -= b;
          if (have >= L && ans == -1) {
              ans = step + 1;
          }
      }
      if (ans == -1) cout << "NA" << endl;
      else cout << ans << endl;
  }
  return 0;
}