This page is still under construction.

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

Last three digits of (3 + √5)^n

Time limit5sMemory limit512 MB

Summary
Compute the last three digits before the decimal point of (3 + sqrt(5))^n for n up to two billion.
Level

Medium6 of 10

Topics
Math, Number theory, Dynamic programming
Solved
No attempts yet

Problem

Given a positive integer nn, find the last three digits before the decimal point of (3+5)n(3 + \sqrt{5})^n.

For example, when n=5n = 5, (3+5)5=3935.73982…(3 + \sqrt{5})^5 = 3935.73982\ldots, so the answer is 935. When n=2n = 2, (3+5)2=27.4164079…(3 + \sqrt{5})^2 = 27.4164079\ldots, so the answer is 027.

Input

The first line holds the number of test cases TT.

Each of the next TT lines holds one positive integer nn.

Output

For each test case print one line in this format.

Case #X: Y

XX is the test case number starting from 1, and YY is the last three digits before the decimal point of (3+5)n(3 + \sqrt{5})^n. If the integer part has fewer than three digits, pad it with leading zeros so that the output always has exactly three digits.

Constraints

  • 1≤T≤1001 \le T \le 100
  • 2≤n≤20000000002 \le n \le 2000000000

Examples2

  1. Example 1

    Input
    2
    5
    2
    
    Expected output
    Case #1: 935
    Case #2: 027
    
  2. Example 2

    Input
    10
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    
    Expected output
    Case #1: 027
    Case #2: 143
    Case #3: 751
    Case #4: 935
    Case #5: 607
    Case #6: 903
    Case #7: 991
    Case #8: 335
    Case #9: 047
    Case #10: 943