#include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define INF 100000000

int main() {
    int N;
    while (cin >> N, N) {
        vi p(N), t(N);
        REP(i, N) cin >> p[i] >> t[i];

        vvi dp(N, vi(4, INF));
        if (p[0] <= t[0]) {
            dp[0][0] = p[0];
        }
        int cnt = 1;
        FOR(i, 1, N) {
            FOR(j, 1, 4) {
                if (dp[i - 1][j - 1] == INF) continue;
                cnt = i + 1;
                int dist = abs(p[i] - p[i - 1]);
                int remain = t[i] - t[i - 1];
                if (j < 3 && dist * (j + 1) <= remain) {
                    dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + dist);
                }
                int dist_back = p[i] + p[i - 1];
                int time = p[i] + p[i - 1] * (j + 1);
                if (time <= remain) {
                    dp[i][0] = min(dp[i][0], dp[i - 1][j - 1] + dist_back);
                }
            }
        }
        int res = *min_element(ALL(dp[N - 1]));
        if (res != INF) {
            printf("OK %d\n", res + p[N - 1]);
        } else {
            printf("NG %d\n", cnt);
        }
    }
}