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 <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);


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

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

int main(void){

  int i,L,M,N,bank=0,min=99;

  while(1){
    min = 99;
    bank = 0;  
    cin >> L;
    if(L == 0) break;

    for(i = 1; i <= 12; i++){
      cin >> M >> N;
      bank += M - N;
      if(bank >= L){
	if(i < min) min = i;
      }
    }
    
    if(bank >= L) cout << min << endl;
    else cout << "NA" << endl;
  }
  
  
  return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;
typedef pair<int,int> P;
const int INF = 1<<29;


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

        int chokin = 0, ans = 0;
        for(int i=0;i<12;i++){
            int M,N;
            scanf("%d %d",&M,&N);
            if(ans)continue;
            chokin += M-N;
            if(L <= chokin) ans = i+1;
        }
        if(ans)cout << ans << endl;
        else cout << "NA" << endl;
    }

    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
 
  int cost,M,N;
  while(1){
    int sum=0,buf=0;
    
    cin >> cost;
    if(cost ==0)break;
    for(int i=0;i<12;i++){
      cin>>M>>N;
      sum+=(M-N);
      if(sum>=cost && buf==0){
	buf=i+1;
      }
    }
    if(buf==0) cout<<"NA"<<endl;
    else cout<<buf<<endl;
  }
  return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<climits>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reg(i,a,b) for(int i=(a);i<=(b);i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=(b);i>=(a);i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX


int main(void){
	while(1){
		int n;
		scanf("%d",&n);
		if(n==0)break;
		int s=0,ans=-1;
		rep(i,12){
			int a,b;
			scanf("%d%d",&a,&b);
			s+=(a-b);
			if(ans==-1 && s>=n)ans=i+1;
		}
		if(ans==-1)printf("NA\n");
		else printf("%d\n",ans);
	}
			
	return 0;
}

C++: #include <iostream>

using namespace std;

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

C++: #include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)

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

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

int main() {
    int L;

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

C++: #include <iostream>
#include <string>

using namespace std;

int main() {
  int l, m, n;
  ios::sync_with_stdio(false);
  
    
  while (1) {
    cin >> l;
    //cout << "aa" << l << endl;
    if(l!=0){
      int i;
      int month=0;
      for(i=1;i<=12;i++){
	cin >> m >> n;
	//cout << i << m << n << endl;
	
	l = l - (m-n);
	if(l<=0 && month==0)
	  {month = i;}
      }

      //cout << "bb" << l << endl;

      if(month==0)
	cout << "NA" <<endl;
      else
	cout << month << endl;
    }
    else
      break;
  }
    
    return 0;
}

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){
	if(f)cout << i+1 << endl;
	f = 0;
      }
    }
    if(!f)cout << "NA" << endl;
  }
  return 0;
}

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

C++: #include<stdio.h>

int main(void){
	int L,M,N,k[12],i,kai;

	while(scanf("%d\n",&L)!=0){

		kai=0;

		for(i=1;i<13;i++){
			scanf("%d %d\n",&M,&N);
			k[i]=M-N;
		}

        for(i=1;i<1;i++){
			L-=k[i];
			  if(L<=0){
				  kai=i;
				  break;
			  }
		}

		if(kai==0) printf("NA\n");
	    else printf("%d\n",kai);
	}
  return 0;
}

C++: #include <iostream>

using namespace std;

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

C++: //53
#include<iostream>

using namespace std;

int main(){
  for(int L;cin>>L,L;){
    int m=0;
    for(int i=1;i<=12;i++){
      int M,N;
      cin>>M>>N;
      L-=M-N;
      if(m==0&&L<=0){
	m=i;
      }
    }
    if(m){
      cout<<m<<endl;
    }else{
      cout<<"NA"<<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 = 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;
}