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

using Pi = pair < int , int >;

const int INF = (1 << 30) - 1;

int main()
{
        int n;
        Pi dat[45];
                
        
        while ( cin >> n, n != 0 ) {
                int dp[45][4];
                int ans[45];

                for ( int i = 1; i <= n; i++ ) {
                        cin >> dat[i].second >> dat[i].first;
                }

                dat[0] = Pi(0, 0);

                sort(dat, dat + n + 1);
                fill_n(*dp, 45 * 4, INF);
                fill_n(ans, 45, INF);

                dp[0][0] = 0;

                for ( int i = 0; i < n; i++ ) {
                        for ( int j = 0; j < 4; j++ ) {
                                if ( dp[i][j] == INF ) continue;
                                int base = (j + 1) * dat[i].second;
                                int pos = 0;
                                int pcost = 0;
                                for ( int k = 1; k <= 3 && i + k <= n; k++ ) {
                                        int nextpos = dat[i + k].second;
                                        int nowtime = dat[i + k - 1].first;
                                        int nexttime = dat[i + k].first;
                                        if ( base + abs(nextpos - pos) * k <= nexttime - nowtime ) {
                                                pcost += base / (j + 1) + abs(nextpos - pos);
                                                dp[i + k][k] = min(dp[i + k][k], dp[i][j] + pcost);
                                                base = 0;
                                                pos = nextpos;
                                        } else {
                                                break;
                                        }
                                }
                        }
                }

                for ( int i = 0; i < 45; i++ ) {
                        for ( int j = 0; j < 4; j++ ) {
                                ans[i] = min(ans[i], dp[i][j]);
                        }
                }

                if ( ans[n] != INF ) {
                        cout << "OK" << " " << ans[n] + dat[n].second << endl;
                } else {
                        int i;
                        cout << "NG" << " ";
                        for ( i = 0; i < n && ans[i] != INF; i++);
                        cout << i << endl;
                }
        }
        return ( 0 );
}

