#include<cstdio>
#include<algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef pair<bool,int> pbi;

pbi dp[41][4];
int n,p[41],t[41];

pbi solve(int i,int k){
	if(~dp[i][k].second) return dp[i][k];

	if(i==n-1) return dp[i][k]=make_pair(true,-p[i]);

	pbi res(false,i);
	if(k<3 && abs(p[i+1]-p[i])*(k+1)<=t[i+1]-t[i]){
		pbi tmp=solve(i+1,k+1);
		if(tmp.first) tmp.second-=abs(p[i+1]-p[i]);
		res=max(res,tmp);
	}
	if(p[i]*(k+1)+p[i+1]<=t[i+1]-t[i]){
		pbi tmp=solve(i+1,1);
		if(tmp.first) tmp.second-=p[i]+p[i+1];
		res=max(res,tmp);
	}
	return dp[i][k]=res;
}

int main(){
	for(;scanf("%d",&n),n;){
		p[0]=t[0]=0;
		rep(i,n) scanf("%d%d",p+i+1,t+i+1);
		n++;

		rep(i,n) rep(k,4) dp[i][k].second=-1;

		pbi res=solve(0,0);
		if(res.first) printf("OK %d\n",-res.second);
		else          printf("NG %d\n",res.second+1);
	}

	return 0;
}