Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
Here:
	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 Here
			}
		}
		fmt.Println("NA")
	}
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

ll l, m, n, sum;
int f = 0;

int main(){
	while (cin >> l&&l){
		f = 0;
		sum = 0;
		REP(i, 12){
			cin >> m >> n;
			sum += m - n;
			if (f == 0){
				if (sum >= l)f = i + 1;
			}
		}
		if (f == 0)cout << "NA\n";
		else cout << f << endl;
	}
}

C++: #include<stdio.h>
int main(void)
{
	int w,n,z,x,i,k,c;
	while(1){
	c=0;
	k=0;
		scanf("%d",&n);
		 if(n==0) break;
	for(i=0;i<12;i++){
			scanf("%d %d",&z,&x);
			k+=z-x;	
			c++;
		if(k>n){
		i=10000;
		}
	}	
	if(c==0||c>=12){
		printf("NA\n");
	}
	else{
		printf("%d\n",c);
	}
   }
	return	0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

using namespace std;

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

C++: #include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define MP make_pair
int main(){
  int l,m,n;
  while(cin>>l&&l){
    int stack=0,ans=-1;
    for(int i=0;i<12;i++){
      cin>>m>>n;
      stack+=(m-n);
      if(stack>=l&&ans==-1)ans=i+1;
    }
    if(ans!=-1)cout<<ans<<endl;
    else cout<<"NA"<<endl;
  }
}

C++: #include <iostream>

using namespace std;

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

C++: #include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

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

        int cnt =0;
        bool flag = false;
        rep(i,12){
            int a, b;
            cin >>a >> b;
            if(flag) continue;
            cnt += a-b;
            if(cnt >= l){
                cout << i+1 << endl;
                flag = true;
            }
        }
        
        if(cnt<l) cout << "NA" << endl;
    }
    return 0;
}

C++: #include<stdio.h>

int main(void){
	int L,M,N,k,i;
	while(scanf("%d",&L)!=EOF){
		k=0;
		for(i=1;i<13;i++){
		  scanf("%d %d",&M,&N);
		  L-=M-N;
		  if(L<=0){ 
			  k=i;
			  L=1000000000;
		  }
		}
      if(k==0) printf("NA\n");
	  else printf("%d\n",k);
	}
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <utility>
#include <set>
#include <cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define all(v) v.begin(),v.end()
#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))
using namespace std;
typedef pair<int,int> point;
typedef complex<double> P;
typedef long long ll;

const double eps = 1e-8;
const double INF = 1e12;


double dot(P a,P b){
	return a.real()*b.real()+a.imag()*b.imag();
}
double cross(P a,P b){
	return a.real()*b.imag()-a.imag()*b.real();
}

bool is_orthogonal(P a1,P a2,P b1,P b2){
	return EQ(dot(a1-a2,b1-b2),0.0);
}
bool is_parallel(P a1,P a2,P b1,P b2){
	return EQ(cross(a1-a2,b1-b2),0.0);
}

bool is_point_on_line(P a,P b,P c){
	return EQ(cross(b-a,c-a),0.0);
}

bool is_point_on_linesegment3(P a,P b,P c){
	return (abs(a-c)+abs(c-b)<abs(a-b)+EPS);
}

double distance_l_p(P a,P b,P c){
	return abs(cross(b-a,c-a))/abs(b-a);
}


double distance_ls_p(P a,P b,P c){
	if(dot(b-a,c-a)<EPS)return abs(c-a);
	if(dot(a-b,c-b)<EPS)return abs(c-b);
	return abs(cross(b-a,c-a))/abs(b-a);
}

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

C++: #include<iostream>
using namespace std;
int main()
{
	long 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>
#include <cstdio>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <sstream>

#define mp make_pair
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define ll long long

using namespace std;

int main(){
	int l;
	while( cin >> l , l)
	{
		int money=0 , i , ans=0;
		for( i = 0; i<12; i++)  
		{
			int n , m;
			cin >> m >> n;
			money += m-n;
			if( l < money ) {
				ans = i+1;
				l = INT_MAX;
			}
		}
		if( ans ) cout << ans;
		else cout << "NA";
		puts("");
	}
	return 0;
}

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

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

C++: #include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

int L;
int up[12];

void solve(){
  int now = 0;

  rep(i,12){
    now += up[i];
    if(now >= L){
      cout<<i+1<<endl;
      return;
    }
  }
  cout<<"NA\n";
}

int main(){
  while(cin>>L,L){
    rep(i,12){
      int n,m;
      cin>>n>>m;
      up[i] = n - m;
    }
    solve();
  }
}

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

int main(){
	long long int price,a,b,n,month;
	bool judge;
	while(cin >> n && n){
		price = 0;
		judge = false;
		for(int i = 0;i< 12 ;i++){
			cin >> a >> b;
			price += (a-b);
			if(price > n && judge == false) {
				month = i + 1;
				judge = true;
			}
		}
		if(judge == true) cout << month << endl;
		else cout << "NA" << endl;
	}
	return 0;
}