#include<iostream>
using namespace std;

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