CRZYSMKR - Crazy Smoker

The "BHAI Group" Of IIIT Allahabad is Famous For Many Things, Leading in Every Field Of College Activity

So One Day The Leader Of Bhai Group decided to smoke C(N) cigarettes each day:

- F(N) = 34^N+ (30 x N) + 32

- C(N) = F(N) mod (11), where x mod y is the remainder obtained by dividing x by y.

But Bhai Group's Leader's Girlfriend wants that he doesn't smoke any cigarette, so she made modifications:

- F(N) = 34^N+ (30 x N) + (32 + M)

- C(N) = F(N) mod (11)

Edit 1 : Time limit set to 0.100s

Problem Credits : IIIT Allahabad HE Club

Input

First line of each test case is an integer T, total number of test cases. Next T lines contains a single integer N.

Output

Print the minimum value of M in single line for each test case.

Constraints

1 <= T <= 10^6

1 <= N <= 10^18

Example

Input:
2
1
2

Output:
3
6
Explanation:
For N = 1
F(N) = 34 + 30 + 32 = 96
So, M = 3
Now, C(N) = 99 mod(11) = 0
For N = 2
F(N) = 1156 + 60 + 32 = 1248
So, M = 6
Now, C(N) = 1254 mod(11) = 0

Added by:Siddharth Singh
Date:2016-02-10
Time limit:0.100s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 GOSU JS-MONKEY
Resource:HackerEarth Contest Of IIIT Allahabad

hide comments
2016-02-16 10:07:49
<snip>
code is running fine in ideone,
but when i submit its shows as wrong ... Help Please ...

NumeriX : Kindly See The Constraints, 34^(10^6) goes beyond C's limit


Last edit: 2022-06-19 16:49:12
2016-02-14 04:47:13
Done it without any Modular exponential :D ...

Last edit: 2016-03-19 14:08:30
2016-02-13 19:45:28 Arnab Animesh Das
Very easy. Explanation gives away the logic without even needing to understand the problem statement.
2016-02-13 14:00:07
it says TLE...is there a better way for calculating powers in python rather than using the usual '**' operator
2016-02-11 18:28:26 kataria
esay one....
2016-02-11 10:51:14
care about zero.......... when modulus of c(n) is already zero ......its cause me many wa.

NumeriX : Hope You Liked It.
farhan:-ya,absolutely i liked it.........it's nice problem@numerix

Last edit: 2016-02-11 13:29:16
2016-02-11 10:50:49
bhai group(BBC..) rockzzz....very nice question

NumeriX : Hahah, Thanks.

Last edit: 2016-02-11 10:51:50
2016-02-10 19:32:51
internal error..............please solve this problem
NumeriX : Surely , Looking Into It , Sorry For The Inconvenience Caused

Last edit: 2016-02-11 09:04:26
2016-02-10 16:15:31 Vipul Srivastava
internal error
@NumeriX please look into it...

NumeriX : Surely , Looking Into It , Sorry For The Inconvenience Caused

Last edit: 2016-02-11 09:04:07
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.