#arc123c. [arc123_c]1, 2, 3 - Decomposition

[arc123_c]1, 2, 3 - Decomposition

Problem Statement

Given is a positive integer NN. Consider a sequence of integers A=(A1,ldots,AK)A = (A_1, \\ldots, A_K) that satisfies the conditions below:

  • sumi=1KAi=N\\sum_{i=1}^K A_i = N;
  • each AiA_i is a positive integer such that every digit in its decimal notation is 11, 22, or 33.

Find the minimum possible value of KK, that is, the number of elements in such a sequence AA.

Process TT test cases per input file.

Constraints

  • 1leqTleq10001\\leq T\\leq 1000
  • 1leqNleq10181\\leq N\\leq 10^{18}

Input

Input is given from Standard Input in the following format:

TT textcase1\\text{case}_1 textcase2\\text{case}_2 vdots\\vdots textcaseT\\text{case}_T

Each case is in the following format:

NN

Output

Print the answers.


Sample Input 1

5
456
10000
123
314
91

Sample Output 1

2
4
1
2
4

For each NN, one optimal AA is shown below.

  • For N=456N = 456: A=(133,323)A = (133, 323).
  • For N=10000N = 10000: A=(323,3132,3232,3313)A = (323, 3132, 3232, 3313).
  • For N=123N = 123: A=(123)A = (123).
  • For N=314N = 314: A=(312,2)A = (312,2).
  • For N=91N = 91: A=(22,23,23,23)A = (22,23,23,23).