
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int maxdepth;
int n;
int p[110];
int t[110];
int memo[5][110];

int calc(int balloon, int depth) {
  assert(balloon <= 3);
  maxdepth = max(maxdepth, depth);
  if (memo[balloon][depth] != -1) { return memo[balloon][depth]; }
  if (depth == n - 1) { return 0; }
  int ret = 1 << 20;
  if (t[depth] + (balloon + 1) * p[depth] + p[depth + 1] <= t[depth + 1]) {
    ret = min(ret, calc(1, depth + 1) + p[depth] + p[depth + 1]);
  }
  if (balloon <= 2 && t[depth] + (balloon + 1) * abs(p[depth] - p[depth + 1]) <= t[depth + 1]) {
    ret = min(ret, calc(balloon + 1, depth + 1) + abs(p[depth] - p[depth + 1]));
  }
  return memo[balloon][depth] = ret;
}

int main() {
  while (scanf("%d", &n), n) {
    maxdepth = -1;
    MEMSET(memo, -1);
    REP(i, n) {
      scanf("%d %d", &p[i + 1], &t[i + 1]);
    }
    p[0] = 0;
    t[0] = 0;
    p[n + 1] = 0;
    t[n + 1] = 1 << 20;
    n += 2;
    calc(0, 0);
    if (maxdepth + 1 != n) {
      printf("NG %d\n", maxdepth + 1);
    } else {
      printf("OK %d\n", memo[0][0]);
    }
  }
}