Problem: We know that lucky digits are digits 4 and 7, however Vasya's got another favorite digit 0 and he assumes it also is lucky! Lucky numbers are such non-negative integers whose decimal record only contains lucky digits. For example, numbers 0, 47, 7074 are lucky, but 1, 7377, 895,  -7 are not.

Vasya has t important positive integers he needs to remember. Vasya is quite superstitious and he wants to remember lucky numbers only, so he is asking you for each important number to represent it as a sum of exactly six lucky numbers (Vasya just can't remember more numbers). Then Vasya can just remember these six numbers and calculate the important number at any moment.

For each of t important integers represent it as the sum of six lucky numbers or state that this is impossible.

Input

The first line contains a single integer t (1 ≤ t ≤ 5000).

Next t lines contain a single positive integer ni (1 ≤ ni ≤ 1018) — the list of important numbers.

Please, do not use the %lld to read or write 64-bit integers С++. It is preferred to read the cin, cout streams or the %I64d specifier.

Output

Print t lines. The i-th line must contain the answer for the i-th important number: if the solution exists, the line must contain exactly six lucky numbers the sum of which equals ni, if the solution doesn't exist the string must contain a single integer -1.

If there are multiple answers print any of them.

Examples

Input

5
42
17
444
7
51


Output

7 7 7 7 7 7
-1
400 0 40 0 4 0
7 0 0 0 0 0
47 4 0 0 0 0

Solution (in JAVA):

Solution:
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        // BEGIN initialize singles array
        int[] temp = new int[3];
        temp[0] = 0;
        temp[1] = 4;
        temp[2] = 7;
        HashMap<Integer, ArrayList<Integer>> singles = new HashMap<Integer, ArrayList<Integer>>();
        for (int i = 0; i < 43; i++) {
            if (!singles.containsKey(i)) {
                for (int j = 0; j < 3; j++) {
                    if (!singles.containsKey(i)) {
                        for (int k = j; k < 3; k++) {
                            if (!singles.containsKey(i)) {
                                for (int l = k; l < 3; l++) {
                                    if (!singles.containsKey(i)) {
                                        for (int m = l; m < 3; m++) {
                                            if (!singles.containsKey(i)) {
                                                for (int n = m; n < 3; n++) {
                                                    if (!singles.containsKey(i)) {
                                                        for (int o = n; o < 3; o++) {
                                                            if (temp[j]
                                                                    + temp[k]
                                                                    + temp[l]
                                                                    + temp[m]
                                                                    + temp[n]
                                                                    + temp[o] == i) {
                                                                if (!singles
                                                                        .containsKey(i)) {
                                                                    ArrayList tempList = new ArrayList<Integer>();
                                                                    tempList.add(temp[j]);
                                                                    tempList.add(temp[k]);
                                                                    tempList.add(temp[l]);
                                                                    tempList.add(temp[m]);
                                                                    tempList.add(temp[n]);
                                                                    tempList.add(temp[o]);
                                                                    singles.put(
                                                                            i,
                                                                            tempList);
                                                                } else {
                                                                    o = 3;
                                                                }
                                                            }
                                                        }
                                                    } else {
                                                        n = 3;
                                                    }
                                                }
                                            } else {
                                                m = 3;
                                            }
                                        }
                                    } else {
                                        l = 3;
                                    }
                                }
                            } else {
                                k = 3;
                            }
                        }
                    } else {
                        j = 3;
                    }
                }
            }
        }
        // END initialize singles array
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        for (int i = 0; i < t; i++) {
            char[] nString = in.next().toCharArray();
            int[] n = new int[nString.length];
            for (int j = 0; j < n.length; j++) {
                n[j] = Character.digit(nString[j], 10);
            }
            ArrayList<Integer> able = new ArrayList<Integer>();
            boolean foundIt = false;
            if (n[0] - 8 <= 4 && n[0] - 8 >= 0) {
                able.add(8);
            }
            if (n[0] - 7 <= 4 && n[0] - 7 >= 0) {
                able.add(7);
            }
            if (n[0] - 4 <= 4 && n[0] - 4 >= 0) {
                able.add(4);
            }
            if (n[0] - 0 <= 4 && n[0] - 0 >= 0) {
                able.add(0);
            }
            if(n.length > 1){
            ArrayList<Integer> answer = new ArrayList<Integer>();
            for (int j = 0; j < able.size(); j++) {
                int tens = n[0] - able.get(j);
                if (!foundIt) {
                    foundIt = f(n, tens, singles, 1, answer);
                    if (foundIt) {
                        answer.add(able.get(j));
                    }
                }
            }
            if (!foundIt) {
                System.out.println(-1);
            } else {
                long[] finalAnswer = new long[6];
                for (int j = 0; j < 6; j++) {
                    for (int k = 0; k < n.length; k++) {
                        finalAnswer[j] += singles.get(answer.get(k)).get(j)
                                * (long)Math.pow(10, k);
                    }
                    System.out.print(finalAnswer[j] + " ");
                }
            }
            }
            else{
                if(!singles.containsKey(n[0])){
                    System.out.println(-1);
                }
                else{
                    for(int j = 0; j < 6; j++){
                        System.out.print(singles.get(n[0]).get(j) + " ");
                    }
                }
            }
        }
    }

    public static boolean f(int[] n, int tens,
            HashMap<Integer, ArrayList<Integer>> singles, int current,
            ArrayList<Integer> answer) {
        boolean foundIt = false;

        if (current + 1 == n.length) {
            int tempNumber = tens * 10 + n[current];
            if (singles.containsKey(tempNumber)) {
                answer.add(tempNumber);
                return true;
            }
            return false;
        }

        ArrayList<Integer> able = new ArrayList<Integer>();
        for (int i = 0; i < 6 && i <= n[current]; i++) {
            int tempNumber = tens * 10 + n[current] - i;
            if (singles.containsKey(tempNumber)) {
                able.add(n[current] - i);
            }
        }
        int singlesDigit = 0;
        for (int i = 0; i < able.size(); i++) {
            if (!foundIt) {
                foundIt = f(n, n[current] - able.get(i), singles, current + 1,
                        answer);
                if (foundIt) {
                    singlesDigit = able.get(i);
                }
            }
        }
        // BEGIN take one and add 10
        if (!foundIt) {
            if (tens > 0) {
                tens -= 1;
                int tempDigit = n[current] + 10;
                able.clear();
                // BEGIN find able again
                for (int i = 0; i < 6 && i <= tempDigit; i++) {
                    if (tempDigit - i < 10) {
                        int tempNumber = tens * 10 + tempDigit - i;
                        if (singles.containsKey(tempNumber)) {
                            able.add(tempDigit - i);
                        }
                    }
                }
                // END find able again
                for (int i = 0; i < able.size(); i++) {
                    if (!foundIt) {
                        foundIt = f(n, tempDigit - able.get(i), singles,
                                current + 1, answer);
                        if (foundIt) {
                            singlesDigit = able.get(i);
                        }
                    }
                }
            }
        }
        // END take one and add 10
        if (foundIt) {
            answer.add(tens * 10 + singlesDigit);
        }
        return foundIt;
    }

}