This page is still under construction.

Parts of this page are still being built. What you see may change.

Frogger

Time limit1sMemory limit256 MB

Summary
Find the fewest frogs to place left of the y-axis so peg jumps can bring one frog to (X, 0), or print frogger when it is impossible.
Level

Hard9 of 10

Topics
Math, BFS, Brute force
Solved
No attempts yet

Problem

A group of frogs sits on an infinite xy grid. Every frog has an x coordinate of 00 or less. A fly sits on the grid point (2,0)(2, 0), and the hungry frogs want to get there and eat it. There is one catch. A frog can move only by jumping over another frog that sits next to it and landing on the square just beyond, and the frog that was jumped over explodes and is gone. So if Peter sits at (0,0)(0, 0), then John at (−1,0)(-1, 0) can jump to (1,0)(1, 0), but Peter explodes. In the same way, if Alfred sits at (−1,2)(-1, 2) and Barney sits at (−1,1)(-1, 1), then Alfred can jump to (−1,0)(-1, 0) and Barney explodes.

A jump goes in one of the four axis directions. The square that is jumped over must hold a frog, and the landing square must be empty.

Reaching the fly costs many frog lives. The frogs believe in the common good and are willing to give up everything for it. The remaining question is whether they can make it at all. Given the position (X,0)(X, 0) of the fly on the non-negative x axis, find how many frogs you need to start with. The frogs can be placed initially on any grid points on or to the left of the y axis, that is with an x coordinate of 00 or less, and no two frogs may share a position.

Input

The first line holds the number of test cases TT, with T≤100T \le 100.

Each test case is one line with a single integer XX, where 0≤X≤310 \le X \le 31. The fly is at (X,0)(X, 0).

Output

For each test case, print on one line the minimum number of frogs you need to start with in order to catch the fly. If catching the fly is impossible, print frogger on that line instead.

Examples2

  1. Example 1

    Input
    4
    0
    1
    2
    3
    
    Expected output
    1
    2
    4
    8
    
  2. Example 2

    Input
    3
    4
    5
    6
    
    Expected output
    20
    frogger
    frogger