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

Python: def jug(l,income):
    assert len(income)==12, "income strange"
    s = 0 
    for i in range(len(income)):
        inc = income[i]
        s += inc[0] - inc[1]
        if s >= l:
            return(str(i+1))
    return("NA")

while True:
    income=[]
    l=int(input())
    if l==0:
        break
    for i in range(12):
        m,n = list(map(int,input().strip().split()))
        income.append((m,n))
    print(jug(l,income))

Python: while 1:
    l = int(input())
    if l == 0:
        break;
    s = 0
    for i in range(1,13):
        m, n = [int(_) for _ in input().split()]
        l -= m - n
        if s == 0 and l <= 0:
            s = i
    print(s) if s != 0 else print('NA')

Python: while 1:
    l = int(input())
    if l == 0:
        break

    money = []
    for _ in range(12):
        m, n = map(int, input().split())
        money.append(m-n)

    total = 0
    for i, p in enumerate(money):
        total += p
        if total >= l:
            print(i+1)
            break
    else:
        print("NA")

C++: #include<stdio.h>
int main(void)
{
	int w,n,z[12],x[12],i,k,c;
	while(1){
		scanf("%d",&n);
		 if(n==0) break;
	c=0;
	k=0;	 
	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++: // AOJ0206.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include <iostream>

using namespace std;


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

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

int main(void){
  int L;
  while(true){
    cin>>L;
    if(L==0){break;}
    int money=0;
    int retval=NA;
    int M,N;
    for(int month=1;month<=12;month++){
      cin>>M>>N;
      money+=M-N;
      if(money>=L){
        retval=min(retval,month);
      }
    }
    if(retval==NA){
      cout<<"NA"<<endl;
    }
    else{
      cout<<retval<<endl;
    }
  }
  return 0;
}

C++: # define _CRT_SECURE_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <unordered_set>
# include <unordered_map>
# include <climits>
# include <complex>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define STR(x) string x;cin>>x;
# define ALL(x) begin(x),end(x)
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl;
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }



int main()
{
	while (true)
	{
		INT(L); if (L == 0)break;
		vi a;
		FOR(i, 12)
		{
			INT(x); INT(y);
			a.push_back(x-y);
		}
		FOR(i, 12)
		{
			L -= a[i];
			if (L <= 0){
				cout << i + 1 << endl; break;
			}
			if (i == 12 - 1)cout << "NA" << endl;
		}
	}
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int l,m,n;

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

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

int main(){
	int L;
	int M[12],N[12];

	while( cin >> L , L ){
		int sum = 0, ans = 13;
		for(int i=0 ; i<12 ; ++i ){
			cin >> M[i] >> N[i] ;
			sum += (M[i]-N[i]);
			if( sum >= L ){
				ans = min(ans,i+1);
			}
		}
		
		((ans==13)? cout << "NA" : cout << ans ) << endl;
	}
}

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); flag = true;
			}
		}
		if (!flag) printf("NA\n");
	}
	return 0;
}

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

C++: #include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
using namespace std; 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;
 
int calc(int n,int *i,int *o){
  int *p,*q;
  p = i;
  q = o;
  int count = 0;
  for(int i = 0;i < 12;i++){
    count += *p - *q;
    if(count >= n) return i+1;
    p++;q++;
  }
  return -1;
}

int main(){
  int n;
  int in[12],out[12];
  int c;
  while(1){
    cin >> n;
    if(n == 0)break; 
    for(int i = 0;i < 12;i++){
      cin >> in[i] >> out[i];
    }
    int count = 0;
    for(int i = 0;i < 12;i++){
      count += in[i] - out[i];
      if(count >= n){P(i+1);break;}
      if(i == 11) P("NA");
    }
  }
  return 0;
}