#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
int main(){
  int n;
  while(cin >> n,n){
    vector< pair<int, int> > V;
    int p, t;
    for(int i = 0; i < n; ++i){
      cin >> p >> t;
      V.push_back(make_pair(p, t));
    }
    int INF = 1000000000;
    vector< vector<int> > dp(n,vector<int>(4,INF));

    if(V[0].first > V[0].second){
      cout << "NG 1" << endl;
      continue;
    }
    dp[0][1] = V[0].first;
    
    bool f = true;
    for(int i = 1; i < n; ++i){
      bool g = false;
      for(int j = 1; j <= 3; ++j){
        if(dp[i-1][j] == INF) continue;
        if(j+1 <= 3 && abs(V[i].first-V[i-1].first)*(j+1) <= V[i].second - V[i-1].second){
          g = true;
          dp[i][j+1] = min(dp[i][j+1], dp[i-1][j]+abs(V[i].first-V[i-1].first));
        }

        if(V[i].first+V[i-1].first*(j+1) <= V[i].second - V[i-1].second){
          g = true;
          dp[i][1] = min(dp[i][1], dp[i-1][j]+V[i].first+V[i-1].first);
        }

      }
      if(!g){
        cout << "NG " << i+1 << endl;
        f = false;
        break;
      }
    }
    if(f){
      int ans = INF;
      for(int i = 0; i < 4; ++i){
        ans = min(ans, dp[n-1][i]+V[n-1].first);
      }
      cout << "OK " << ans << endl;
    }
  }
  return 0;
}