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>
#include <cstdio>
using namespace std;
int main(){
  int i ,j=0 ,n ,m ,L ,tmp[13] ,savings=0;
  while( 1 ){  // 目標金額
    cin >> L;
    if( L == 0 ){
      break;
    }
    for( i=0 ; i<12 ; i++ ){
      tmp[i] = 0;
    }
    if( L == 0 ){
      break;
    }
    
    for( i=1 ; i<=12 ; i++ ){
      cin >> m >> n;       // 小遣い　使用金額
      savings = savings + ( m - n );
      if( savings > L && j == 0 ){
	tmp[0] = i;
	j++;
      }
    }
    
    if( savings >= L ){
      cout << tmp[0] << endl;
    }

    else{
      cout << "NA" << endl;
    }
    j=0;
  }

  return 0;
}

C++: #include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

int main() {
  while( 1 ) {
    int l;
    cin >> l;
    if( !l ) { return EXIT_SUCCESS; }
    
    int mth = -1;
    for( int i = 1; i <= 12; i++ ) {
      int m, n;
      cin >> m >> n;
      l -= ( m - n );
      if( mth == -1 && l < 0 ) { mth = i; }
    }
    cout << ( mth == -1 ? "NA" : to_string( mth ) ) << endl;
  }
}

C++: #include <iostream>
using namespace std;
int main( void )
{
	int L;
	while ( cin >> L && L )
	{
		int kotae = 0;
		int now = 0;
		int M, N;
		for ( int i = 0; i < 12; i++ )
		{
			cin >> M >> N;

			now += M - N;
			if ( kotae == 0 && now >= L )
			{
				kotae = i + 1;
			}
		}

		if ( kotae )
			cout << kotae << endl;
		else
			cout << "NA" << endl;
	}

	return 0;
}

C++: #include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
using namespace std;
typedef long long  ll;

/** Problem0206 : Next Trip **/
int main()
{
	int L, a, b, sum, ans;
	while (cin>>L, L!=0) {
		ans=0; sum=0;
		rep(i, 12) {
			cin >> a >> b;
			sum+=a-b;
			
			if (ans>0) continue;
			
			if (sum>=L) {
				ans = i+1;
			}
		}
		if (ans>0)
			cout << ans << endl;
		else
			cout << "NA" << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
  
// #define int long long
#define pb push_back
  
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
 
template <class X> void print(X Target){ cout << Target << '\n'; }

signed main()
{
  ios::sync_with_stdio(false);
  int L;
  
  while (cin >> L, L){
    int sum = 0, ans = 0;
    for (int i = 0; i < 12; i++){
      int M, N;
      cin >> M >> N;
      sum += M - N;
      if (!ans && sum >= L){
        ans = i + 1;
      }
    }
    if (ans){
      print(ans);
    }
    else {
      print("NA");
    }
  }

  return (0);
}

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

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

int l;

void solve() {
  int tl = 0; bool flag = false;
  rep(i,12) {
    int m, n; cin>>m>>n;
    if (flag) continue;
    tl += (m-n);
    if (tl >= l) {
      cout<<i+1<<endl;
      flag = true;
    }
  }
  if (flag) return;
  cout<<"NA"<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>l, l) {
    solve();
  }
  return 0;
}

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 (i = 0; i < 12; i++)
		{
			if (L <= 0)
			{
				break;
			}
			ans++;
			L = L + N[i] - M[i];
		}

		if (i == 12 && L > 0)
		{
			cout << "NA" << endl;
			continue;
		}

		cout << ans << endl;
	}

	return 0;
}

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

C++: #include <cstdio>

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

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

using namespace std;

int main(){

	int L,M,N;
	while(cin>>L&&L!=0){
		int ac=-1;
		int sum=0;
		bool f=false;
		for(int i = 0; i < 12; i++){
			int a,b;
			cin>>a>>b;
			sum+=a-b;
			if(sum>=L&&!f){
				ac=i;
				f=true;
			}
		}
		if(ac!=-1)
			cout<<ac+1<<endl;
		else
			cout<<"NA"<<endl;
	}
	return 0;
}

C++: #include<stdio.h>
int main(void){
	while(1){
		int l,m,n,r=0,cnt=0;
		scanf("%d",&l);
		if(l==0)return 0;
		int i;
		for(i=0;i<12;i++){
			scanf("%d%d",&m,&n);
			r+=(m-n);
		
			if(r>=l)cnt=i+1;break;
		}
		if(cnt!=0)printf("%d\n",cnt);
		else printf("NA\n");
	}
	
	
}

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

int main() {
	int L;
	int i,kozu[12],use[12],sum=0,fl=0,mon;
	while(1){
		cin >> L;
		if(L==0) break;
		for(i=0;i<12;i++){
			cin >> kozu[i] >> use[i];
			sum+=kozu[i]-use[i];
			if(sum>=L && fl==0){
				mon=i+1;
				fl=1;
			}
		}
		if(fl==1){
			cout << mon << endl;
		}else{
			cout << "NA" << endl;
		}
		sum=0;
		fl=0;
	}
	return 0;
}

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

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

using namespace std;

int main()
{
    int L, M, N;
    while (cin >> L, L) {
        int sum = 0, j = -1;
        for (int i = 0; i < 12; i++) {
            cin >> M >> N;
            sum += (M - N);
            if (j == -1 && sum >= L) {
                j = i;
            }           
        }
        if (j >= 0) {
            cout << j+1 << 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>
using namespace std;

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

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

using namespace std;

int main()
{
  int n;
  while (scanf("%d ", &n) == 1) {
    if (n == 0) {
      break;
    }
    for (int i = 1; i <= 12; i++) {
      int a, b;
      scanf("%d %d ", &a, &b);
      n -= a - b;
      if (n <= 0) {
	cout << i << endl;
	goto next;
      }
    }
        cout << "NA" << endl;
  next:;
  }
  return 0;
}