//By LH
#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;

#define INT (0x3f3f3f3f)*2
#define clr(a) memset(a, 0, sizeof(a))
#define repin(i, a, b) for (int i = a; i <= b; i++)
#define N 1024
struct Data
{
	int p, t;
}data[N];

int n;
int dp[N][4];

int main()
{
	clr(data);
	clr(dp);
	while (~scanf("%d", &n) && n)
	{
		repin(i, 1, n)
		{
			scanf("%d %d", &data[i].p, &data[i].t);
		}
		repin(i, 1, n)
		{
			repin(j, 1, 3)
			{
				dp[i][j] = INT;
			}
		}
		repin(i, 1, n)
		{
			if (dp[i - 1][1] != INT)
			{
				int times = 2 * data[i - 1].p + data[i].p;
				if (data[i - 1].t + times <= data[i].t)
				{
					dp[i][1] = min(dp[i][1], dp[i - 1][1] + data[i - 1].p + data[i].p);
				}
			}
			if (dp[i - 1][2] != INT)
			{
				int times = 3 * data[i - 1].p + data[i].p;
				if (data[i - 1].t + times <= data[i].t)
				{
					dp[i][1] = min(dp[i][1], dp[i - 1][2] + data[i - 1].p + data[i].p);
				}
			}
			if (dp[i - 1][3] != INT)
			{
				int times = 4 * data[i - 1].p + data[i].p;
				if (data[i - 1].t + times <= data[i].t)
				{
					dp[i][1] = min(dp[i][1], dp[i - 1][3] + data[i - 1].p + data[i].p);
				}
			}
			if (dp[i - 1][1])
			{
				int times = 2 * abs(data[i - 1].p - data[i].p);
				if (data[i - 1].t + times <= data[i].t)
				{
					dp[i][2] = min(dp[i][2], dp[i - 1][1] + abs(data[i - 1].p - data[i].p));
				}
			}
			if (dp[i - 1][2])
			{
				int times = 3 * abs(data[i - 1].p - data[i].p);
				if (data[i - 1].t + times <= data[i].t)
				{
					dp[i][3] = min(dp[i][3], dp[i - 1][2] + abs(data[i - 1].p - data[i].p));
				}
			}
		}
		int mini = INT;
		repin(j, 1, 3)
		{
			mini = min(mini, dp[n][j]);
		}
		if (mini != INT) printf("OK %d\n", mini + data[n].p);
		else
		{
			repin(i, 1, n)
			{
				if (dp[i][1] == dp[i][2] && dp[i][2] == dp[i][3] && dp[i][3] == INT)
				{
					printf("NG %d\n", i);
					break;
				}
			}
		}
	}
	return 0;
}