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 <vector>

using namespace std;

void solve()
{
	int price;
	while(cin >> price, price)
	{
		vector<int> Vec;
		for(int i = 0; i < 12; ++i)
		{
			int in, out;
			cin >> in >> out;
			Vec.push_back(in - out);
		}
		bool endFlag = false;
		int sum = 0;
		for(int i = 0; i < 12; ++i)
		{
			sum += Vec[i];
			if(sum >= price)
			{
				cout << i + 1 << endl;
				endFlag = true;
				break;
			}
		}
		if(!endFlag)
		{
			cout << "NA" << endl;			
		}
	}
}

int main()
{
	solve();
	return(0);
}

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

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

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

C++: #include<stdio.h>

int main(){
	int l,m,n,i,j;
	while(0<=scanf("%d",&l)){
		if(l==0) break;
		j=0;
		for(i=0;i<12;i++){
			scanf("%d%d",&m,&n);
			l-=(m-n);
			if(j==0)			if(l<=0) j=i;
		}
		
		if(j!=0){
			printf("%d\n",j+1);
			continue;
		}
		
		printf("NA\n");
	}
	return 0;
}

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

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

C++: #include<iostream>
#define N 12

using namespace std;

int main () {

  int L;
  int m,n;
  int mon;
  bool skip;

  while ( true ) {
    cin >> L;
    if ( L == 0 )
      break;
    //sum = L;
    skip = false;
    for ( int i=0; i<N; i++ ) {
      cin >> m >> n;
      L -= m-n;
      if ( L <= 0 && !skip ) {
	skip = true;
	mon = i+1;
      }
      
    }

    if ( skip )
      cout << mon;
    else
      cout << "NA\n";
   }

}

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

int main(void){
  int l=0;
  int m[12];
  int n[12];
  cin >> l;
  while(l!=0){
    int sum=0;
    int mon=0;
    for(int i=0;i<12;i++){
      cin >> m[i] >> n[i];
      sum += (m[i] - n[i]);
      if(sum > l and mon==0){
	mon = i+1;
      }
    }
    if(mon==0){
      cout << "NA" << endl;
    }else{
      cout << mon << endl;
    }
    cin >> l;
  }
  return 0;
}

C++: #include<iostream>

int l, m, n, money = 0, month;

int main(){
	while(true){
		std::cin >> l;
		if(!l)
			return 0;
		for(int i=0; i<12; i++){
			std::cin >> m >> n;
			money += m-n;
			if(money >= l && !month)
				month = i+1;
		}
		if(!month)
			std::cout << "NA" << std::endl;
		else
			std::cout << month << std::endl;
		money = 0;
		month = 0;
	}
}

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

int main(void){
  int l,m,n;
  
  for(;;){
    
    int flg = 0,cnt = 0;    
    
  con:
    
    cin >> l;
    if( l == 0 ) break;
    
    for( int i = 0 ; i < 12 ; i++ ){
      cin >> m >> n;
      l = l - ( m - n );
      if( flg == 0 ){
	cnt++;
	if( l <= 0 ) flg = 1;
	
	if( cnt == 12 ){
	  cout << "NA" << endl;
	goto con;
	}
      }
      
    }
    
    cout << cnt << endl;
    
  }
  
  return 0;
}

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

int main()
{
    int l, m, n;

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

    return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count etc.
#include <cstdlib>	// require abs
#include <cstdio>	// require printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require sqrt ceil floor
#include <climits>	// require INT_MAX etc
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <stdint.h>	// require uint64_t
#include <fstream>	// require freopen

using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.nexttrip", "r", stdin );
	string str = "";
	while (getline (cin, str ) && str != "0" ){
		int l;
		stringstream ssl (str );
		ssl >> l;
		int sum = 0;
		int res = -1;
		bool found = false;
		for (int i = 0; i < 12; ++i ){
			int n, m;
			getline (cin, str );
			stringstream ss (str );
			ss >> n >> m;
			sum += (n - m );
			if (sum >= l && !found ){
				res = i+1;
				found = true;
			} // end if
		} // end for
		if (res != -1 ){
			cout << res << endl;
		}else{
			cout << "NA" << endl;
		} // end if
	} // end loop
		
	return 0;
}

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

int main() {
	while (1) {
		int a;
		cin >> a;
		if (a == 0)break;
		vector<int>s(12);
		for (int b = 0; b < 12; b++) {
			int c, d;
			cin >> c >> d;
			s[b] = c - d;
			if (a <= 0) {
				cout << b + 1 << endl; break;
			}
		}
		for (int f = 0; f < 12; f++) {
			a -= s[f];
			if (a <= 0) { cout << f + 1 << endl; break; }
			if (f == 11) { cout << "NA" << endl; break; }
		}
	}
}

C++: #define _USE_MATH_DEFINES
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
#include<climits>
#include<map>
#include<string>
using namespace std;

int main(){
	int L, M, N;
	while(cin >> L, L){
		int sum = 0, ans = -1;
		for(int i = 1; i <= 12; i++){
			cin >> M >> N;
			sum += M - N;
			if(sum >= L && ans == -1) ans = i;
		}
		printf("\t");
		if(ans == -1) puts("NA");
		else printf("%d\n", ans);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int sum, n, a, b, ok;
int main() {
	while (true) {
		sum = 0;
		ok = 0;
		cin >> n;
		if (n == 0) { break; }
		for (int i = 0; i < 12; i++) {
			cin >> a >> b;
			sum += a - b;
			if (sum >= n && ok == 0) { cout << i << endl; ok = 1; }
		}
		if (ok == 0) { cout << "NA" << endl; }
	}
}

C++: #include <cstdio>

using namespace std;

int main(){
	while(true){
		int L;
		scanf("%d", &L);
		if(L == 0){ break; }
		int answer = 0, sum = 0;
		for(int i = 1; i <= 12; i++){
			int M, N;
			scanf("%d%d", &M, &N);
			sum += (M - N);
			if(answer == 0 && sum >= L){ answer = i; }
		}
		if(answer == 0){
			puts("NA");
		}else{
			printf("%d\n", answer);
		}
	}
	return 0;
}