#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n;
	while (cin >> n, n) {
		vector<int> p(n + 2), t(n + 2);
		vector<vector<int>> dp(n + 2, vector<int>(4, INF));
		for (int i = 1; i <= n; i++) {
			cin >> p[i] >> t[i];
		}
		p[n + 1] = 0;
		t[n + 1] = INF;
		dp[0][0] = 0;
		for (int i = 0; i < n + 1; i++) {
			for (int j = 0; j < 4; j++) {
				if (dp[i][j] == INF) continue;
				if (j < 3 && abs(p[i] - p[i + 1]) * (j + 1) <= t[i + 1] - t[i]) dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + abs(p[i] - p[i + 1]));
				if (p[i] * (j + 1) + p[i + 1] <= t[i + 1] - t[i]) dp[i + 1][1] = min(dp[i + 1][1], dp[i][j] + p[i] + p[i + 1]);
			}
		}
		int res = INF, last = 0;
		for (int i = 1; i < n + 2; i++) {
			bool ng = true;
			res = INF;
			for (int j = 0; j < 4; j++) {
				if (dp[i][j] != INF) {
					ng = false;
					res = min(res, dp[i][j]);
				}
			}
			if (ng) {
				last = i;
				break;
			}
		}
		if (res != INF) {
			cout << "OK " << res << endl;
		}
		else {
			cout << "NG " << last << endl;
		}
	}
	return 0;
}