/*
2
10 100
100 270
2
10 100
100 280
3
100 150
10 360
40 450
3
100 150
10 360
40 440
2
100 10
50 200
2
100 100
50 110
1
15 10
4
1 10
2 20
3 100
90 200
0
*/
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>

using namespace std;

int INF;

int n;
int p[100];
int t[100];
int f[100][5];

int main(){
    while (1){
        scanf("%d",&n);
        if (n==0) return 0;
        for (int i=1;i<=n;i++) scanf("%d%d",&p[i],&t[i]);
        memset(f,127,sizeof(f));
        INF=f[0][0];
        if (p[1]<=t[1]) f[1][1]=p[1];
        for (int i=2;i<=n;i++){
                if ((f[i-1][1]!=INF)&&((t[i]-t[i-1])>=(p[i]+p[i-1]*2))) f[i][1]=min(f[i][1],f[i-1][1]+(p[i]+p[i-1]));
                if ((f[i-1][2]!=INF)&&((t[i]-t[i-1])>=(p[i]+p[i-1]*3))) f[i][1]=min(f[i][1],f[i-1][2]+(p[i]+p[i-1]));
                if ((f[i-1][3]!=INF)&&((t[i]-t[i-1])>=(p[i]+p[i-1]*4))) f[i][1]=min(f[i][1],f[i-1][3]+(p[i]+p[i-1]));
                if ((f[i-1][1]!=INF)&&((t[i]-t[i-1])>=abs(p[i]-p[i-1])*2)) f[i][2]=f[i-1][1]+abs(p[i]-p[i-1]);
                if ((f[i-1][2]!=INF)&&((t[i]-t[i-1])>=abs(p[i]-p[i-1])*3)) f[i][3]=f[i-1][2]+abs(p[i]-p[i-1]);
        }
        if (min(f[n][1],min(f[n][2],f[n][3]))==INF){
                printf("NG ");
                for (int i=1;i<=n;i++) if (min(f[i][1],min(f[i][2],f[i][3]))==INF){
                        printf("%d\n",i);
                        break;
                }
        }
        else{
                printf("OK %d\n",min(f[n][1],min(f[n][2],f[n][3]))+p[n]);
        }
    }
    return 0;
}