var n;
var p = [];
var t = [];
var g = [];
var u = [];
var d = [];

function index(i, j){
	return i * 3 + j;
}

function main(){
	while(n = scan()){
		rep(n, function(i){
			p[i] = scan();
			t[i] = scan();
		});
		
		rep(index(n, 0) + 2, function(i){
			g[i] = [];
		});
		if(p[0] <= t[0]){
			g[index(n, 0)].push([index(0, 0), p[0]]);
		}
		rep(3, function(i){
			g[index(n - 1, i)].push([index(n, 0) + 1, p[n - 1]]);
		});
		rep(n - 1, function(i){
			rep(3, function(j){
				var dp = Math.abs(p[i] - p[i + 1]);
				var dt = t[i + 1] - t[i];
				if(j < 2 && dp * (j + 2) <= dt){
					g[index(i, j)].push([index(i + 1, j + 1), dp]);
				}
				if(p[i] * (j + 2) + p[i + 1] <= dt){
					g[index(i, j)].push([index(i + 1, 0), p[i] + p[i + 1]]);
				}
			});
		});

		rep(index(n, 0) + 2, function(i){
			u[i] = false;
			d[i] = Infinity;
		});

		d[index(n, 0)] = 0;
		while(true){
			var v = -1;
			rep(index(n, 0) + 2, function(i){
				if(!u[i] && (v === -1 || d[i] < d[v])){
					v = i;
				}
			});

			if(v === -1){
				break;
			}

			u[v] = true;
			rep(g[v].length, function(i){
				var e = g[v][i];
				if(d[e[0]] > d[v] + e[1]){
					d[e[0]] = d[v] + e[1];
				}
			});
		}

		if(d[index(n, 0) + 1] !== Infinity){
			print('OK ' + d[index(n, 0) + 1]);
		}
		else{
			rep(n, function(i){
				var f = false;
				rep(3, function(j){
					if(d[index(i, j)] !== Infinity){
						f = true;
						return false;
					}
				});
				if(!f){
					print('NG ' + (i + 1));
					return false;
				}
			});
		}
	}
}

function rep(a, b, c, u){
	if(c === u){
		c = b;
		b = a;
		a = 0;
	}
	for(var i = a; i < b; ++i){
		if(c(i) === false){
			break;
		}
	}
}

var input = '';

function scan(){
	return +input.pop();
}
function scan_string(){
	return input.pop();
} 
function print(val){
	console.log(val);
}
 
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk){
	input += chunk;
});
process.stdin.on('end', function(){
	input = input.trim().split(/\s+/).reverse();
	main();
});