#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

struct Balloon{
	Balloon(){
		location = 0;
		time = 0;
	}
	Balloon(int arg_location,int arg_time){
		location = arg_location;
		time = arg_time;
	}
	int location,time;
};

int main(){

	int N,ans,last_catch,dist,dp[41][4];
	bool FLG;
	Balloon info[41];

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		ans = BIG_NUM;
		last_catch = 0;

		for(int i = 1; i <= N; i++){
			scanf("%d %d",&info[i].location,&info[i].time);
		}

		for(int i = 1; i <= N; i++){
			for(int k = 0; k <= 3; k++)dp[i][k] = BIG_NUM;
		}

		if(info[1].location > info[1].time){
			printf("NG 1\n");
			continue;
		}else{
			dp[1][1] = info[1].location;
			last_catch = 1;
		}

		for(int i = 2; i <= N; i++){
			FLG = false;
			for(int k = 0; k <= 3; k++){
				if(dp[i-1][k] == BIG_NUM)continue;

				dist = abs(info[i].location-info[i-1].location);

				switch(k){
				case 0:
					if(dist*(k+1) <= info[i].time-info[i-1].time){
						dp[i][k+1] = min(dp[i][k+1],dp[i-1][k]+dist);
						FLG = true;
					}else{
						//Do nothing
					}
					break;
				case 1:
				case 2:
					if(dist*(k+1) <= info[i].time-info[i-1].time){
						dp[i][k+1] = min(dp[i][k+1],dp[i-1][k]+dist);
						FLG = true;
					}else{
						//Do nothing
					}

					if(info[i-1].location*(k+1) + info[i].location <= info[i].time-info[i-1].time){
						dp[i][1] = min(dp[i][1],dp[i-1][k]+info[i-1].location+info[i].location);
						FLG = true;
					}
					break;
				case 3:
					if(info[i-1].location*(k+1) + info[i].location <= info[i].time-info[i-1].time){
						dp[i][1] = min(dp[i][1],dp[i-1][k]+info[i-1].location+info[i].location);
						FLG = true;
					}
					break;
				}
			}
			if(!FLG){
				break;
			}else{
				last_catch = i;
			}
		}

		if(last_catch == N){
			for(int i = 0; i <= 3; i++)ans = min(ans,dp[N][i]);
		}

		if(ans == BIG_NUM){
			printf("NG %d\n",last_catch+1);
		}else{
			printf("OK %d\n",ans+info[N].location);
		}
	}

	return 0;
}