CF BUDDY
← Problems·

1202D · Print a 1337-string...

1900 · combinatorics, constructive algorithms, math

Problem: The subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.

You are given an integer nn.

You have to find a sequence ss consisting of digits {1,3,7}\{1, 3, 7\} such that it has exactly nn subsequences equal to 13371337.

For example, sequence 337133377337133377 has 66 subsequences equal to 13371337:

  1. 337133377337\underline{1}3\underline{3}\underline{3}7\underline{7} (you can remove the second and fifth characters);
  2. 337133377337\underline{1}\underline{3}3\underline{3}7\underline{7} (you can remove the third and fifth characters);
  3. 337133377337\underline{1}\underline{3}\underline{3}37\underline{7} (you can remove the fourth and fifth characters);
  4. 337133377337\underline{1}3\underline{3}\underline{3}\underline{7}7 (you can remove the second and sixth characters);
  5. 337133377337\underline{1}\underline{3}3\underline{3}\underline{7}7 (you can remove the third and sixth characters);
  6. 337133377337\underline{1}\underline{3}\underline{3}3\underline{7}7 (you can remove the fourth and sixth characters).

Note that the length of the sequence ss must not exceed 10510^5.

You have to answer tt independent queries.

Input Format: The first line contains one integer tt (1t101 \le t \le 10) — the number of queries.

Next tt lines contains a description of queries: the ii-th line contains one integer nin_i (1ni1091 \le n_i \le 10^9).

Output Format: For the ii-th query print one string sis_i (1si1051 \le |s_i| \le 10^5) consisting of digits {1,3,7}\{1, 3, 7\}. String sis_i must have exactly nin_i subsequences 13371337. If there are multiple such strings, print any of them.

Sample Cases

Case 1

Input

2
6
1

Output

113337
1337

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback