EIGHTS - Triple Fat Ladies


Pattern Matchers have been designed for various sorts of patterns. Mr. HKP likes to observe patterns in numbers. After completing his extensive research on the squares of numbers, he has moved on to cubes. Now he wants to know all numbers whose cube ends in 888.

Given a number k, help Mr. HKP find the kth number (indexed from 1) whose cube ends in 888.

Input

The first line of the input contains an integer t, the number of test cases. t test cases follow.

Each test case consists of a single line containing a single integer k (1 <= k <= 2000000000000).

Output

For each test case, output a single integer which denotes the kth number whose cube ends in 888. The result will be less than 263.

Example

Input:
1
1

Output:
192

hide comments
Mayank: 2015-05-28 15:27:31

I did this question by generating the series and observing the pattern but is there any logic by number theory?

Last edit: 2015-05-28 15:28:43
Harsh Vardhan Ladha: 2015-05-26 09:48:45

Lol the pattern :D

biswas: 2015-05-20 20:28:50

solution hidden in the word "PATTERN"...Think Think

pk: 2015-05-18 07:47:31

nice question... Ac in first go... :)

John Jost: 2015-04-18 16:23:06

I feel dirty... Did it initially with an entirely too slow algorithm but that let me see the pattern which made this a trivial problem.

Pradd: 2015-04-16 16:54:19

AC on second.. Don't forget to use long long in C.. For large numbers, instead of segmentation fault you got a weird output which gives WA..

hareesh: 2015-04-14 08:11:43

AC on first go :)
@arjun : thanx for the pattern

arjun: 2015-03-27 19:41:34

Test Cases:
4
1
2
3
4
192
442
692
942

I did in O(1) for single test case.
Observe the pattern in the op. U will definitely get it.
Stills Doubts, then contact Spoj forum.

Last edit: 2015-03-27 20:16:36
Tony T.: 2015-03-26 08:02:05

For c++ I had to use long long to meet the 2000000000000 limit

Maverick: 2015-03-15 17:24:11

those using JAVA, there's no need to use BigInteger. long is more than enough.Just think.

Last edit: 2015-03-15 17:24:32

Added by:Matthew Reeder
Date:2006-10-30
Time limit:1.197s
Source limit:30000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:Al-Khawarizm 2006