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)
				break
			}
		}
		fmt.Println("NA")
	}
}

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

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

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

int main(){
	int s;
	while(scanf("%d", &s), s){
		int x, y;
		int ans = -1;
		for(int i = 1; i <= 12; ++i){
			scanf("%d%d", &x, &y);
			s -= x - y;
			if(s <= 0 && ans == -1){
				ans = i;
			}
		}
		printf(ans == -1 ? "NA\n" : "%d\n", ans);
	}
}

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;
        }
        else if (t<L){
             if (i==11){
        cout << "NA" << endl;
        }
    }
    }
    return 0;
    }

C++: #include<iostream>
using namespace std;
int main()
{
	int L, M, N, sum, i, k;
	while(1)
	{	
		cin >> L;
		if ( L == 0 )break;
		else
		{
			k = 0;
			sum = 0;
			for ( i = 0; i < 12; i++ )
			{
				cin >> M >> N;
				sum = (sum + (M - N));
				if ( sum <= L )k++;
			}
			k = k + 1;
			if ( sum < L )cout << "NA" << endl;
			else cout << k << 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 = 1; i < 13; i++ )
			{
				cin >> M >> N;
				sum = sum + (M - N);
				if ( sum <= L )k++;
			}
			if ( sum < L )cout << "NA" << endl;
			else cout << k << endl;
		}
	}	
	return 0;
}

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

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

using namespace std;

int main()
{
	int l;

	while(cin >> l && l)
	{
		bool flag = false;
		int t,t2;
		vector<int> v;
			
		rep(i,12)
		{
			cin >> t >> t2;
			v.push_back(t-t2);
		}

		rep(i,12)
		{
			l -= v[i];
			if(l <= 0)
			{
				flag = true;
				cout << i+1 << endl;
				break;
			}
		}

		if(flag)
		{
			cout << "NA" << endl;
		}
	}
	return 0;
}