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>
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>
using namespace std;

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

C++: #include <bits/stdc++.h>

using namespace std;

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

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

int l;
int m[12], n[12];

int main() {
	while (cin >> l, l) {
		REP(i, 12) scanf("%d %d", m + i, n + i);
		
		int ans = -1, sum = 0;
		REP(i, 12) {
			sum += m[i] - n[i];
			if (sum >= l) { ans = i + 1; break; }
		}
		
		if (ans == -1) puts("NA");
		else cout << ans << endl;
		
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
struct trip {
	bool b;
	int l;
	int mon;
};
int main() {
	int l;
	long m, n;
	int x;
	int y;
	trip z[1001];
	for (int j = 0; j < 1001; j++){
		z[j].b = false;
		z[j].l = 0;
	}
	for (int i = 0;; i++){
		cin >> l;
		if (l == 0){
			x = i;
			break;
		}
		else {
			for (int j = 0; j < 12; j++){
				cin >> m >> n;
				z[j].l += (int)(m - n);
				if (z[j].b = false && z[j].l >= l){
					z[j].mon = j;
					z[j].b = true;
				}
			}
		}
	}
	for (int i = 0; i < x; i++){
		if (z[i].b == false){
			cout << "NA\n";
		}
		else cout << z[i].mon << endl;
	}
}

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

C++: #include <cstdio>


int l, sum, m, n, j;
bool f;

int main(){
    while(scanf("%d", &l) != EOF){
        if(l == 0) break;
        sum = 0;
        f = false;
        for(int i = 0; i < 12; i++){
            scanf("%d %d", &m, &n);
            sum += m - n;

            if(sum >= l && !f){
                j = i + 1;
                f = true;
            }
        }

        if(!f) printf("NA\n");
        else printf("%d\n", j);
    }

    return 0;
}

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

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int l,m;
	m=0;
	string ans = "NA";
	cin >> l;
	if(l==0) break;
	vector<int> d(12);
	REP(i,12) {
	    int a,b;
	    cin >> a >> b;
	    d[i] = a-b;
	}
	REP(i,12){
	    m += d[i];
	    if(m >= l){
		ans = to_string(i+1);
		break;
	    }
	}
	cout << ans << endl;
    }
    return 0;
}

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

int main() {
	int a=0,m,n,l,cnt=1,b=0;
	while(1){
		cin>>l;
		if(l==0){
			break;
		}
		while(b<12){
			cin>>m>>n;
			a=m-n+a;
			if(a<l){
			   cnt++;
			}   
			b++;
		}
		if(cnt>0 && cnt<13){
			cout<<cnt<<endl;
		}
		else{cout<<"NA"<<endl;}
		cnt=1;
		a=0;
		b=0;
		
	}
	// your code goes here
	return 0;
}

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

int main()
{
  int l;
  int a;

  while (cin >> l && l != 0){
    int m, n;
    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;
  }
}

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

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

C++: #include <iostream>
using namespace std;
int main()
{
	int l;
	int m,n;
	int num=0;
	int a[12];

	while(true){

		cin >> l;

		if(l==0)
			break;

		for(int i=0 ;i<12 ;i++){
			cin >> m >> n;

			num = num+(m - n);
			a[i] = num;
		}
		for(int i=0 ;i<12 ;i++){
			
			if(a[i] >= l){
				cout << i+1 << endl;
				break;
			}
			else if(i==11){
				cout << "NA" << endl;
			}
		}
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
main(){
  int m,n,l,day,sum;
  while(1){
    cin>>l;
    if(l==0)break;
    day=0;
    sum=0;
    for(int i=0;i<12;i++){
      cin>>m>>n;
      if(day!=0)continue;
      sum+=m-n;
      if(sum>=l){
	day=i+1;
      }
    }
    if(day!=0){
      cout<<day<<endl;
    }
    else{
      cout<<"NA"<<endl;
    }
  }
}

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

int main() {
	// your code goes here
	int n,m,s,sum;
	while(cin >> n && n!=0){
		sum=0;
		int i;
		for(i=0;i<12;i++){
			cin >> m >> s;
			sum+=m-s;
			if(sum>=n){
				cout << i+1 << endl;
			break;
			}
		}
		for(i=i+1;i<12;i++)
		cin >> m >> s;
		if(sum<n)
		cout << "NA" << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {

  int l;
  int m,n;

  int saving;
  int success;


  while(cin >> l) {

    if(l==0) break;

    saving=0;
    success=0;

    for(int i=0;i<12;i++) {

      cin >> m >> n;

      saving+=m-n;

      if(saving>=l) {
	
	if(success==0) success=i+1;

      }

    }

    if(success>0) cout << success << endl;
    else cout << "NA" << endl;
    
  }

  return 0;

}