Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		val := 0
		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 && val == 0 {
				val = i+1
			}
		}
		if val == 0 {
			fmt.Println("NA")
		} else {
			fmt.Println(val)
		}
	}
}

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

C++: #include<iostream>
using namespace std;
int main() {
	int l;
	while (cin >> l&&l != 0) {
		int m = 0, n = 0, g=10000;
		bool h = false;
		for (int i = 0; i < 12; i++) {
			int a, b;
			cin >> a >> b;
			a -= b;
			m++;
			n += a;
			if (n >= l&&h == false) {
				g = m;h = true;
			}
		}
		if (g == 10000)
			cout << "NA" << endl;
		else {
			cout << g << endl;
		}
	}
}

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

int main(){
	int l;
	int mx,mxt;
	int now;
	int t,t1;
	while(cin >> l && l){
		int now=0,mxt=0;
		for(int i=1;i<=12;i++){
			cin >> t1 >> t;
			now += t1-t;
			if(now>=l && !mxt){
				mxt = i;
			}
		}
		if(mxt){
			cout << mxt << endl;
		}else{
			cout << "NA" << endl;
		}
	}
}

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

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

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<30;

int main() {
  int l;
  while(cin >> l) {
    bool f = 0;
    int a[13], b[13];
    REP(i,13) {
      cin >> a[i] >> b[i];
    }
    REP(i,12) {
      l -= a[i]-b[i];
      if (l <= 0) {
        cout << i+1 << endl;
        f = 1;
        break;
      }
    }
    if (!f) {
      cout << "NA" << endl;
    }
  }
}

C++: #include<iostream>

using namespace std;

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

C++: #include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>

using namespace std;

int main() {
	int l;
	while (true) {
		cin >> l;
		if (!l) break;
		int i;
		for (i = 0; i < 12; i++) {
			int a, b;
			cin >> a >> b;
			l -= a;
			l += b;
			if (l <= 0) {
				break;
			}
		}
		if (i == 12) {
			cout << "NA" << endl;
		} else {
			cout << i << endl;
		}
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  
  int L,M,N,money,month,cnt;
  
  while(1){

    cin >>L;

    if(L == 0)break;
    
    money=0;
    month=0;
    cnt=0;
    
    for(int i=0 ; i < 12 ; i++){
      cin >>M>>N;
      money+=M-N;
      if(money-L >= 0 && cnt == 0){
	month=i+1;
	cnt++;
      }
    }
    
    if(month == 0){
      cout <<"NA"<<endl;
    }else{
      cout <<month<<endl;
    }

  }

  return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int w,n,z[100000],x[100000],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[i],&x[i]);
	}
	for(i=0;i<12;i++){
			k+=z[i]-x[i];
//			printf("%d\n",k);
			c++;	
		if(k>n) break;
	}	
	if(c==0||c>=12){
		printf("NA\n");
	}
	else{
		printf("%d\n",c);
	}
   }
	return	0;
}

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

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


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

C++: #include<cstdio>
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
#include<stack>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii; 
typedef long long ll ;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

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

}

C++: #include<stdio.h>

int main(void){
	int L,M,N,k[12],i,kai;

	while(scanf("%d\n",&L)!=EOF){

		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 shotoku[12];
	int l,m,n;
	int i,total;
	cin>>l;
	for(i=0;i<12;i++){
		cin>>m>>n;
		shotoku[i]=m-n;
	}
	total=0;
	for(i=0;i<12;i++){
		total+=shotoku[i];
		if(l<=total){
			cout<<i+1;
			break;
		}
	}
	if(i==13) cout<<"NA";
	cout<<endl;
	return 0;
}

C++: #include<iostream>

using namespace std;

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

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

int main(int argc, char *argv[]){
  int l, m, n;
  while(std::cin >> l, l){
    int sum = 0, ans = 1e9;
    for (int i = 0; i < 12; i++) {
      std::cin >> m >> n;
      sum += m - n;
      if(sum >= l && ans == 1e9)ans = i + 1;
    }
    if(ans == 1e9) std::cout << "NA" << std::endl;
    else std::cout << ans << std::endl;
  }
  return 0;
}