#include <iostream>
#include <queue>
#include <cstdlib>
using namespace std;

class State
{
public:
	int n, k, d;
	State(int n, int k, int d)
		:n(n),k(k),d(d)
	{}

	bool operator<(const State& s) const
	{
		if(n!=s.n) return n > s.n;
		return d > s.d;
	}
};

int N, p[41], t[41];

pair<bool, int> solve()
{
	bool vis[40][4] = {0};

	int m = 0, res = (1<<24);
	priority_queue<State> q;
	q.push(State(0,0,0));

	while(!q.empty()) {
		State s = q.top(); q.pop();
		m = max(m, s.n);

		if(s.n == N) {
			res = min(res, s.d + p[s.n]);
			continue;
		}
		if(vis[s.n][s.k]) continue;
		vis[s.n][s.k] = true;

		int nt = (s.k + 1)*abs(p[s.n + 1] - p[s.n]) + t[s.n];
		if(nt <= t[s.n + 1] && s.k < 3) q.push(State(s.n + 1, s.k + 1, s.d + abs(p[s.n + 1] - p[s.n])));

		nt = (s.k + 1)*p[s.n] + p[s.n + 1] + t[s.n];
		if(nt <= t[s.n + 1]) q.push(State(s.n + 1, 1, s.d + p[s.n + 1] + p[s.n] ));
	}

	if(m == N) return make_pair(true, res);
	return make_pair(false, m + 1);
}


int main()
{
	while(cin >> N, N) {
		p[0] = t[0] = 0;
		for(int i=1; i<=N; i++)
			cin >> p[i] >> t[i];

		pair<bool, int> res = solve();

		cout << (res.first ? "OK" : "NG") << " ";
		cout << res.second << endl;
	}
}