#include <bits/stdc++.h>
template<typename T>
struct Edge {
    int from, to;
    T cost;
    Edge(int from, int to, T cost) {
        this->from = from;
        this->to = to;
        this->cost = cost;
    }
};
bool operator == (Edge<int> e1, Edge<int> e2) {
    return e1.from == e2.from &&
            e1.to == e2.to &&
            e1.cost == e2.cost;
}
bool operator > (Edge<int> e1, Edge<int> e2) {
    return e1.cost < e2.cost;
}
template<typename T>
using Edges = std::vector<Edge<T>>;
template<typename T>
using Graph = std::vector<Edges<T>>;
template <typename T>
std::vector<T> dijkstra(const Graph<T> &g, int s) {
    int sz = (int)(g.size());
    std::vector<T> dist(sz, -1);
    std::priority_queue<std::pair<T, int>, std::vector<std::pair<T, int>>, std::greater<std::pair<T, int>>> pq;
    dist[s] = 0;
    pq.push({0, s});
    while(!pq.empty()) {
        T d = pq.top().first;
        int now = pq.top().second;
        pq.pop();
        if(dist[now] == -1 || d > dist[now]) continue;
        for(int i=0;i<(int)(g[now].size());++i) {
            int next = g[now][i].to;
            T cost = g[now][i].cost;
            if(dist[next] == -1 || dist[next] > dist[now] + cost) {
                dist[next] = dist[now] + cost;
                pq.push({cost, next});
            }
        }
    }
    return dist;
}
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
void solve(int n) {
  vi p(n), t(n);
  for(int i=0;i<n;++i) {
    cin >> p[i] >> t[i];
  }
  Graph<ll> graph(n * 4 + 2);
  if(p[0] <= t[0]) graph[0].push_back(Edge<ll>(0, 2, p[0]));
  for(int i=0;i<n-1;++i) {
    for(int j=1;j<=2;++j) {
      if((j+1) * abs(p[i] - p[i+1]) <= t[i+1] - t[i]) graph[1+i*4+j].push_back(Edge<ll>(1+i*4+j, 1+(i+1)*4+j+1, abs(p[i] - p[i+1])));
    }
    for(int j=1;j<=3;++j) {
      if((j+1) * p[i] + p[i+1] <= t[i+1] - t[i]) graph[1+i*4+j].push_back(Edge<ll>(1+i*4+j, 1+(i+1)*4+1, p[i] + p[i+1]));
    }
  }
  for(int i=0;i<4;++i) {
    graph[1+(n-1)*4+i].push_back(Edge<ll>(1+(n-1)*4+i, n*4+1, p[n-1]));
  }
  auto d = dijkstra(graph, 0);
  ll mi = INF;
  int maidx = -1;
  for(int i=0;i<(int)(d.size());++i) {
    if(i == 0) continue;
    if(d[i] == -1) continue;
    int idx = (i-1) / 4;
    if(idx == n) {
      maidx = idx;
      mi = d[i];
    } else if(maidx < idx) {
      maidx = idx;
      mi = d[i];
    } else if(maidx == idx) {
      mi = min(mi, d[i]);
    }
  }
  if(maidx == n) {
    cout << "OK " << mi << endl;
  } else {
    cout << "NG " << maidx + 2 << endl;
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    int n; cin >> n;
    if(n == 0) break;
    solve(n);
  }
}



Measured memory_bytes: 3152