#include<bits/stdc++.h>
#define INF 100000
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int d[n],t[n];

    for(int i=0;i<n;i++)
       cin>>d[i]>>t[i];

    for(int i=n-1;i>=1;i--)t[i]-=t[i-1];

    int dp[n][4];

    for(int i=0;i<n;i++)
      for(int j=0;j<4;j++)
        dp[i][j]=INF;

    if(t[0]<d[0]){
      cout<<"NG "<<1<<endl;
    }
    else{
      dp[0][0]=d[0];
    for(int i=1;i<n;i++){
      if(dp[i-1][1]!=INF){
        int dt=abs(d[i]-d[i-1]);
        if(dt*3<=t[i])dp[i][2]=min(dp[i][2],dp[i-1][1]+dt);
        int de=d[i-1]*3+d[i];
        if(de<=t[i])dp[i][0]=min(dp[i][0],dp[i-1][1]+d[i]+d[i-1]);
      }
      if(dp[i-1][2]!=INF){
        int de=d[i-1]*4+d[i];
        if(de<=t[i])dp[i][0]=min(dp[i][0],dp[i-1][2]+d[i]+d[i-1]);
      }
      if(dp[i-1][0]!=INF){
        int dt=abs(d[i]-d[i-1]);
        if(dt*2<=t[i])dp[i][1]=min(dp[i][1],dp[i-1][0]+dt);
        int de=d[i-1]*2+d[i];
        if(de<=t[i])dp[i][0]=min(dp[i][0],dp[i-1][0]+d[i]+d[i-1]);
      }
      int cc=0;
      for(int j=0;j<4;j++)
        if(dp[i][j]!=INF)cc++;
      if(!cc){
        cout<<"NG "<<i+1<<endl;
        goto L;
      }
    }
    int sum=INF;
    for(int i=0;i<4;i++)
      sum=min(sum,dp[n-1][i]+d[n-1]);
    cout<<"OK "<<sum<<endl;
    }L:;
  }
}