樹枝排數字


Submit solution

Points: 100
Time limit: 2.0s
Memory limit: 512M

Authors:
Problem types

松鼠撿到\(K\)枝樹枝,他想試試看如果他挖\(N\)個排成一列的洞並且使用全部樹枝的情況下,他能排出多大的十進位數字?

(每個洞皆可排0-7枝樹枝來表示數字,像七段顯示器。但有樹枝的洞必須連續,否則該答案無效)

提醒:樹枝必須全部用完

各數字表現方法

Input

第一行一個整數 \(T\),代表測資筆數

\(T \le 10000\)

一行兩個整數 \(N,K\)

\(1\le N \le1000000 \)

\(2\le K \le 7N \)

單筆測資中 \(N\) 的總和不超過 \(1000000\)

Output

最大可排出的數字

Constraints

第 \(1\) 組測資, \(N\le 6\)。 \((5\text{%})\)

第 \(2\) 組測資, \(K \le 3 \times N\)。\((15\text{%})\)

第 \(3\) 組測資, \(6 \times N\le K\)。\((15\text{%})\)

第 \(4\) 組測資, \(N \le 10^3\)。\((30\text{%})\)

第 \(5\) 組測資, 沒有其他限制。\((35\text{%})\)

Sample Input
4
1 2
1 6
1 7
2 12
Sample Output
1
9
8
99

Comments

There are no comments at the moment.