Under construction

Still being built. Things may change

n, 3n, 5n

Time limit2sMemory limit1024 MB

Summary
For each query i, find the i-th term of the lexicographically smallest increasing sequence where each positive integer n has exactly one of n, 3n, and 5n in the sequence.
Level

Medium6 of 10

Topics
Number theory, Greedy, Math
Solved
No attempts yet

Problem

An infinite increasing sequence aia_i of distinct positive integers is the lexicographically smallest sequence that satisfies the following property.

  • For every positive integer nn, exactly one of nn, 3n3n, and 5n5n appears in the sequence.

Given a positive integer ii, find the value of aia_i.

Input

The first line contains the number of test cases TT (1≤T≤100 0001\le T\le 100\,000). Each of the next TT lines contains one value of ii (1≤i≤100 0001\le i\le 100\,000).

Output

Print TT lines. For each ii, print aia_i on its own line.

Examples1

  1. Example 1

    Input
    3
    1
    2
    3
    
    Expected output
    1
    2
    4