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 <vector>
#include <algorithm>
#include <iostream>

using namespace std;

const int MAX_M = 12;

int main() {
	while (true) {
		int L, M, N;
		int info[MAX_M] = {0};

		int temp = 0;

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

		for (int i = 0; i < 12; i++) {
			temp += info[i];
			
			if (temp > L) {
				cout << i+1 << endl;
				break;
			}
		}
		
		if (temp < L) {
			cout << "NA" << endl;
		}
	}
	
	return 0;
}

C++: #include<iostream>

using namespace std;

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

C++: #include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

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

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 27;
const double EPS = 1e-10;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)

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

C++: #include<iostream>
using namespace std;
int main(){
  
  int i,l,a,b,m[15],sum;
  
  while(cin >> l,l!=0){
    for(i=0;i<12;i++){
      cin >> a >> b;
      m[i] = a-b;
    }
    m[13] = l;
    
    sum = 0;
    for(i=0;i<=12;i++){
      sum += m[i];
      if(sum >= l){
	if(i == 12) cout << "NA" << endl;
	else cout << i+1 << endl;
	break;
      }
    }
  }
  return(0);
}

C++: #include<stdio.h>
int main(){
	int a;
	while(scanf("%d",&a),a){
		int val=0;
		for(int i=0;i<12;i++){
			int b,c;
			scanf("%d%d",&b,&c);
			a-=(b-c);
			if(a<=0&&val==0){
				val=i+1;
			}
		}
		if(val==0)printf("NA\n");
		else printf("%d\n",val);
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
main() {
	int L, M, N;
	while( cin >> L && L ) {
		int t = 0, S = 0;
		for ( int i = 1; i <= 12; i++ ) {
			cin >> M >> N;
			S += M - N;
			if ( S >= L && t == 0 ) t = i;
		}
		if ( S < L ) cout << "NA" << endl;
		else cout << t << endl;
	}
}

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

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    while (cin >> N , N) {
        vector<int> v(12);
        for (auto& i : v) {
            int x, y;
            cin >> x >> y;
            i = x - y;
        }

        int sum = 0;
        for (int i = 0; i < 12; i++) {
            sum += v[i];
            if (sum >= N) {
                cout << i + 1 << endl;
                break;
            }

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

    return 0;
}

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


int main(){

  int l;
  while(1){
    cin >> l;
    if(l == 0)break;
    int sum=0;
    bool f = true;
    for(int i=0;i<12;i++){
      int m,n;
      cin >> m >> n;
      sum += (m-n);
      if(l <= sum && f){
	cout << i+1 << "\n";
	f = false;
      }
    }
    if(l>sum)
      cout << "NA\n";
  }
}

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

  while(cin >> n, n){
    int x,y,ans = 0,t = 0;

    for(int i=0;i<12;i++){
      cin >> x >> y;

      ans += (x - y);

      if(ans >= n && t == 0){
	cout << i+1 << endl;
	t = 1;
      }
    }

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

C++: #include "bits/stdc++.h"
using namespace std;


int main(){
	while(1){
	int a,flag =0,g = 0;
	cin >> a;
	int b = 0;
	for(int i=1;i <=12;i++){
		int c,d;
		cin >>c >> d;
		b = b +c -d;
		if(b >= a){
			if(flag == 0){
			g = i;
			flag = 1;
			}
		}
		if(i == 12)break;
	}
	if(flag == 1) cout << g << endl;
		if(flag == 0)cout << "NA" << endl;
	

	}


		return 0;

}

C++: #include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>

using namespace std;

int main(void){
	int ans,h;
	int n,m;
	int l;
	int a;
	while(1){
		ans=0;
		h=0;
		cin >> l;
		if(l==0)break;
		for(a=1;a<=12;a++){
			cin >> n >> m;
			if(n>m)ans+=n-m;
			if(ans>=l && h==0)h=a;
		}
		if(h!=0)cout << h << endl;
		else cout << "NA" << endl;
	}
	return 0;
}

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

int main()
{
	int l;

	cin >> l;

	while (l) {
		int t = 0, r = -1;

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

			t += m - n;

			if (t >= l && r < 0)
				r = i + 1;
		}

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

		cin >> l;
	}

	return 0;
}

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

int main(){
	int L, mon[12][2], sav, i;
	
	while(1){
		sav = 0;
		cin >> L;
		if(L == 0)
			return 0;
		for(i = 0; i < 12; i++){
			cin >> mon[i][0] >> mon[i][1];
		}
		
		for(i = 0; i < 12; i++){
			sav += mon[i][0]-mon[i][1];
			if(sav >= L){
				cout << i+1 << endl;
				break;
			}
		}
		
		if(sav < L)
			cout << "NA" << endl;
	}
}