import java.io.*;
import java.util.*;

public class packing_as implements Runnable {
    String toHex(long l) {
        int k = (int) l;
        return "" + "0123456789abcdef".charAt(k / 16) + "0123456789abcdef".charAt(k % 16);
    }

    public void writePackedInt(StringBuilder s, long v) throws IOException {
    	long t = 1L << 6;
    	int bnum = 0;
    	byte lead = 0;
    	while (!(-t <= v && v < t) && bnum < 8) {
    		t <<= 7;
    		bnum++;
    		lead |= 1 << (8 - bnum);
    	}
    	s.append(toHex(0xff & (lead | (((v >>> (bnum << 3))) & ~ (1 << (7 - bnum))))));
    	for (int i = 1; i <= bnum; i++) {
    		s.append(toHex((0xff & (v >>> ((bnum - i) << 3)))));
    	}
        s.append("\n");
    }

    public void solve() throws IOException {
        Scanner in = new Scanner(new File("packing.in"));
        PrintWriter out = new PrintWriter("packing.out");

        int n = in.nextInt();
        StringBuilder answer = new StringBuilder();
        for (int i = 0; i < n; i++) {
            writePackedInt(answer, in.nextLong());
        }

        out.print(answer.toString());

        in.close();
        out.close();
    }

    public void run() {
        try {
            solve();
        } catch (IOException e) {
        }
    }

    public static void main(String[] arg) {
        new Thread(new packing_as()).start();
    }
}