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<stdio.h>
int main(){
	int L,M,N,t=0,c=0,i;
	for(;;t=0,c=0){
		scanf("%d",&L);
		if(L==0)break;
		for(i=1;i<13;i++){
			scanf("%d%d", &M, &N);
			t+=M-N;
			if(t>=L&&c==0){
				c=i;
			}
		}
		if(c!=0)printf("%d\n",c);
		else puts("NA");
	}
	return 0;
}

C++: #include<stdio.h>
int main(void){
	while(1){
		int l,m,n,r=0,cnt=0;
		scanf("%d",&l);
		if(l==0)return 0;
		int i;
		for(i=0;i<12;i++){
			scanf("%d%d",&m,&n);
			r+=(m-n);
		    
			if(r>=l&&cnt==0)cnt=i+1;
		}
		if(cnt!=0)printf("%d\n",cnt);
		else printf("NA\n");
	}
	return 0;
}

C++: #include<iostream>

using namespace std;


int main(void)
{
	int M[12] = {0};
	int N[12] = {0};
	int L = 0;
	
	while (true)
	{
		int ans = 0;

		cin >> L;
		if (L == 0)	{	return 0; }


		int i = 0;

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

		for (int i = 0; i < 12; i++)
		{
			if (L <= 0)
			{
				break;
			}
			ans++;
			L = L + N[i] - M[i];
		}

		if (i == 12)
		{
			cout << "NA" << endl;
			continue;
		}

		cout << ans << endl;
	}

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

  return (0);
}

C++: #include <iostream>

using namespace std;

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

C++: #include <cstdio>
int main(){
	int l;
	while(scanf("%d", &l), l){
		int cm = -1;
		for(int i=1;i<=12;i++){
			int m, n;
			scanf("%d%d", &m, &n);
			l -= m - n;
			if(l <= 0 && cm < 0)
				cm = i;
		}
		if(cm<0)puts("NA");
		else printf("%d", cm);
	}
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int a;
	while(cin>>a,a){
		vector<int>sa(12);
		rep(i,12){
			int b,c;
			cin>>b>>c;
			sa[i]=b-c;
		}
		int sum=0;
		rep(i,12){
			sum+=sa[i];
			if(sum>=a){
				cout<<i+1<<endl;
				break;
			}
			if(i==11)cout<<"NA"<<endl;
		}
	}
}

C++: #include<iostream>
using namespace std;
int main(){
    int L;
    cin >> L;
    int t;
    t = 0;
    for(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 <iostream>
using namespace std;

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

  }
 
  return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
	
	int L,M,N,Rest;
	int month;
	bool flag;
	while(cin>>L,L!=0){
		Rest=0;
		flag=false;
		for(int i=1;i<=12;i++){
			cin>>M>>N;
			Rest=Rest+(M-N);
			if(Rest>=L){
				if(flag==false){
					month=i;
				}
				flag=true;
			}
		}
		if(flag){
			cout<<month<<endl;
		}else{
			cout<<"NA"<<endl;
		}
	}
	
}

C++: #include <bits/stdc++.h>
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 c = 0;
        bool flag = true;
        
        for (int i=0; i<12; i++) {
            c += M[i]-N[i];
            
            if (c>=L) {
                cout << i+1 << endl;
                flag = false;
                break;
            }
        }
        
        if (flag) {
            cout << "NA" << endl;
        }
    }
}

C++: #define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair<int,string> P;

static const double eps = 1e-8;

int main(){
	int L;
	while(~scanf("%d",&L)){
		if(L==0) break;
		int sum=0;
		int res=INF;
		for(int i=0;i<12;i++){
			int M,N;
			scanf("%d %d",&M,&N);
			sum += M-N;
			if(sum >= L){
				res = min(i+1,res);
			}
		}

		if(res==INF) printf("NA\n");
		else printf("%d\n",res);
	}
}

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

C++: #include<iostream>
using namespace std;
int main() {
	int a, ans,moku, b, tyokin;
	while (1) {
		cin >> moku;
		if (moku == 0) {
			goto a;
		}
		tyokin = 0;
		ans = 0;
		for (int i = 1; i <= 12; i++) {
			cin >> a >> b;
			tyokin += a - b;
			if (moku <= tyokin) {
				ans = i;
				tyokin = -99999999;
			}
		}
		if (ans == 0) {
			cout << "NA" << endl;
		}
		else {
			cout << ans << endl;
		}
	}
a:;
}

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;
		}
		if( ans ) cout << ans;
		else cout << "NA";
		puts("");
	}
	return 0;
}

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

int main()
{
  int l;

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