#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> P;

const int INF = 1e8;

/*int func(int now, int t, int b) {
	if ( now == n ) return 0;
	if ( dp[now][t][b] != INF ) return dp[now][t][b];

	int add;
	int ret = func(now+1, t+
	}*/

int main() {
	int n;
	while ( cin >> n, n ) {
		vector<P> v(n);
		int dp[40][4];
		for ( int i = 0; i < n; i++ ) {
			cin >> v[i].second >> v[i].first; 
		}
	
		sort(v.begin(), v.end());

		fill_n(*dp, 40*4, INF);

		if ( v[0].first < v[0].second ) {
			cout << "NG " << 1 << endl;
			continue;
		}
		dp[0][1] = v[0].second;

		for ( int i = 1; i < n; i++ ) {
			for ( int j = 0; j < 3; j++ ) {				
				if ( dp[i-1][j] == INF ) continue;
				if ( v[i-1].first + (v[i-1].second)*(j+1) + v[i].second <= v[i].first ) {
					dp[i][1] = min(dp[i][1], dp[i-1][j] + v[i-1].second + v[i].second);
				}
				if ( v[i-1].first + abs(v[i-1].second-v[i].second)*(j+1) <= v[i].first ) {
					dp[i][j+1] = min(dp[i][j+1], dp[i-1][j] + abs(v[i-1].second-v[i].second));
				}
			}
			if ( dp[i-1][3] != INF ) {
				if ( v[i-1].first + (v[i-1].second)*(4) + v[i].second <= v[i].first ) {
					dp[i][1] = min(dp[i][1], dp[i-1][3] + v[i-1].second + v[i].second);
				}
			}
		}
	
		int ans = INF;
		for ( int i = 0; i < 4; i++ ) {
			ans = min(ans, dp[n-1][i]);
		}

		if ( ans == INF ) {
			int i;
			for ( i = 0; i < n; i++ ) {
				int mi = INF;
				for ( int j = 0; j < 4; j++ ) mi = min(mi, dp[i][j]);
				if ( mi == INF ) break;
			}
			cout << "NG ";
			cout << i+1 << endl;
		} else {
			cout << "OK ";
			cout << ans+v[n-1].second << endl;
		}
	}

	return 0;
}

