Balloon Collecting
“Balloons should be captured efficiently”, the game designer says. He is designing an oldfashioned game with two dimensional graphics. In the game, balloons fall onto the ground one after another, and the player manipulates a robot vehicle on the ground to capture the balloons. The player can control the vehicle to move left or right, or simply stay. When one of the balloons reaches the ground, the vehicle and the balloon must reside at the same position, otherwise the balloon will burst and the game ends.
Figure 1: Robot vehicle and falling balloons
The goal of the game is to store all the balloons into the house at the left end on the game field. The vehicle can carry at most three balloons at a time, but its speed changes according to the number of the carrying balloons. When the vehicle carries k balloons (k = 0, 1, 2, 3), it takes k+1 units of time to move one unit distance. The player will get higher score when the total moving distance of the vehicle is shorter.
Your mission is to help the game designer check game data consisting of a set of balloons. Given a landing position (as the distance from the house) and a landing time of each balloon, you must judge whether a player can capture all the balloons, and answer the minimum moving distance needed to capture and store all the balloons. The vehicle starts from the house. If the player cannot capture all the balloons, you must identify the first balloon that the player cannot capture.
Input
The input is a sequence of datasets. Each dataset is formatted as follows.
n p_1 t_1 ... p_n t_n
The first line contains an integer n, which represents the number of balloons (0 < n ≤ 40). Each of the following n lines contains two integers p_i and t_i (1 ≤ i ≤ n) separated by a space. p_i and t_i represent the position and the time when the i-th balloon reaches the ground (0 < p_i ≤ 100, 0 < t_i ≤ 50000). You can assume t_i < t_j for i < j. The position of the house is 0, and the game starts from the time 0.
The sizes of the vehicle, the house, and the balloons are small enough, and should be ignored. The vehicle needs 0 time for catching the balloons or storing them into the house. The vehicle can start moving immediately after these operations.
The end of the input is indicated by a line containing a zero.
Output
For each dataset, output one word and one integer in a line separated by a space. No extra characters should occur in the output.
If the player can capture all the balloons, output "OK" and an integer that represents theminimum moving distance of the vehicle to capture and store all the balloons.
If it is impossible for the player to capture all the balloons, output "NG" and an integer ksuch that the k-th balloon in the dataset is the first balloon that the player cannot capture.