import std.stdio;
import std.ascii;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

const INF = int.max / 2;

void main() {
    int N;
    int[] P, T;
    bool input() {
        scanf("%d\n", &N);
        if (N == 0) return false;
        P = new int[N + 1];
        T = new int[N + 1];
        P[0] = T[0] = 0;
        for (int i = 1; i <= N; i++) {
            scanf("%d %d\n", &P[i], &T[i]);
        }
        return true;
    }
    int dist(int a, int b) {
        return abs(P[a] - P[b]);
    }
    void solve() {
        auto dp = new int[][](4, N + 1);
        foreach (ref L; dp) L[] = INF;
        dp[0][0] = 0; // ばんぺーさん
        dp[1][1] = T[1] < P[1] ? INF : P[1];
        for (int j = 1; j <= N; j++) {
            for (int i = 1; i <= 3; i++) {
                int ntime = T[j - 1] + dist(0, j - 1) * (i + 1) + dist(0, j) * 1;
                if (ntime <= T[j]) {
                    dp[1][j] = min(dp[1][j], dp[i][j - 1] + dist(0, j - 1) + dist(0, j));
                }
            }
            for (int i = 2; i <= 3; i++) {
                int ntime = T[j - 1] + dist(j - 1, j) * i;
                if (ntime <= T[j]) {
                    dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + dist(j, j - 1));
                }
            }
        }
        for (int j = N; j >= 0; j--) {
            int X = INF;
            for (int i = 0; i <= 3; i++) {
                X = min(X, dp[i][j]);
            }
            if (X < INF) {
                if (j == N) {
                    writeln("OK ", X + P[N]);
                } else {
                    writeln("NG ", j + 1);
                }
                break;
            }
        }
    }
    while (input) solve;
}