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 l, m, n;
int main() {
	while (true) {
		scanf("%d", &l);
		if (l == 0) break;
		bool flag = false;
		for (int i = 0; i < 12; i++) {
			scanf("%d%d", &m, &n);
			l -= (m - n);
			if (l < 0 && !flag) {
				printf("%d\n", i + 1);
			}
		}
		if (!flag) {
			printf("NA\n");
		}
	}
	return 0;
}

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

C++: #include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int l;

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

C++: #include<iostream>

using namespace std;

int main(){
  int L, Gain[12], Consume[12], i, saving, month;
  while(cin >> L, L){
    for(i=0; i<12; i++){
      cin >> Gain[i] >> Consume[i];
    }
    saving = 0;
    month=0;
    while(saving < L){
      saving += Gain[month] - Consume[month];
      month+=1;
    }
    cout << month << endl;
  }
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef pair<double,double> P;
typedef complex<double> CP;
typedef long long ll;

ll L,N,M;

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

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

int main()
{
  int L;
  while (cin >> L && L != 0) {
    vector<int> ds(12);
    for (int i = 0; i < 12; i++) {
      int M, N;
      cin >> M >> N;
      ds[i] = M-N;
    }

    int s = 0;
    int ans = 0;
    for (int i = 0; i < 12; i++) {
      s += ds[i];
      if (s >= L) {
        ans = i+1;
        break;
      }
    }
    if (ans == 0) {
      cout << "NA" << endl;
    } else {
      cout << ans << 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 l;
	while(1){
		cin >> l;
		if(l==0)break;
		int ans=-1;
		int mn=0;
		for(int i=1;i<=12;i++){
			int m,n;
			cin >> m >> n;
			mn+=m-n;
			if(ans==-1 && mn>=l)ans=i;
		}
		if(ans>=0)cout << ans << endl;
		else cout << "NA" << endl;
	}
    return 0;
}

C++: #include<iostream>
#include<cmath>
#include<cstdio>

using namespace std;

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

  return 0;
}

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;
  bool flag = true;
  
  while (scanf("%d", &l), l != 0){
    REP(0, 12){
      scanf("%d%d", &m, &n);
      sum += m - n;
      if (sum < l && flag) month++;
      else flag = false;
    }
  
    if (month <= 12) printf("%d\n", month);
    else printf("NA\n");
  }

  return (0);
}

C++: #include<iostream>
using namespace std;
int main(){
    int L;
    while(cin >> L){
    int t;
    t = 0;
    for(int i=0;i<12;++i){
        int Plus;
        int Minus;
        cin >> Plus >> Minus;
        t += Plus - Minus;
        if (t>=L){
            cout << i+1 << endl;
            break;
        }
        else if (t<L){
             if (i==11){
        cout << "NA" << endl;
        }
    }
    }
    }
    return 0;
    }

C++: #include <cstdio>
#include <vector>

using namespace std;

int main(){
	int self;
	int l,m,n;
	int c;
	bool flag;
	while(1){
		scanf("%d",&l);
		if(l == 0){break;}
		c = 0;
		flag = false;
		for(int i = 0;i < 12; i++){
			scanf("%d %d",&m,&n);
			c += m - n;
			if(!flag && c > l){
				printf("%d\n",i+1);
				flag = true;
			}
		}
		if(!flag){
			printf("NA\n");
		}
	}
	return 0;
}

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

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

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

#define REP(i,n) for(int i=0;i<(int)(n);++i)

int main() {
  for (;;) {
      int L; cin >> L; if (L == 0) break;
      int ans = -1;
      int have = 0;
      REP(step, 12) {
          int a, b; cin >> a >> b;

          have += a;
          have -= b;
          if (have >= L && ans == -1) {
              ans = step + 1;
          }
      }
      if (ans == -1) cout << "NA" << endl;
      else cout << ans << endl;
  }
  return 0;
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	while (1) {

		int L; cin >> L;
		if (!L)break;
		int ans = 22;
		for (int i = 0; i < 12; ++i) {
			int M, N; cin >> M >> N;
			L -= (M - N);
			if (L <= 0) {
				ans = min(ans,i + 1);
			}

		}
		if (ans != 22) {
			cout << ans << endl;
		}
		else {
			cout << "NA" << endl;
		}
	}
	return 0;
}