#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    int n;
    cin >> n;
    if(n==0) return 0;
    vector<int> p(n+1),t(n+1);
    p[0]=0,t[0]=0;
    rep(i,n) cin >> p[i+1] >> t[i+1];
    vector<vector<int>> dp(n+1,vector<int>(3,IINF));
    dp[0][0]=0;
    int ans=IINF;
    repp(i,1,n+1){
      rep(j,3){
        if(p[i-1]*(j+2)+p[i]<=t[i]-t[i-1]){
          dp[i][0]=min(dp[i][0],dp[i-1][j]+p[i-1]+p[i]);
        }
      }
      repp(j,1,3){
        if((j+1)*abs(p[i-1]-p[i])<=t[i]-t[i-1]){
          dp[i][j]=min(dp[i][j],dp[i-1][j-1]+abs(p[i-1]-p[i]));
        }
      }
      bool ok=false;
      rep(j,3){
        if(dp[i][j]<IINF) ok=true;
      }
      if(!ok){
        cout << "NG" SP i << endl;
        goto next;
      }
    }
    rep(i,3) ans=min(ans,dp[n][i]+p[n]);
    cout << "OK" SP ans << endl;
    next:;
  }
  return 0;
}

