#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





bool comp(pair<ll, ll> a, pair<ll, ll> b) {
    return a.S < b.S;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    
    int n;
    while (cin >> n && n) {
        vector<pair<ll, ll> > v(n);
        rep(i, n) cin >> v[i].F >> v[i].S;
        sort(all(v), comp);
        
        ll dp[n + 1][43]; // 総移動距離を最小にしたい
        // バルーン3個までしか持てんのかい!!
        // i番目の風船(1indexed), i番目にいったときの風船の数
        fill_n(*dp, (n + 1) * 43, 1e18);
        dp[0][0] = 0;
        
        rep(i, n) rep(j, 4) {
            if (dp[i][j] == 1e18) continue;
            // 直接行く
            ll p = (i == 0 ? 0 : v[i - 1].F);
            ll t = (i == 0 ? 0 : v[i - 1].S);
            if ((j + 1) * abs(v[i].F - p) <= v[i].S - t) {
                chmin(dp[i + 1][j + 1], dp[i][j] + abs(v[i].F - p));
            }
            // 一旦帰る
            if ((j + 1) * p + v[i].F <= v[i].S - t) {
                chmin(dp[i + 1][1], dp[i][j] + p + v[i].F);
            }
        }
        rep(i, n + 1) {
            int flg = 0;
            rep(j, 4) if (dp[i][j] != 1e18) { flg = 1; break; }
            if (flg == 0) {
                cout << "NG " << i << endl;
                break;
            }
            if (i == n) {
                ll ans = 1e18;
                rep(i, 4) chmin(ans, dp[n][i]);
                cout << "OK " << ans + v[n - 1].F << endl;
            }
        }
        // rep(i, n + 1) { rep(j, n + 1) cout << dp[i][j] << " "; cout << endl; }
        // rep(j, n + 1) cout << dp[n][j] << " "; cout << endl;
    }
}




