#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
#define INF (1<<24)
#define MAX_N 50
struct state{
  int pi,pj,cost;
  bool operator < (const state &p)const{
    return cost > p.cost;  
  }
};

int n;
int d[MAX_N][4];
int t[MAX_N],u[MAX_N];

void solve(){
  for(int i=0;i<MAX_N;i++)
    for(int j=0;j<4;j++)d[i][j]=INF;
  d[0][0]=0;
  priority_queue<state> Q;
  Q.push((state){0,0,0});

  while(!Q.empty()){
    state s=Q.top();Q.pop();
    if(s.cost>d[s.pi][s.pj])continue;
    if(s.pi==n+1){cout<<"OK "<<s.cost<<endl;return;}
   
    int k=s.pj+1;

    int di=abs(t[s.pi]-t[s.pi+1]);
    
    if(s.pj<3){
      int td=di*k;
      if(d[s.pi+1][s.pj+1]>s.cost+di){
	if(td<=u[s.pi+1]-u[s.pi]){
	  d[s.pi+1][s.pj+1]=s.cost+di;
	  Q.push((state){s.pi+1,s.pj+1,s.cost+di});
	}
      }
    }
    

    int td=t[s.pi]*k;
    for(int i=1;i<=s.pj;i++){
      int nk=k-i;
      int td2=t[s.pi+1]*nk;
      if(td+td2>u[s.pi+1]-u[s.pi])continue;
      if(s.cost+t[s.pi]+t[s.pi+1]<d[s.pi+1][nk]){
	d[s.pi+1][nk]=t[s.pi]+t[s.pi+1]+s.cost;
	Q.push((state){s.pi+1,nk,d[s.pi+1][nk]});
      }
    }
  }
 
  for(int i=0;i<=n;i++){
    bool flg=false;
    for(int j=0;j<4;j++)
      if(d[i][j]!=INF)flg=true;
    if(!flg){
      cout<<"NG "<<i<<endl;return;
    }
  }
 
}

int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    for(int i=1;i<=n;i++)cin>>t[i]>>u[i];
    t[n+1]=0;
    u[n+1]=INF;
    solve();
  }
  return 0;
}