using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Competitive_Programming
{
    class MainClass
    {
        Scanner sc;
        StringBuilder ans;
        const long MOD = (long) 1e9 + 7;
        const int INF = (int)1e9;
        static void Main(string[] args)
        {
            new MainClass().solve();
        }
        
        void solve()
        {
            sc = new Scanner();
            ans = new StringBuilder();
            
            while (true)
            {
                int N = sc.NextInt();
                if (N == 0)
                {
                    break;
                }
                int[] p = new int[N + 1];
                int[] t = new int[N + 1];
                p[0] = t[0] = 0;
                for (int i = 0; i < N; i++)
                {
                    p[i + 1] = sc.NextInt();
                    t[i + 1] = sc.NextInt();
                }
                int[,] dp = new int[N + 1, 4];
                for (int i = 0; i < N + 1; i++)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        dp[i, j] = INF;
                    }
                }
                dp[0, 0] = 0;
                for (int i = 0; i < N; i++)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        if (dp[i, j] != INF)
                        {
                            int dist = Math.Abs(p[i] - p[i + 1]);
                            int time = t[i + 1] - t[i];
                            if (j != 3)
                            {
                                if (dist * (j + 1) <= time)
                                {
                                    dp[i + 1, j + 1] = Math.Min(dp[i + 1, j + 1], dp[i, j] + dist);
                                }
                            }
                            if (p[i] * (j + 1) + p[i + 1] <= time)
                            {
                                dp[i + 1, 1] = Math.Min(dp[i + 1, 1], dp[i, j] + p[i] + p[i + 1]);
                            }
                        }
                    }
                }
                int buf = INF;
                for (int i = 0; i < 4; i++)
                {
                    if (dp[N, i] != INF)
                    {
                        buf = Math.Min(buf, dp[N, i] + p[N]);
                    }
                }
                if (buf != INF)
                {
                    ans.AppendFormat("OK {0}\n", buf);
                    continue;
                }
                for (int i = N; i >= 0; i--)
                {
                    bool flag = false;
                    for (int j = 0; j < 4; j++)
                    {
                        flag |= (dp[i, j] != INF);
                    }
                    if (flag)
                    {
                        ans.AppendFormat("NG {0}\n", i + 1);
                        break;
                    }
                }
            }
            
            Console.Write(ans);
        }
    }
    
    class Scanner
    {
        Queue<string> buf;
        public Scanner()
        {
            buf = new Queue<string>();
        }
        private void GetBuf()
        {
            while (buf.Count == 0)
            {
                string[] stringArray = Console.ReadLine().Split(' ');
                if (stringArray.Length == 0 || stringArray[0] == "")
                {
                    continue;
                }
                foreach (string e in stringArray)
                {
                    buf.Enqueue(e);
                }
            }
        }
        public int NextInt()
        {
            return int.Parse(this.Next());
        }
        public long NextLong()
        {
            return long.Parse(this.Next());
        }
        public double NextDouble()
        {
            return double.Parse(this.Next());
        }
        public string Next()
        {
            this.GetBuf();
            return buf.Dequeue();
        }
    }
}

Measured memory_bytes: 10232