#include <bits/stdc++.h>

using namespace std;

int main()
{
  int n;
  while(cin >> n, n){
    int p[44], t[44];
    p[0] = 0;
    t[0] = 0;
    for(int i = 1; i <= n; i++) cin >> p[i] >> t[i];
    int dp[44][4];
    const int inf = (1 << 25);
    fill(dp[0], dp[44], inf); 
    dp[0][0] = 0;
    for(int i = 1; i <= n; i++){
      for(int j = 0; j <= min(i-1, 3); j++){
	if(j != 3 && abs(p[i]-p[i-1])*(j+1) <= t[i]-t[i-1]){
	  dp[i][j+1] = min(dp[i][j+1], dp[i-1][j] + abs(p[i]-p[i-1]));
	}
	if(p[i]+p[i-1]*(j+1) <= t[i]-t[i-1]){
	  dp[i][1] = min(dp[i][1], dp[i-1][j] + p[i]+p[i-1]);	    
	}
      }
    }
    for(int i = 0; i <= 3; i++) dp[n][i] += p[n];
    int ans = *min_element(dp[n], dp[n] + 4);
    if(ans < inf) cout << "OK " << ans << endl;
    else{
      for(int i = 0; i <= n; i++){
	bool judge = false;
	for(int j = 0; j <= 3; j++){
	  if(dp[i][j] < inf) judge = true;
	}
	if(!judge){
	  cout << "NG " << i << endl;
	  break;
	}
      }
    }
  }
  return 0;
}