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>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

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

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int L;
    while(cin>>L,L){
        bool endFlag=false;
        int ans,sum=0;
        for(int i=0;i<12;i++){
            int M,N;
            cin>>M>>N;
            if(endFlag)continue;
            sum+=(M-N);
            if(L<=sum){
                ans=i+1;
                endFlag=true;
            }
        }
        if(!endFlag)cout<<"NA"<<endl;
        else cout<<ans<<endl;
    }
}

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(){
	int n,a,b,ans;
	while(cin>>n,n){
		ans=-1;
		for(int i=1;i<=12;i++){
			cin>>a>>b;
			n -= a-b;
			if(ans==-1 && n<=0)ans=i;
		}
		if(ans!=-1)cout<<ans<<endl;
		else cout<<"NA\n";
	}
}

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

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;
        }
        }
    if (t<L){
        cout << "NA" << 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;
  
  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 <iostream>
#include <cstdio>
using namespace std;
int main(void) {
  int L;
  int M[12], N[12];
  int cnt, sum;
  int i;
  while(1) {
    sum = 0; cnt = 0;
    cin >> L;
    if(L == 0) break;

    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;
      //cout << sum << endl;
    }
    if(sum < L) cout << "NA" << endl;
    else cout << i + 1 << endl;
  }
  return 0;
}

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+2<<endl;
    else
      cout<<"NA"<<endl;
  }
}

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

int main(){
    int l;
    int chokin = 0;
    int tmp;
    int m;
    int n;
    bool flug = false;
    int month;

    while(cin >> l, l != 0){
        chokin = 0;
        flug = false;
        month = 0;
        for(int i=1; i<=12; i++){
            cin >> m >> n;
            if(flug == false){
                tmp = m - n;
                chokin += tmp;
                if(chokin >= l){
                    flug = true;
                    month = i;
                }
            }
        }
        if(flug == true){
            cout << month << endl;
        }else{
            cout << "NA" << endl;
        }
    }

    return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int l,c=0,t=0,m,n;
	while(1){
		scanf("%d",&l);
		if(l==0)break;
		for(int i=0;i<12;i++){
			scanf("%d %d",&m,&n);
			t+=m-n;
			c++;
			if(t>=l)c--;
		}
		if(t>=l)printf("%d\n",c+1);
		else
			printf("NA\n");
		t=c=0;
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(){

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

    int hantei = 0;
    int frag = 0;

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

    if(hantei == 0) cout << "NA" <<endl;
    else cout << hantei << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main(){
  int i ,j=0 ,n ,m ,L ,tmp[12] ,savings=0;
  while( scanf( "%d" ,&L ) != EOF ){  // 目標金額
    for( i=0 ; i<12 ; i++ ){
      tmp[i] = 0;
    }
    if( L == 0 ){
      break;
    }
    
    for( i=1 ; i<=12 ; i++ ){
      cin >> m >> n;       // 小遣い　使用金額
      savings = savings + ( m - n );
      if( savings >= L ){
	tmp[i] = 1;
      }
    }
    
    if( savings >= L ){
      for( i=0 ; i<12 ; i++ ){
	if( tmp[i] == 1 ){
	  cout << i << endl;
	  break;
	}
      }
    }
    
    else{
      cout << "NA" << endl;
    }
    savings = 0;
    j = 0;

  }

  return 0;
}

C++: // Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int L;
		cin >> L;

		if(L==0)
			break;

		int M[12], N[12];
		for(int i=0; i<12; i++){
			cin >> M[i] >> N[i];
		}

		int sum = 0;
		int ans = -1;
		for(int i=0; i<12; i++){
			sum += (M[i]-N[i]);

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

		if(ans!=-1){
			cout << ans << endl;
		}
		else{
			cout << "NA" << endl;
		}
	}

	return 0;
}

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

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

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

int main(void) {
	int L, M, N;

	while(cin >> L, L) {
		int sum = 0;
		bool flag = true;

		for(int i = 0; i < 12; i++) {
			cin >> M >> N;
			sum += M - N;

			if(sum > L && flag) {
				cout << i + 1 << endl;
				flag = false;
			}
		}

		if(flag)
			cout << "NA" << endl;
	}
}

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

int main(){
	while(1){
		int L, M, N, ans = 0;
		
		cin>>L;
		if(L == 0)
			break;

		for(int i=1;i<=12;i++){
			cin>>M>>N;
			L -= M-N;

			if((L <= 0) && (ans == 0))
				ans = i;
		}

		if(ans == 0)
			cout<<"NA"<<endl;
		else
			cout<<ans<<endl;
	}

	return 0;
}