#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
const ll INF = MOD + 1;
const ld EPS = 1e-10;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
int p[50], t[50], dp[50][5];
int n;

int solve(int i, int j)
{
	if (i == n) return p[n];
	if (dp[i][j] >= 0) return dp[i][j];
	int res = INF;
	if (p[i] * (j + 1) + p[i + 1] <= t[i + 1] - t[i]) 
		chmin(res, solve(i + 1, 1) + p[i] + p[i + 1]);
	if (j < 3 && abs(p[i] - p[i + 1]) * (j + 1) <= t[i + 1] - t[i]) 
		chmin(res, solve(i + 1, j + 1) + abs(p[i] - p[i + 1]));
	return dp[i][j] = res;
}

int main()
{
	while (cin >> n, n)
	{
		MS(dp, -1);
		FOR(i, 1, n + 1) cin >> p[i] >> t[i];
		int ans = solve(0, 0);
		if (ans == INF)
		{
			while (ans == INF)
			{
				MS(dp, -1);
				n--;
				ans = solve(0, 0);
			}
			cout << "NG " << n+1 << endl;
		}
		else cout << "OK " << ans << endl;
	}
	return 0;
}