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(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<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){
  int L;
  while(cin>>L,L){
    bool ans = false;
    int sum = 0 ;
    for(int i = 0 ; i < 12 ; i ++){
      int 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<bits/stdc++.h>
using namespace std;
int a,b,c,d,y,t,f;
int main(){
    while(1){
        f=0;
        t=0;
        d=0;
        cin>>a;
        if(a==0)return 0;
        for(y=1;y<13;y++){
            cin>>b>>c;
            d+=b-c;
            if(y==12&&d<a){t=13;}
            if(d>=a&&f==0){t=y;f++;}
        }
        if(t==13){cout<<"NA"<<endl;}else
                 {cout<<t<<endl; }
    }




}

C++: #include<iostream>
int main(){
	while(1){
		int a;
		std::cin>>a;
		if(a==0)break;
		int b,c=0,d;
		for(int i=1;i<13;i++){
			int n,m;
			std::cin>>n>>m;
			b+=n;
			b-=m;
			if(a>=b&&c==0)d=i,c=1;
		}
		if(c==0)std::cout<<"NA"<<std::endl;
		else std::cout<<d<<std::endl;
	}
	return 0;
}

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

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

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

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

int main(void)
{
  int L,m,n;
  while(1){
    int a =0;
    int q =0;
    cin >> L ;
    if(L == 0) break;
    else{
      for(int i =1  ; i <= 12;++i){
        cin >> m >> n;
        a += m-n;
        if(a >= L) ++q;
      }
      if(a < L) cout << "NA" << endl;
      else if(a >= L) cout << 12-q+1 << endl;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define alint(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	while(1){
		int l,sum=0,ans=0;
		cin>>l;
		if(l==0) break;
		vi m(12),n(12);
		rep(i,0,12){
			cin>>m[i]>>n[i];
		}
		rep(i,0,12){
			sum+=m[i]-n[i];
			if(sum>=l){
				ans=i+1;
				break;
			}
		}
		if(ans==0) o("NA");
		else o(ans);
	}
}

C++: #include<iostream>

using namespace std;

int main() {
  int n,m,nn,mm,x,p;
  while(cin >> x){
    if(x==0){break;}
  p=0;
  for(int i =0;i<12;i++){
    cin >>n>>m;
    nn += n;
    mm += m;
    if (nn-mm>=x){
      p = i+1;
    }
  }
  if(p==0){cout << "NA" << endl;}else{cout << p << endl;}
  }
  return 0;
}

C++: #include <algorithm>
#include <iostream>
#include <set>

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int L;
int N[12], M[12];
void solve() {
    int sum = 0;
    int ans = -1;
    rep(i, 12) {
        sum += M[i] - N[i];
        if (L <= sum) {
            ans = i;
            break;
        }
    }
    if (ans == -1)
        cout << "NA" << endl;
    else
        cout << ans + 1 << endl;
}
int main() {
    while (cin >> L, L) {
        rep(i, 12) cin >> M[i] >> N[i];
        solve();
    }
}

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

int main()
{
  int L, M, N;
  
  while (scanf("%d", &L), L){
    int sum = 0, reach;
    bool check = true;
    for (int i = 0; i < 12; i++){
      scanf("%d%d", &M, &N);
      sum += M - N;
      if (check && sum >= L){
        reach = i + 1;
        check = false;
      }
    }
    if (!check){
      printf("%d\n", reach);
    }
    else {
      printf("NA\n");
    }
  }

  return (0);
}

C++: #include <iostream>
using namespace std;
int hoge(int *L){ cin >> *L; return *L;}
int main(){
	int L,M,N;
	while(hoge(&L)){
		int j=1;
		for(int i=0;i<12;i++){
			cin >> M >> N;
			L -= M-N;
			if(L>=0) j++;
		}
		if(L>0) cout << "NA" << endl;
		else cout <<  j << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int M,N,L;

	while(1)
	{
		int sum = 0;
		int count = 0;
		int ans;
		cin >> L;

		if(L == 0)
		{
			break;
		}

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

			cin >> M >> N ;

			sum += M - N;

			if(sum >= L && count < 1)
				{
					count++;
					ans = i;
				}
		}

		if(sum >= L && count < 2)
				{
					cout << ans << endl;
				}	
		else
		{
			cout << "NA" << endl;
		}
	}


	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
	int m,n,l,f,sum;
	while(cin>>l){
	if(l==0)break;
	f=1;
	sum=0;
	while(cin>>m>>n){
	if(f>=13){
	cout<<"NA"<<endl;
	break;
	}
	sum+=m-n;
	if(l<=sum)cout<<f<<endl;
	f++;
	}
}
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
    for(;;){
	int l;
	int m[12];
	int n[12];
	int c=0;
	int ans=0;
	cin>>l;
	if(l==0)break;
	for(int i=0;i<12;i++){
        cin>>m[i]>>n[i];
	}
	for(int i=0;i<12;i++){
        c+=m[i]-n[i];
        if(c>=l){
            ans=i+1;
            break;
        }
	}
	if(ans==0)cout<<"NA"<<endl;
	else cout<<ans<<endl;

    }
	return 0;
}