import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class C {
    public static void main(String[] args) throws Exception {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        int t = Integer.parseInt(buffer.readLine());
        while (t-- > 0) {
            int n = Integer.parseInt(buffer.readLine());
            ArrayList<Integer>list = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                int a = Integer.parseInt(buffer.readLine());
                if (a == 1)
                    list.add(1);
                else {
                    for (int j = list.size()-1; j >= 0; j--) {
                        if (list.get(j)+1 == a)
                            break;
                        list.remove(list.size()-1);
                    }
                    list.remove(list.size()-1);
                    list.add(a);
                }
                for (int j = 0; j < list.size(); j++) {
                    sb.append(list.get(j));
                    if (j == list.size()-1)
                        sb.append("\n");
                    else
                        sb.append(".");
                }
            }
        }
        System.out.println(sb);
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.util.Deque;
import java.util.ArrayList;
import java.io.UncheckedIOException;
import java.util.List;
import java.io.Closeable;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.ArrayDeque;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 29);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastInput in = new FastInput(inputStream);
            FastOutput out = new FastOutput(outputStream);
            CCompressionAndExpansion solver = new CCompressionAndExpansion();
            int testCount = Integer.parseInt(in.next());
            for (int i = 1; i <= testCount; i++)
                solver.solve(i, in, out);
            out.close();
        }
    }

    static class CCompressionAndExpansion {
        Node end = new Node(null, -1);
        FastOutput out;

        public void solve(int testNumber, FastInput in, FastOutput out) {
            int n = in.ri();

            List<Node> seq = new ArrayList<>(n);
            Deque<Node> dq = new ArrayDeque<>(n);
            end = new Node(null, -1);
            dq.addLast(end);
            for (int i = 0; i < n; i++) {
                int x = in.ri();
                while (true) {
                    Node last = dq.peekLast();
                    if (last.nextChild != x) {
                        dq.removeLast();
                        continue;
                    }
                    last.nextChild++;
                    dq.addLast(new Node(dq.peekLast(), x));
                    break;
                }
                seq.add(dq.peekLast());
            }

            this.out = out;
            for (Node node : seq) {
                print(node);
                out.println();
            }
        }

        void print(Node root) {
            if (root.p != end) {
                print(root.p);
                out.append('.');
            }
            out.append(root.index);
        }

    }

    static class FastInput {
        private final InputStream is;
        private StringBuilder defaultStringBuf = new StringBuilder(1 << 13);
        private byte[] buf = new byte[1 << 13];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastInput(InputStream is) {
            this.is = is;
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    bufLen = -1;
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public String next() {
            return readString();
        }

        public int ri() {
            return readInt();
        }

        public int readInt() {
            boolean rev = false;

            skipBlank();
            if (next == '+' || next == '-') {
                rev = next == '-';
                next = read();
            }

            int val = 0;
            while (next >= '0' && next <= '9') {
                val = val * 10 - next + '0';
                next = read();
            }

            return rev ? val : -val;
        }

        public String readString(StringBuilder builder) {
            skipBlank();

            while (next > 32) {
                builder.append((char) next);
                next = read();
            }

            return builder.toString();
        }

        public String readString() {
            defaultStringBuf.setLength(0);
            return readString(defaultStringBuf);
        }

    }

    static class Node {
        Node p;
        int index;
        int nextChild = 1;

        public Node(Node p, int index) {
            this.p = p;
            this.index = index;
        }

    }

    static class FastOutput implements AutoCloseable, Closeable, Appendable {
        private static final int THRESHOLD = 32 << 10;
        private final Writer os;
        private StringBuilder cache = new StringBuilder(THRESHOLD * 2);

        public FastOutput append(CharSequence csq) {
            cache.append(csq);
            return this;
        }

        public FastOutput append(CharSequence csq, int start, int end) {
            cache.append(csq, start, end);
            return this;
        }

        private void afterWrite() {
            if (cache.length() < THRESHOLD) {
                return;
            }
            flush();
        }

        public FastOutput(Writer os) {
            this.os = os;
        }

        public FastOutput(OutputStream os) {
            this(new OutputStreamWriter(os));
        }

        public FastOutput append(char c) {
            cache.append(c);
            afterWrite();
            return this;
        }

        public FastOutput append(int c) {
            cache.append(c);
            afterWrite();
            return this;
        }

        public FastOutput println() {
            return append('\n');
        }

        public FastOutput flush() {
            try {
//            boolean success = false;
//            if (stringBuilderValueField != null) {
//                try {
//                    char[] value = (char[]) stringBuilderValueField.get(cache);
//                    os.write(value, 0, cache.length());
//                    success = true;
//                } catch (Exception e) {
//                }
//            }
//            if (!success) {
                os.append(cache);
//            }
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
            return this;
        }

        public void close() {
            flush();
            try {
                os.close();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }

        public String toString() {
            return cache.toString();
        }

    }
}


import java.util.StringTokenizer;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.io.IOException;
import java.io.BufferedReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;

public class p3
{
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
				br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next()
		{
				while (st == null || !st.hasMoreElements()) {
						try {
								st = new StringTokenizer(br.readLine());
						}
						catch (IOException e) {
								e.printStackTrace();
						}
				}
				return st.nextToken();
		}

		int nextInt() { return Integer.parseInt(next()); }

		byte nextByte() { return Byte.parseByte(next()); }

		short nextShort() { return Short.parseShort(next()); }

		long nextLong() { return Long.parseLong(next()); }

		double nextDouble()	{	return Double.parseDouble(next());	}

		String nextLine()
		{
				String str = "";
				try {
						str = br.readLine();
				}
				catch (IOException e) {
						e.printStackTrace();
				}
				return str;
		}
	}

	public static void main(String[] args)
	{
		FastReader fr=new FastReader();

		byte t=fr.nextByte();
		while(t-->0)
		{
			short n=fr.nextShort();
			short a[]=new short [n];
			for (short i=-1;++i<n;)
				a[i]=fr.nextShort();

			String s="1";
			System.out.println(s);

			for(short i=0;++i<n;)
			{
				if(a[i]==1)
				{
					s+=".1";
					System.out.println(s);
				}
				else if(a[i]==a[i-1]+1)
				{
					int c=s.lastIndexOf(".");
					s=s.substring(0,c+1)+a[i];
					System.out.println(s);
				}
				else
				{
					for(;;)
					{
						s=s.substring(0,s.lastIndexOf("."));
						int c=s.lastIndexOf(".");

						int b=Integer.parseInt(s.substring(c+1,s.length()));
						if(b+1==a[i])
						{
							s=s.substring(0,c+1)+a[i];
							System.out.println(s);
							break;
						}
					}
				}
			}
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

@SuppressWarnings("unused")
public class C{

	static long inf = (long)1e15;

    public static void main(String[] args) throws IOException {

    	FastScanner fs = new FastScanner();
    	PrintWriter out = new PrintWriter(System.out);

    	int tt = fs.nextInt();
    	outer:
    	while(tt-->0) {

    		int n = fs.nextInt();
    		int[] a = fs.readArray(n);

    		ArrayList<Integer>[] l = new ArrayList[n];
    		for(int i=0;i<n;i++) l[i] = new ArrayList<Integer>();

    		l[0].add(1);

    		for(int i=1;i<n;i++) {
    			if(a[i]==1) {
    				for(int j=0;j<l[i-1].size();j++) l[i].add(l[i-1].get(j));
    				l[i].add(1);
    			}
    			else {
    				int ind = -1;
    				for(int j=l[i-1].size()-1;j>=0;j--) {
    					if(l[i-1].get(j)+1==a[i]) {
    						ind = j; break;
    					}
    				}
    				for(int j=0;j<ind;j++) l[i].add(l[i-1].get(j));
    				l[i].add(a[i]);
    			}
    		}

    		for(int i=0;i<n;i++) {
    			out.print(l[i].get(0));
    			for(int j=1;j<l[i].size();j++) out.print("."+l[i].get(j));
    			out.println();
    		}

    	}

    	out.close();

    }

    static final Random random=new Random();

    static <T> void shuffle(T[] arr) {
    	int n = arr.length;
    	for(int i=0;i<n;i++	) {
    		int k = random.nextInt(n);
    		T temp = arr[k]; arr[k] = arr[i]; arr[i] = temp;
    	}
    }

    static void ruffleSort(int[] a) {
    	int n=a.length;//shuffle, then sort
    	for (int i=0; i<n; i++) {
    		int oi=random.nextInt(n); int temp=a[oi];
    		a[oi]=a[i]; a[i]=temp;
    	}
    	Arrays.sort(a);
    }

    static void ruffleSort(long[] a) {
    	int n=a.length;//shuffle, then sort
    	for (int i=0; i<n; i++) {
    		int oi=random.nextInt(n); long temp=a[oi];
    		a[oi]=a[i]; a[i]=temp;
    	}
    	Arrays.sort(a);
    }

    static void reverse(int[] arr, int l, int r) {
    	for(int i=l;i<l+(r-l)/2;i++){
    		int temp = arr[i]; arr[i] = arr[r-i+l-1]; arr[r-i+l-1] = temp;
    	}
    }

    static void reverse(long[] arr, int l, int r) {
    	for(int i=l;i<l+(r-l)/2;i++){
    		long temp = arr[i]; arr[i] = arr[r-i+l-1]; arr[r-i+l-1] = temp;
    	}
    }

    static <T> void reverse(T[] arr, int l, int r) {
    	for(int i=l;i<l+(r-l)/2;i++) {
    		T temp = arr[i]; arr[i] = arr[r-i+l-1]; arr[r-i+l-1] = temp;
    	}
    }

    static class FastScanner{
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	StringTokenizer st = new StringTokenizer("");

    	public String next(){
    		while(!st.hasMoreElements()){
    			try{
    				st = new StringTokenizer(br.readLine());
    			} catch(IOException e){
    				e.printStackTrace();
    			}
    		}
    		return st.nextToken();
    	}

    	public String nextLine() throws IOException {
    		return br.readLine();
    	}

    	public int nextInt(){
    		return Integer.parseInt(next());
    	}

    	public int[] readArray(int n){
    		int[] a = new int[n];
    		for(int i=0;i<n;i++)
    			a[i] = nextInt();
    		return a;
    	}

    	public long nextLong() {
    		return Long.parseLong(next());
    	}

    	public double nextDouble() {
    		return Double.parseDouble(next());
    	}

    	public char nextChar() {
    		return next().toCharArray()[0];
    	}

    }

}


import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Stack;

public class C {
	private static PrintWriter out = new PrintWriter(System.out);

	public static void solve() {
		In in = new In();
		int tests = in.ni();
		while (tests-- > 0) {
			int n = in.ni();
			int[] a = in.nia(n);
			Stack<Integer> st = new Stack<>();
			StringBuilder sb = new StringBuilder();
			for (int num : a) {
//				System.out.println("Checking " + num);
				if (st.isEmpty()) {
					st.push(num);
					sb.append(num);
				} else {
					// increment current level
					if (num == st.peek() + 1) {
						st.pop();
						st.push(num);

						while (sb.length() > 0 && sb.charAt(sb.length() - 1) != '.') {
							sb.deleteCharAt(sb.length() - 1);
						}
						sb.append(num);
					}
					// expand current level by 1
					else if (num == 1) {
						st.push(num);
						sb.append(".");
						sb.append(num);
					}
					// increment higher level
					else {
						// search which higher level is the previous of the current number
						while (!st.isEmpty() && st.peek() + 1 != num) {
							st.pop();
							while (sb.length() > 0 && sb.charAt(sb.length() - 1) != '.') {
								sb.deleteCharAt(sb.length() - 1);
							}
							if (sb.length() > 0)
								sb.deleteCharAt(sb.length() - 1);
						}

//						System.out.println(" " + st.toString() + " " + sb.toString());
						if (!st.isEmpty() && st.peek() + 1 == num) {
							st.pop();
							st.add(num);
							while (sb.length() > 0 && sb.charAt(sb.length() - 1) != '.') {
								sb.deleteCharAt(sb.length() - 1);
							}
							sb.append(num);
						}
					}
				}
//				System.out.println(">>" + st.toString());
				out.println(sb);
			}
		}
	}

	public static void main(String[] args) throws IOException {
		// long start = System.nanoTime();
		solve();
		// System.out.println("Elapsed: " + (System.nanoTime() - start) / 1000000 +
		// "ns");
		out.flush();
	}

	@SuppressWarnings("unused")
	private static class In {
		final private static int BUFFER_SIZE = 1024;
		private byte[] buf;
		private InputStream is;
		private int buflen;
		private int bufptr;

		public In() {
			is = System.in;
			buf = new byte[BUFFER_SIZE];
			buflen = bufptr = 0;
		}

		public In(String input) {
			is = new ByteArrayInputStream(input.getBytes());
			buf = new byte[BUFFER_SIZE];
			buflen = bufptr = 0;
		}

		public int readByte() {
			if (bufptr >= buflen) {
				try {
					buflen = is.read(buf);
				} catch (IOException ioe) {
					throw new InputMismatchException();
				}
				bufptr = 0;
			}
			if (buflen <= 0)
				return -1;
			return buf[bufptr++];
		}

		public boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		public int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		}

		/* Next character */
		public char nc() {
			return (char) skip();
		}

		/* Next double */
		public double nd() {
			return Double.parseDouble(ns());
		}

		/* Next string */
		public String ns() {
			final StringBuilder sb = new StringBuilder();
			int b = skip();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		/* Next integer */
		public int ni() {
			boolean minus = false;
			int num = 0;
			int b;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			while (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
				b = readByte();
			}
			return minus ? -num : num;
		}

		/* Next long */
		public long nl() {
			boolean minus = false;
			long num = 0;
			int b;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			while (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
				b = readByte();
			}
			return minus ? -num : num;
		}

		/* Next integer 1D array */
		public int[] nia(int n) {
			final int[] arr = new int[n];
			for (int i = 0; i < n; i++)
				arr[i] = ni();
			return arr;
		}

		/* Next long 1D array */
		public long[] nla(int n) {
			final long[] arr = new long[n];
			for (int i = 0; i < n; i++)
				arr[i] = nl();
			return arr;
		}

		/* Next string 1D array */
		public String[] nsa(int n) {
			final String[] arr = new String[n];
			for (int i = 0; i < n; i++)
				arr[i] = ns();
			return arr;
		}

		/* Next char 1D array */
		public char[] nca(int n) {
			final char[] arr = new char[n];
			for (int i = 0; i < n; i++)
				arr[i] = nc();
			return arr;
		}

		/* Next double 1D array */
		public double[] nda(int n) {
			final double[] arr = new double[n];
			for (int i = 0; i < n; i++)
				arr[i] = nc();
			return arr;
		}

		/* Next integer matrix */
		public int[][] nim(int n, int m) {
			final int[][] arr = new int[n][m];
			for (int i = 0; i < n; i++)
				for (int j = 0; j < m; j++)
					arr[i][j] = ni();
			return arr;
		}

		/* Next long matrix */
		public long[][] nlm(int n, int m) {
			final long[][] arr = new long[n][m];
			for (int i = 0; i < n; i++)
				for (int j = 0; j < m; j++)
					arr[i][j] = nl();
			return arr;
		}

		/* Next string matrix */
		public String[][] nsm(int n, int m) {
			final String[][] arr = new String[n][m];
			for (int i = 0; i < n; i++)
				for (int j = 0; j < m; j++)
					arr[i][j] = ns();
			return arr;
		}

		/* Next char matrix */
		public char[][] ncm(int n, int m) {
			final char[][] arr = new char[n][m];
			for (int i = 0; i < n; i++)
				for (int j = 0; j < m; j++)
					arr[i][j] = nc();
			return arr;
		}

		/* Next double matrix */
		public double[][] ndm(int n, int m) {
			final double[][] arr = new double[n][m];
			for (int i = 0; i < n; i++)
				for (int j = 0; j < m; j++)
					arr[i][j] = nd();
			return arr;
		}

		public static void log(Object... o) {
			System.out.println(Arrays.deepToString(o));
		}
	}

}


/*
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀⢠⠞⠉⠙⠲⡀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀⡏⠀⠀Y⠀⠀⢷
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀⢸⠀⠀A⠀⠀ ⡇
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀⣸⠀⠀S⠀  ⡇
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀⢹⠀⠀H⠀⠀ ⡇
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀⡇⠀⠀⠀⠀⡼
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀⠘⠤⣄⣠⠞
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸
⣿⣿⣧⣀⣿………⣀⣰⣏⣘⣆⣀
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter; // System.out is a PrintStream
// import java.util.Arrays;
import java.util.ArrayDeque;
// import java.util.ArrayList;
// import java.util.Collections;    //  for sorting ArrayList mainly
// import java.util.HashMap;
// import java.util.HashSet;
// import java.util.Random;
import java.util.StringTokenizer;

public class C {
    public static void main(String[] args) throws IOException {
        FastScanner scn = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        for (int tc = scn.nextInt(); tc > 0; tc--) {
            int N = scn.nextInt();
            int[] arr = new int[N];
            for (int i = 0; i < N; i++) {
                arr[i] = scn.nextInt();
            }
            StringBuilder[] ans = new StringBuilder[N];
            ans[0] = new StringBuilder("1");
            ArrayDeque<Integer> st = new ArrayDeque<>();
            st.addLast(0);
            for (int i = 1; i < N; i++) {
                // System.out.println(st);
                ans[i] = new StringBuilder();
                if (arr[i] == 1) {
                    st.addLast(i);
                    ans[i].append(ans[i - 1].toString() + ".1");
                } else {
                    while (arr[st.getLast()] != arr[i] - 1) {
                        st.removeLast();
                    }
                    int pos = st.removeLast();
                    String[] prev = ans[pos].toString().split("[.]");
                    for (int j = 0, sz = prev.length - 1; j < sz; j++) {
                        ans[i].append(prev[j] + ".");
                    }
                    ans[i].append(arr[i] + "");
                    st.addLast(i);
                }
            }
            for (StringBuilder str : ans) {
                out.println(str);
            }
        }
        out.close();
    }

    private static int gcd(int num1, int num2) {
        int temp = 0;
        while (num2 != 0) {
            temp = num1;
            num1 = num2;
            num2 = temp % num2;
        }
        return num1;
    }

    private static int lcm(int num1, int num2) {
        return (int)((1L * num1 * num2) / gcd(num1, num2));
    }

    private static void ruffleSort(int[] arr) {
        // int N = arr.length;
        // Random rand = new Random();
        // for (int i = 0; i < N; i++) {
        //     int oi = rand.nextInt(N), temp = arr[i];
        //     arr[i] = arr[oi];
        //     arr[oi] = temp;
        // }
        // Arrays.sort(arr);
    }

    private static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner() {
            this.br = new BufferedReader(new InputStreamReader(System.in));
            this.st = new StringTokenizer("");
        }

        String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException err) {
                    err.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            if (st.hasMoreTokens()) {
                return st.nextToken("").trim();
            }
            try {
                return br.readLine().trim();
            } catch (IOException err) {
                err.printStackTrace();
            }
            return "";
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashSet;

public class Solution {
    public static void main(String[] args)throws IOException {
        FastReader in=new FastReader(System.in);
        int t=in.nextInt();
        StringBuilder sb=new StringBuilder();
        int i,j,tc=0;
        while(tc++<t) {
            int n=in.nextInt();
            int arr[]=new int[n];
            for(i=0;i<n;i++)
                arr[i]=in.nextInt();
            int ans[]=new int[n+4];
            ans[0]=1;
            int pos=0;
            sb.append("1\n");
            for(i=1;i<n;i++){
                if(arr[i]==arr[i-1]+1){
                    ans[pos]=ans[pos]+1;
                }
                else if(arr[i]==1){
                    pos++;
                    ans[pos]=1;
                }
                else{
                    while(ans[pos]!=arr[i]-1)
                        pos--;
                    ans[pos]=ans[pos]+1;
                }
                for(j=0;j<=pos;j++){
                    if(j<pos)
                        sb.append(ans[j]).append(".");
                    else
                        sb.append(ans[j]).append("\n");
                }

            }
        }
        System.out.println(sb);
    }
}

class Node {
    int setroot, dist;
    public Node(int setroot, int dist){
        this.setroot = setroot;
        this.dist = dist;
    }
    @Override
    public String toString() {
        return String.format(setroot + ", " + dist);
    }
}

class FastReader {

    byte[] buf = new byte[2048];
    int index, total;
    InputStream in;

    FastReader(InputStream is) {
        in = is;
    }

    int scan() throws IOException {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0) {
                return -1;
            }
        }
        return buf[index++];
    }

    String next() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }

    int nextInt() throws IOException {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }

    long nextLong() throws IOException {
        int c;
        long val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }
}


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

public class Main implements Runnable {

    final static int mod = 1000000007;
    static FastReader sc;
    static PrintWriter out;
    static boolean test_case_input = true;
    static final int MAX = 1000000000;
    static final int MIN = -1000000000;

    public static void print(int a[], int point) {
        out.print(a[1]);
        for(int i = 2; i <= point; i++) {
            out.print("." + a[i]);
        }
        out.println();
    }

    public static void solution(int test_case) throws IOException {
        // code
        int n = sc.nextInt();
        int a[] = sc.intarr(n);
        int lev[] = new int[n + 1];
        lev[1] = 1;
        int point = 1;
        out.println(1);
        for(int i=1; i < n; i++) {
            if(a[i] == 1) {
                point++;
                lev[point] = 1;
                print(lev, point);
            }
            else if(a[i] == lev[point] + 1) {
                lev[point]++;
                print(lev, point);
            }
            else {
                while(lev[point] + 1 != a[i]) {
                    point--;
                }
                lev[point]++;
                print(lev, point);
            }
        }
    }

    // log A base B
    public static int logint(int x, int base) {
        return (int) (Math.log(x) / Math.log(base));
    }

    public static int logint(long x, long base) {
        return (int) (Math.log(x) / Math.log(base));
    }

    public static int logint(double x, double base) {
        return (int) (Math.log(x) / Math.log(base));
    }

    public static double logdouble(int x, int base) {
        return (Math.log(x) / Math.log(base));
    }

    public static double logdouble(long x, long base) {
        return (Math.log(x) / Math.log(base));
    }

    public static double logdouble(double x, double base) {
        return (Math.log(x) / Math.log(base));
    }

    public static long loglong(int x, int base) {
        return (long) (Math.log(x) / Math.log(base));
    }

    public static long loglong(long x, long base) {
        return (long) (Math.log(x) / Math.log(base));
    }

    public static long loglong(double x, double base) {
        return (long) (Math.log(x) / Math.log(base));
    }

    // Debug
    public static void debug(String msg, Object value) {
        File output = new File("output.txt");
        if (!output.exists()) return;
        String type = value.getClass().getSimpleName();
        if (type.equals("int[]")) out.println(msg + " => " + Arrays.toString((int[]) value));
        else if (type.equals("double[]")) out.println(msg + " => " + Arrays.toString((double[]) value));
        else if (type.equals("float[]")) out.println(msg + " => " + Arrays.toString((float[]) value));
        else if (type.equals("long[]")) out.println(msg + " => " + Arrays.toString((long[]) value));
        else if (type.equals("char[]")) out.println(msg + " => " + Arrays.toString((char[]) value));
        else if (type.equals("String[]")) out.println(msg + " => " + Arrays.toString((String[]) value));
        else if (type.equals("int[][]")) {
            out.println(msg + "=>");
            for (int i[] : (int[][]) value)
                out.println(" . " + Arrays.toString(i).replace(' ', '\t'));
        } else if (type.equals("double[][]")) {
            out.println(msg + "=>");
            for (double i[] : (double[][]) value)
                out.println(" . " + Arrays.toString(i).replace(' ', '\t'));
        } else if (type.equals("float[][]")) {
            out.println(msg + "=>");
            for (float i[] : (float[][]) value)
                out.println(" . " + Arrays.toString(i).replace(' ', '\t'));
        } else if (type.equals("long[][]")) {
            out.println(msg + "=>");
            for (long i[] : (long[][]) value)
                out.println(" . " + Arrays.toString(i).replace(' ', '\t'));
        } else if (type.equals("char[][]")) {
            out.println(msg + "=>");
            for (char i[] : (char[][]) value)
                out.println(" . " + Arrays.toString(i).replace(' ', '\t'));
        } else if (type.equals("String[][]")) {
            out.println(msg + "=>");
            for (String i[] : (String[][]) value)
                out.println(" . " + Arrays.toString(i).replace(' ', '\t'));
        } else out.println(msg + " => " + value);
    }

    public static void debug(Object value) {
        File output = new File("output.txt");
        if (!output.exists()) return;
        String type = value.getClass().getSimpleName();
        if (type.equals("int[]")) out.println(" => " + Arrays.toString((int[]) value));
        else if (type.equals("double[]")) out.println(" => " + Arrays.toString((double[]) value));
        else if (type.equals("float[]")) out.println(" => " + Arrays.toString((float[]) value));
        else if (type.equals("long[]")) out.println(" => " + Arrays.toString((long[]) value));
        else if (type.equals("char[]")) out.println(" => " + Arrays.toString((char[]) value));
        else if (type.equals("String[]")) out.println(" => " + Arrays.toString((String[]) value));
        else if (type.equals("int[][]")) {
            out.println("=>");
            for (int i[] : (int[][]) value)
                out.println(" . " + Arrays.toString(i).replace(' ', '\t'));
        } else if (type.equals("double[][]")) {
            out.println("=>");
            for (double i[] : (double[][]) value)
                out.println(" . " + Arrays.toString(i).replace(' ', '\t'));
        } else if (type.equals("float[][]")) {
            out.println("=>");
            for (float i[] : (float[][]) value)
                out.println(" . " + Arrays.toString(i).replace(' ', '\t'));
        } else if (type.equals("long[][]")) {
            out.println("=>");
            for (long i[] : (long[][]) value)
                out.println(" . " + Arrays.toString(i).replace(' ', '\t'));
        } else if (type.equals("char[][]")) {
            out.println("=>");
            for (char i[] : (char[][]) value)
                out.println(" . " + Arrays.toString(i).replace(' ', '\t'));
        } else if (type.equals("String[][]")) {
            out.println("=>");
            for (String i[] : (String[][]) value)
                out.println(" . " + Arrays.toString(i).replace(' ', '\t'));
        } else out.println(" => " + value);
    }

    // Graph Functions
    public static void addUndirectedEdge(ArrayList<ArrayList<Integer>> adj, int u, int v) {
        adj.get(u).add(v);
        adj.get(v).add(u);
    }

    public static void addDirectedEdge(ArrayList<ArrayList<Integer>> adj, int u, int v) {
        adj.get(u).add(v);
    }

    public static <T> void addUndirectedEdge(ArrayList<ArrayList<Point>> adj, int u, int v, T weight) {
        adj.get(u).add(new Point(v, weight));
        adj.get(v).add(new Point(u, weight));
    }

    public static <T> void addDirectedEdge(ArrayList<ArrayList<Point>> adj, int u, int v, T weight) {
        adj.get(u).add(new Point(v, weight));
    }

    public static <T> void toString(String msg, ArrayList<ArrayList<T>> adj) {
        out.println(msg + ":");
        int count = 0;
        for (ArrayList<T> i : adj) {
            out.print("\t" + count++ + ": ");
            for (T j : i) {
                out.print(j + " ");
            }
            out.println();
        }
    }

    public static void addUndirectedEdge(Map<Integer, ArrayList<Integer>> adj, int u, int v) {
        if (adj.containsKey(u)) {
            ArrayList<Integer> temp = adj.get(u);
            temp.add(v);
            adj.put(u, temp);
        } else {
            ArrayList<Integer> temp = new ArrayList<>();
            temp.add(v);
            adj.put(u, temp);
        }
        if (adj.containsKey(v)) {
            ArrayList<Integer> temp = adj.get(v);
            temp.add(u);
            adj.put(v, temp);
        } else {
            ArrayList<Integer> temp = new ArrayList<>();
            temp.add(u);
            adj.put(v, temp);
        }
    }

    public static void addDirectedEdge(Map<Integer, ArrayList<Integer>> adj, int u, int v) {
        if (adj.containsKey(u)) {
            ArrayList<Integer> temp = adj.get(u);
            temp.add(v);
            adj.put(u, temp);
        } else {
            ArrayList<Integer> temp = new ArrayList<>();
            temp.add(v);
            adj.put(u, temp);
        }
    }

    public static <T> void addUndirectedEdge(Map<Integer, ArrayList<Point>> adj, int u, int v, T weight) {
        if (adj.containsKey(u)) {
            ArrayList<Point> temp = adj.get(u);
            temp.add(new Point(v, weight));
            adj.put(u, temp);
        } else {
            ArrayList<Point> temp = new ArrayList<>();
            temp.add(new Point(v, weight));
            adj.put(u, temp);
        }
        if (adj.containsKey(v)) {
            ArrayList<Point> temp = adj.get(v);
            temp.add(new Point(u, weight));
            adj.put(v, temp);
        } else {
            ArrayList<Point> temp = new ArrayList<>();
            temp.add(new Point(u, weight));
            adj.put(v, temp);
        }
    }

    public static <T> void addDirectedEdge(Map<Integer, ArrayList<Point>> adj, int u, int v, T weight) {
        if (adj.containsKey(u)) {
            ArrayList<Point> temp = adj.get(u);
            temp.add(new Point(v, weight));
            adj.put(u, temp);
        } else {
            ArrayList<Point> temp = new ArrayList<>();
            temp.add(new Point(v, weight));
            adj.put(u, temp);
        }
    }

    public static <T> void toString(String msg, Map<T, ArrayList<T>> adj) {
        out.println(msg + ":");
        for (Map.Entry<T, ArrayList<T>> entry : adj.entrySet()) {
            out.println("\t" + entry.getKey() + ": " + entry.getValue());
        }
    }

    // GCD
    public static int __gcd(int a, int b) {
        BigInteger n1 = BigInteger.valueOf(a);
        BigInteger n2 = BigInteger.valueOf(b);
        BigInteger gcd = n1.gcd(n2);
        return gcd.intValue();
    }

    public static long __gcd(long a, long b) {
        BigInteger n1 = BigInteger.valueOf(a);
        BigInteger n2 = BigInteger.valueOf(b);
        BigInteger gcd = n1.gcd(n2);
        return gcd.longValue();
    }

    public static void main(String args[]) throws IOException {
        new Thread(null, new Main(), "random", 1 << 26).start();
    }

    @Override
    public void run() {
        long start = 0, end = 0;
        try {
            File output = new File("output.txt");
            sc = new FastReader();
            if (output.exists()) {
                out = new PrintWriter(new FileOutputStream("output.txt"));
                start = System.nanoTime();
            } else {
                out = new PrintWriter(System.out);
            }

            int test_cases = 1;
            if (test_case_input) test_cases = sc.nextInt();
            for (int i = 1; i <= test_cases; i++) {
                solution(i);
            }
            if (output.exists()) {
                end = System.nanoTime();
                out.println("Execution time: " + (end - start) / 1000000 + " ms");
            }
            out.flush();
            out.close();
        } catch (Exception e) {
            out.println("Exception: " + e);
            out.println("At Line no. : " + e.getStackTrace()[0].getLineNumber());
            out.flush();
            out.close();
            return;
        }
    }

    // Edge Class
    static class Edge implements Comparable<Edge> {
        Object u;
        Object v;
        Object wt;

        public Edge(Object origin, Object destination, Object weight) {
            u = origin;
            v = destination;
            wt = weight;
        }

        public String toString() {
            String ans = u + " -> " + v + " : " + wt;
            return ans;
        }

        public int getIntOrigin() {
            return (int) u;
        }

        public int getIntDestination() {
            return (int) v;
        }

        public int getIntWeight() {
            return (int) wt;
        }

        public long getLongOrigin() {
            return (long) u;
        }

        public long getLongDestination() {
            return (long) v;
        }

        public long getLongWeight() {
            return (long) wt;
        }

        @Override
        public int compareTo(Edge edge) {
            if ((edge.u).getClass() == Long.class) return (((Long) this.wt).compareTo((Long) edge.wt));
            else return (((Integer) this.wt).compareTo((Integer) edge.wt));
        }
    }

    // Point Class
    static class Point implements Comparable<Point> {
        Object x;
        Object y;

        public Point(Object a, Object b) {
            x = a;
            y = b;
        }

        public int getIntX() {
            return (int) x;
        }

        public int getIntY() {
            return (int) y;
        }

        public long getLongX() {
            return (long) x;
        }

        public long getLongY() {
            return (long) y;
        }

        public int compareTo(Point obj) {
            if (obj.x.equals(this.x)) {
                if ((obj.y).getClass() == Long.class) return ((Long) this.y).compareTo((Long) obj.y);
                else return ((Integer) this.y).compareTo((Integer) obj.y);
            } else {
                if ((obj.x).getClass() == Long.class) return ((Long) this.x).compareTo((Long) obj.x);
                else return ((Integer) this.x).compareTo((Integer) obj.x);
            }
        }

        public String toString() {
            String ans = "(" + x + ", " + y + ")";
            return ans;
        }

        @Override
        public int hashCode() {
            int hash = 7;
            hash = 71 * hash + (int) this.x;
            hash = 71 * hash + (int) this.y;
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) return false;
            Point point = (Point) obj;
            if (point.x.equals(this.x) && point.y.equals(this.y)) return true;
            else return false;
        }
    }

    // Fast IO
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() throws FileNotFoundException {
            File in = new File("input.txt");
            if (in.exists()) {
                br = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt")));
            } else {
                br = new BufferedReader(new InputStreamReader(System.in));
            }
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        float nextFloat() {
            return Float.parseFloat(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        int[] intarr(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(next());
            }
            return a;
        }

        long[] longarr(int n) {
            long a[] = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = Long.parseLong(next());
            }
            return a;
        }

        float[] floatarr(int n) {
            float a[] = new float[n];
            for (int i = 0; i < n; i++) {
                a[i] = Float.parseFloat(next());
            }
            return a;
        }

        double[] doublearr(int n) {
            double a[] = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = Double.parseDouble(next());
            }
            return a;
        }

        int[][] intmatrix(int row, int col) {
            int a[][] = new int[row][col];
            for (int i = 0; i < row; i++) {
                for (int j = 0; j < col; j++) {
                    a[i][j] = Integer.parseInt(next());
                }
            }
            return a;
        }

        long[][] longmatrix(int row, int col) {
            long a[][] = new long[row][col];
            for (int i = 0; i < row; i++) {
                for (int j = 0; j < col; j++) {
                    a[i][j] = Long.parseLong(next());
                }
            }
            return a;
        }

        float[][] floatmatrix(int row, int col) {
            float a[][] = new float[row][col];
            for (int i = 0; i < row; i++) {
                for (int j = 0; j < col; j++) {
                    a[i][j] = Float.parseFloat(next());
                }
            }
            return a;
        }

        double[][] doublematrix(int row, int col) {
            double a[][] = new double[row][col];
            for (int i = 0; i < row; i++) {
                for (int j = 0; j < col; j++) {
                    a[i][j] = Double.parseDouble(next());
                }
            }
            return a;
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.arraycopy;
import static java.lang.System.exit;
import static java.util.Arrays.copyOf;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;

public class C {

	static class IntList {

		int data[] = new int[3];
		int size = 0;

		boolean isEmpty() {
			return size == 0;
		}

		int size() {
			return size;
		}

		int get(int index) {
			if (index < 0 || index >= size) {
				throw new IndexOutOfBoundsException();
			}
			return data[index];
		}

		void clear() {
			size = 0;
		}

		void set(int index, int value) {
			if (index < 0 || index >= size) {
				throw new IndexOutOfBoundsException();
			}
			data[index] = value;
		}

		void expand() {
			if (size >= data.length) {
				data = copyOf(data, (data.length << 1) + 1);
			}
		}

		void insert(int index, int value) {
			if (index < 0 || index > size) {
				throw new IndexOutOfBoundsException();
			}
			expand();
			arraycopy(data, index, data, index + 1, size++ - index);
			data[index] = value;
		}

		int delete(int index) {
			if (index < 0 || index >= size) {
				throw new IndexOutOfBoundsException();
			}
			int value = data[index];
			arraycopy(data, index + 1, data, index, --size - index);
			return value;
		}

		void push(int value) {
			expand();
			data[size++] = value;
		}

		int pop() {
			if (size == 0) {
				throw new NoSuchElementException();
			}
			return data[--size];
		}

		void unshift(int value) {
			expand();
			arraycopy(data, 0, data, 1, size++);
			data[0] = value;
		}

		int shift() {
			if (size == 0) {
				throw new NoSuchElementException();
			}
			int value = data[0];
			arraycopy(data, 1, data, 0, --size);
			return value;
		}
	}

	static void solve() throws Exception {
		int tests = scanInt();
		IntList stack = new IntList();
		for (int test = 0; test < tests; test++) {
			stack.clear();
			int n = scanInt();
			for (int i = 0; i < n; i++) {
				int v = scanInt();
				if (v == 1) {
					stack.push(v);
				} else {
					while (stack.pop() != v - 1) { }
					stack.push(v);
				}
				for (int j = 0; j < stack.size; j++) {
					if (j != 0) {
						out.print('.');
					}
					out.print(stack.data[j]);
				}
				out.println();
			}
		}
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}


import java.util.*;
import java.io.*;
public class C {
    static class Scan {
        private byte[] buf=new byte[1024];
        private int index;
        private InputStream in;
        private int total;
        public Scan()
        {
            in=System.in;
        }
        public int scan()throws IOException
        {
            if(total<0)
            throw new InputMismatchException();
            if(index>=total)
            {
                index=0;
                total=in.read(buf);
                if(total<=0)
                return -1;
            }
            return buf[index++];
        }
        public int scanInt()throws IOException
        {
            int integer=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n))
            {
                if(n>='0'&&n<='9')
                {
                    integer*=10;
                    integer+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            return neg*integer;
        }
        public double scanDouble()throws IOException
        {
            double doub=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n)&&n!='.')
            {
                if(n>='0'&&n<='9')
                {
                    doub*=10;
                    doub+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            if(n=='.')
            {
                n=scan();
                double temp=1;
                while(!isWhiteSpace(n))
                {
                    if(n>='0'&&n<='9')
                    {
                        temp/=10;
                        doub+=(n-'0')*temp;
                        n=scan();
                    }
                    else throw new InputMismatchException();
                }
            }
            return doub*neg;
        }
        public String scanString()throws IOException
        {
            StringBuilder sb=new StringBuilder();
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            while(!isWhiteSpace(n))
            {
                sb.append((char)n);
                n=scan();
            }
            return sb.toString();
        }
        private boolean isWhiteSpace(int n)
        {
            if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
            return true;
            return false;
        }
    }

    public static void sort(int arr[],int l,int r) {    //sort(arr,0,n-1);
        if(l==r) {
            return;
        }
        int mid=(l+r)/2;
        sort(arr,l,mid);
        sort(arr,mid+1,r);
        merge(arr,l,mid,mid+1,r);
    }
    public static void merge(int arr[],int l1,int r1,int l2,int r2) {
        int tmp[]=new int[r2-l1+1];
        int indx1=l1,indx2=l2;
        //sorting the two halves using a tmp array
        for(int i=0;i<tmp.length;i++) {
            if(indx1>r1) {
                tmp[i]=arr[indx2];
                indx2++;
                continue;
            }
            if(indx2>r2) {
                tmp[i]=arr[indx1];
                indx1++;
                continue;
            }
            if(arr[indx1]<arr[indx2]) {
                tmp[i]=arr[indx1];
                indx1++;
                continue;
            }
            tmp[i]=arr[indx2];
            indx2++;
        }
        //Copying the elements of tmp into the main array
        for(int i=0,j=l1;i<tmp.length;i++,j++) {
            arr[j]=tmp[i];
        }
    }

    public static void sort(long arr[],int l,int r) {    //sort(arr,0,n-1);
        if(l==r) {
            return;
        }
        int mid=(l+r)/2;
        sort(arr,l,mid);
        sort(arr,mid+1,r);
        merge(arr,l,mid,mid+1,r);
    }
    public static void merge(long arr[],int l1,int r1,int l2,int r2) {
        long tmp[]=new long[r2-l1+1];
        int indx1=l1,indx2=l2;
        //sorting the two halves using a tmp array
        for(int i=0;i<tmp.length;i++) {
            if(indx1>r1) {
                tmp[i]=arr[indx2];
                indx2++;
                continue;
            }
            if(indx2>r2) {
                tmp[i]=arr[indx1];
                indx1++;
                continue;
            }
            if(arr[indx1]<arr[indx2]) {
                tmp[i]=arr[indx1];
                indx1++;
                continue;
            }
            tmp[i]=arr[indx2];
            indx2++;
        }
        //Copying the elements of tmp into the main array
        for(int i=0,j=l1;i<tmp.length;i++,j++) {
            arr[j]=tmp[i];
        }
    }

    public static void main(String args[]) throws IOException {
        Scan input=new Scan();
        StringBuilder ans=new StringBuilder("");
        int test=input.scanInt();
        for(int tt=1;tt<=test;tt++) {
            int n=input.scanInt();

            ArrayList<Integer> arrli[]=new ArrayList[n];
            for(int i=0;i<n;i++) {
                arrli[i]=new ArrayList<>();
            }

            for(int i=0;i<n;i++) {
                int tmp=input.scanInt();
                if(i==0) {
                    arrli[0].add(1);
                    continue;
                }
                if(tmp==1) {
                    for(int j=0;j<arrli[i-1].size();j++) {
                        arrli[i].add(arrli[i-1].get(j));
                    }
                    arrli[i].add(tmp);
                    continue;
                }
                int indx=-1;
                for(int j=0;j<arrli[i-1].size();j++) {
                    if(arrli[i-1].get(j)==tmp-1) {
                        indx=j;
                    }
                }
                for(int j=0;j<indx;j++) {
                    arrli[i].add(arrli[i-1].get(j));
                }
                arrli[i].add(tmp);
            }
            for(int i=0;i<n;i++) {
               for(int j=0;j<arrli[i].size();j++) {
                   ans.append(arrli[i].get(j));
                   if(j!=arrli[i].size()-1) {
                       ans.append(".");
                   }
               }
               ans.append("\n");
            }
        }
        System.out.println(ans);
    }

}


import java.util.*;
import java.io.*;
public class B{
	public static void main(String[] args)
	{
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int t = fs.nextInt();
		for(int tt=0;tt<t;tt++)
		{
			int n = fs.nextInt();
			int[] arr = fs.readArray(n);
			List<String> ans = new ArrayList();
			List<Integer> temp = new ArrayList();
			temp.add(arr[0]);
			ans.add(""+arr[0]);
			for(int i=1;i<n;i++)
			{
				int ch = arr[i];
				if(ch == 1)
				{
					temp.add(1);
					StringBuilder sb = new StringBuilder();
					for(int j=0;j<temp.size();j++)
					{
						sb.append(temp.get(j));
						if(j != temp.size()-1)
						{
							sb.append('.');
						}
					}
					ans.add(sb.toString());
				}
				else
				{
					int j = temp.size()-1;
					while(j>=0)
					{
						if(ch - temp.get(j) == 1)
						{
							temp.set(j,ch);
							break;
						}
						else
						{
							j--;
						}
					}
					int extra = temp.size()-1;
					while(extra>j)
					{
						temp.remove(temp.size()-1);
						extra--;
					}
					StringBuilder sb = new StringBuilder();
					for(int jj=0;jj<temp.size();jj++)
					{
						sb.append(temp.get(jj));
						if(jj != temp.size()-1)
						{
							sb.append('.');
						}
					}
					ans.add(sb.toString());
				}
//				out.println("Here: "+temp);
			}
			for(String str:ans)
			{
				out.println(str);
			}
		}
		out.close();
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
	public static int[] sort(int[] arr)
	{
		List<Integer> temp = new ArrayList();
		for(int i:arr)temp.add(i);
		Collections.sort(temp);
		int start = 0;
		for(int i:temp)arr[start++]=i;
		return arr;
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Stack;

public class Main {

    static void debug(Object... args) {
        System.out.println(Arrays.deepToString(args));
    }

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        int T = Integer.parseInt(br.readLine());
        while (T-- > 0) {
            int N = Integer.parseInt(br.readLine());
            Stack<LN> nodes = new Stack<>();
            int a0 = Integer.parseInt(br.readLine());
            LN root = new LN(1, 0, "");
            nodes.add(root);
            pw.println(root);
            for (int i = 0; i < N - 1; i++) {
                int ai = Integer.parseInt(br.readLine());
                while (!nodes.isEmpty()) {
                    LN nn = nodes.pop();
                    if (ai == 1) {
                        LN e = new LN(1, nn.depth + 1, nn.toString());
                        nodes.add(nn);
                        nodes.add(e);
                        pw.println(e);
                        break;
                    } else if (nn.lv == ai - 1) {
                        LN e = new LN(ai, nn.depth, nn.base);
                        nodes.add(e);
                        pw.println(e);
                        break;
                    }
                }
            }
        }
        pw.flush();
    }

    static class LN {
        int lv;
        int depth;
        String base;

        public LN(int lv, int depth, String prev) {
            this.lv = lv;
            this.depth = depth;
            base = prev;
        }

        @Override
        public String toString() {
            StringBuilder bob = new StringBuilder(base);
            if (depth > 0) {
                bob.append(".");
            }
            bob.append(lv);
            return bob.toString();
        }
    }
}


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

import static java.lang.Math.*;

public class Main
{
    static MyScanner scan;
    static PrintWriter pw;
    static long MOD = 1_000_000_007;
    static long INF = 2_000_000_000_000_000_000L;
    static long inf = 2_000_000_000;
    public static void main(String[] args) {
        new Thread(null, null, "_", 1 << 27) {
            public void run() {
                try {
                    solve();
                } catch (Exception e) {
                    e.printStackTrace();
                    System.exit(1);
                }
            }
        }.start();
    }

    static void solve() throws java.lang.Exception {
        //initIo(true, "");
        initIo(false, "");
        StringBuilder sb = new StringBuilder();

        int t = ni();
        while (t-->0) {
            int n = ni();
            ArrayList<ArrayList<Integer>> ans = new ArrayList<>();
            ArrayList<Integer> prev = new ArrayList<>();
            prev.add(1);
            ni();
            for(int i=1;i<n;i++) {
                int x = ni();
                ans.add(prev);
                ArrayList<Integer> next = new ArrayList<>();
                int idx = -1;
                for(int j=prev.size()-1;j>=0;--j) {
                    if(prev.get(j)==x-1) {
                        for(int k=0;k<j;++k) {
                            next.add(prev.get(k));
                        }
                        next.add(x);
                        idx = j;
                        break;
                    }
                }

                if(idx==-1) {
                    assert_in_range("x", x, 1, 1);
                    for(int e : prev) {
                        next.add(e);
                    }
                    next.add(1);
                }
                prev = next;
            }

            ans.add(prev);
            for(ArrayList<Integer> list: ans) {
                print(list);
            }
        }

        pw.flush();
        pw.close();
    }

    static void print(ArrayList<Integer> list) {
        for(int i=0;i<list.size();i++) {
            pw.print(list.get(i));
            if(i==list.size()-1) {
                continue;
            }
            pw.print(".");
        }
        pl();
    }

    static void assert_in_range(String varName, int n, int l, int r) {
        if (n >=l && n<=r) return;
        System.out.println(varName + " is not in range. Actual: "+n+" l : "+l+" r: "+r);
        System.exit(1);
    }
    static void assert_in_range(String varName, long n, long l, long r) {
        if (n>=l && n<=r) return;
        System.out.println(varName + " is not in range. Actual: "+n+" l : "+l+" r: "+r);
        System.exit(1);
    }

    static void initIo(boolean isFileIO, String suffix) throws IOException {
        scan = new MyScanner(isFileIO, suffix);
        if(isFileIO) {
            pw = new PrintWriter("/Users/dsds/Desktop/output"+suffix+".txt");
        }
        else {
            pw = new PrintWriter(System.out, true);
        }
    }
    static int ni() throws IOException
    {
        return scan.nextInt();
    }
    static long nl() throws IOException
    {
        return scan.nextLong();
    }
    static double nd() throws IOException
    {
        return scan.nextDouble();
    }
    static String ne() throws IOException
    {
        return scan.next();
    }
    static String nel() throws IOException
    {
        return scan.nextLine();
    }
    static void pl()
    {
        pw.println();
    }
    static void p(Object o)
    {
        pw.print(o+" ");
    }
    static void pl(Object o)
    {
        pw.println(o);
    }
    static void psb(StringBuilder sb)
    {
        pw.print(sb);
    }
    static void pa(String arrayName, Object arr[])
    {
        pl(arrayName+" : ");
        for(Object o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, int arr[])
    {
        pl(arrayName+" : ");
        for(int o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, long arr[])
    {
        pl(arrayName+" : ");
        for(long o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, double arr[])
    {
        pl(arrayName+" : ");
        for(double o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, char arr[])
    {
        pl(arrayName+" : ");
        for(char o : arr)
            p(o);
        pl();
    }

    static void pa(String arrayName, TreeSet<Integer> set)
    {
        pl(arrayName+" : ");
        for(Object o : set)
            p(o);
        pl();
    }

    static void pa(String arrayName, boolean arr[])
    {
        pl(arrayName+" : ");
        for(boolean o : arr)
            p(o);
        pl();
    }
    static void pa(String listName, List list)
    {
        pl(listName+" : ");
        for(Object o : list)
            p(o);
        pl();
    }
    static void pa(String arrayName, Object[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(Object o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, int[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(int o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, long[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(long o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, char[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(char o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, double[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(double o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, boolean[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(boolean o : arr[i])
                p(o);
            pl();
        }
    }
    static class MyScanner
    {
        BufferedReader br;
        StringTokenizer st;
        MyScanner(boolean readingFromFile, String suffix) throws IOException
        {
            if(readingFromFile) {
                br = new BufferedReader(new FileReader("/Users/ddfds/Desktop/input"+suffix+".txt"));
            }
            else {
                br = new BufferedReader(new InputStreamReader(System.in));
            }
        }
        String nextLine()throws IOException
        {
            return br.readLine();
        }
        String next() throws IOException
        {
            if(st==null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
        int nextInt() throws IOException
        {
            return Integer.parseInt(next());
        }
        long nextLong() throws IOException
        {
            return Long.parseLong(next());
        }
        double nextDouble() throws IOException
        {
            return Double.parseDouble(next());
        }
    }
}


import java.util.*;
import java.io.*;
public class C {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int T = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		while(T-->0) {
			int n = sc.nextInt();
			int[] arr = new int[n];
			for(int i = 0; i < n; i++) {
				arr[i] = sc.nextInt();
			}
			int[] p = new int[n];
			int[] base = new int[n];
			p[0] = -1;
			base[0] = -1;
			boolean[] used = new boolean[n];
			for(int i = 1; i < n; i++) {
				if(arr[i] == 1) {
					p[i] = i-1;
					base[i] = i-1;
				}
				else {
					for(int j = i-1; j >= 0; j--) {
						if(used[j]) continue;
						if(arr[j] == arr[i]-1) {
							p[i] = j; used[j] = true;
							base[i] = base[j]; break;
						}
						else used[j] = true;
					}
				}
			}
			StringBuilder[] res = new StringBuilder[n];
			res[0] = new StringBuilder("1");
			sb.append("1\n");
			for(int i = 1; i < n; i++) {
				if(base[i] == -1) {
					res[i] = new StringBuilder();
				}
				else {
					res[i] = new StringBuilder(res[base[i]]);
					res[i].append(".");
				}
				res[i].append(arr[i]+"");
				sb.append(res[i]);
				sb.append("\n");
			}
		}
		PrintWriter pw = new PrintWriter(System.out);
		pw.println(sb.toString().trim());
		pw.flush();
	}
	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch(IOException e) {
				throw new RuntimeException(e);
			}
		}
	}

}


import javax.print.DocFlavor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;
import java.util.Stack;

public class p1523C {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        for (int i = 0; i < t ; i++) {
            int n = sc.nextInt();
            ArrayList<Stack<Integer>> ar = new ArrayList<Stack<Integer>>();
            for (int j = 0; j < n + 1; j++) {
                ar.add(new Stack<Integer>());
            }
            HashMap <Integer , Integer> hm = new HashMap<Integer, Integer>();
            StringBuilder cur = new StringBuilder();
            int l = 0;
            for (int j = 0; j < n; j++) {
                int a = sc.nextInt();
                if( a == 1)
                {
                    if(cur.length() == 0)
                        cur.append("1");
                    else
                        cur.append(".1");
                    l++;
                    ar.get(1).add(l);
                    hm.put(l , 1);
                }
                else
                {
                    int newl = ar.get( a - 1).pop();
                    for (int k = newl + 1; k <= l ; k++) {
                        ar.get(hm.get(k)).pop();
                        hm.remove(k);
                        cur.delete(cur.lastIndexOf(".")  + 1, cur.length());
                        cur.delete(cur.length() - 1 , cur.length());
                    }
                    cur.delete(cur.lastIndexOf(".")  + 1, cur.length());
                    cur.append(a);
                    ar.get(a).add(newl);
                    hm.put(newl , a);
                    l = newl;
                }
                System.out.println(cur);
            }

        }
    }
}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

/**
 *
 * @author is2ac
 */
public class C_CF {

    public static void main(String[] args) {
        FastScanner57 fs = new FastScanner57();
        PrintWriter pw = new PrintWriter(System.out);
        int t = fs.ni();
        //int t = 1;
        for (int tc = 0; tc < t; tc++) {
            int n = fs.ni();
            int[] q = new int[n+5];
            int ind = 0;
            q[0] = 1;
            for (int i = 0; i < n; i++) {
                int a = fs.ni();
                while (q[ind]!=a) ind--;
                StringBuilder sb = new StringBuilder();
                for (int j = 0; j < ind; j++) {
                    sb.append(q[j]-1);
                    sb.append(".");
                }
                    sb.append(a);
                    q[ind]++;
                    q[ind+1] = 1;
                    ind++;
                    pw.println(sb);
            }
        }
        pw.close();

    }

    static class BIT18 {

        int[] bit;

        public BIT18(int size) {
            bit = new int[size];
        }

        public void update(int ind, int delta) {
            while (ind < bit.length) {
                bit[ind] += delta;
                ind = ind + (ind & (-1 * ind));
            }
        }

        public int sum(int ind) {
            int s = 0;
            while (ind > 0) {
                s += bit[ind];
                ind = ind - (ind & (-1 * ind));
            }
            return s;
        }

        public int query(int l, int r) {
            return sum(r) - sum(l);
        }
    }

    // 0 -> left was chosen
    // 1 -> right was chosen
    public static long recur(int ind, int p, int prev, long[] v, Long[][] dp, long[][] lr, List<List<Integer>> list) {

        long last = v[0];
        long ls = 0L;
        long rs = 0L;
        if (p == 1) {
            last = v[1];
        }
        if (ind != 0) {
            ls += (long) Math.abs(last - lr[ind][0]);
        }
        if (ind != 0) {
            rs += (long) Math.abs(last - lr[ind][1]);
        }
        if (dp[ind][p] != null) {
            return dp[ind][p];
        }
        long[] cur = lr[ind];

        List<Integer> temp = list.get(ind);
        for (int val : temp) {
            if (prev == val) {
                continue;
            }
            ls += recur(val, 0, ind, cur, dp, lr, list);
            rs += recur(val, 1, ind, cur, dp, lr, list);
        }
        return dp[ind][p] = Math.max(ls, rs);
    }

    public static void sort(long[] a) {
        List<Long> list = new ArrayList();
        for (int i = 0; i < a.length; i++) {
            list.add(a[i]);
        }
        Collections.sort(list);
        for (int i = 0; i < a.length; i++) {
            a[i] = list.get(i);
        }
    }

    public static long gcd(long n1, long n2) {
        if (n2 == 0) {
            return n1;
        }
        return gcd(n2, n1 % n2);
    }

}

class UnionFind16 {

    int[] id;

    public UnionFind16(int size) {
        id = new int[size];
        for (int i = 0; i < size; i++) {
            id[i] = i;
        }
    }

    public int find(int p) {
        int root = p;
        while (root != id[root]) {
            root = id[root];
        }
        while (p != root) {
            int next = id[p];
            id[p] = root;
            p = next;
        }
        return root;
    }

    public void union(int p, int q) {
        int a = find(p), b = find(q);
        if (a == b) {
            return;
        }
        id[b] = a;
    }
}

class FastScanner57 {

    BufferedReader br;
    StringTokenizer st;

    public FastScanner57() {
        br = new BufferedReader(new InputStreamReader(System.in), 32768);
        st = null;
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int ni() {
        return Integer.parseInt(next());
    }

    int[] intArray(int N) {
        int[] ret = new int[N];
        for (int i = 0; i < N; i++) {
            ret[i] = ni();
        }
        return ret;
    }

    long nl() {
        return Long.parseLong(next());
    }

    long[] longArray(int N) {
        long[] ret = new long[N];
        for (int i = 0; i < N; i++) {
            ret[i] = nl();
        }
        return ret;
    }

    double nd() {
        return Double.parseDouble(next());
    }

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}


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

public class Main {
    private static HashMap<String, Integer> nodes;
    private static void dfs(String cur, PrintWriter out) {
        if(cur.length() > 0) {
            out.println(cur.substring(1));
        }
        int children = nodes.get(cur);
        for(int i = 1; i <= children; i++) {
            dfs(cur+"."+i, out);
        }
    }
    public static void main(String[] args) throws IOException {
        //Scanner f = new Scanner(new File("uva.in"));
        //Scanner f = new Scanner(System.in);
        //BufferedReader f = new BufferedReader(new FileReader("uva.in"));
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int t = Integer.parseInt(f.readLine());
        while(t-- > 0) {
            int n = Integer.parseInt(f.readLine());
            nodes = new HashMap<>();
            nodes.put("", 0);
            String cur = "";
            for(int i = 0; i < n; i++) {
                int a = Integer.parseInt(f.readLine());
                while(nodes.get(cur) != a-1) {
                    cur = cur.substring(0, cur.lastIndexOf("."));
                }
                nodes.put(cur, a);
                cur = cur+"."+a;
                nodes.put(cur, 0);
            }
            dfs("", out);
        }
        f.close();
        out.close();
    }
}


/**
* @author: Prasad Chaudhari
* @linkedIn: https://www.linkedin.com/in/prasad-chaudhari-841655a6/
* @git: https://github.com/Prasad-Chaudhari
*/
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;

public class Main {

    public static void main(String[] args) throws Exception {
        FastIO in = new FastIO(args);
        int t = in.ni();
        while (t-- > 0) {
            int n = in.ni();
            LinkedList<Integer> l = new LinkedList<>();
            ArrayList<LinkedList<Integer>> al = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                int p = in.ni();
                if (p == 1) {
                    l.addFirst(1);
                } else {
                    while (true) {
                        if (l.peekFirst() == p - 1) {
                            l.addFirst(l.removeFirst() + 1);
                            break;
                        } else {
                            l.removeFirst();
                        }
                    }
                }
                al.add(new LinkedList<>(l));
            }
            for (LinkedList<Integer> ll : al) {
                while (ll.size() > 1) {
                    System.out.print(ll.removeLast() + ".");
                }
                System.out.println(ll.remove());
            }
            System.out.println();
        }
        in.bw.flush();
    }

    static boolean willbealive(int i, int a[]) {
        if (i < 0 || i >= a.length)
            return false;
        if (a.length == 1)
            return false;
        if (a[i] == 1)
            return false;
        if (i == 0)
            return a[1] == 1;
        else if (i == a.length - 1)
            return a[i - 1] == 1;
        else
            return (a[i - 1] == 1) ^ (a[i + 1] == 1);
    }

    static class Data implements Comparable<Data> {

        int a, b;

        public Data(int a, int b) {
            this.a = a;
            this.b = b;
        }

        @Override
        public int compareTo(Data o) {
            if (a == o.a) {
                return Integer.compare(b, o.b);
            }
            return Integer.compare(a, o.a);
        }

        public static void sort(int a[]) {
            Data d[] = new Data[a.length];
            for (int i = 0; i < a.length; i++) {
                d[i] = new Data(a[i], 0);
            }
            Arrays.sort(d);
            for (int i = 0; i < a.length; i++) {
                a[i] = d[i].a;
            }
        }
    }

    static class FastIO {

        private final BufferedReader br;
        private final BufferedWriter bw;
        private String s[];
        private int index;

        public FastIO(String[] args) throws IOException {
            if (args.length > 1) {
                br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(args[0]))));
                bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(args[1]))));
            } else {
                br = new BufferedReader(new InputStreamReader(System.in));
                bw = new BufferedWriter(new OutputStreamWriter(System.out, "UTF-8"));
            }
            s = br.readLine().split(" ");
            index = 0;
        }

        public int ni() throws IOException {
            return Integer.parseInt(nextToken());
        }

        public double nd() throws IOException {
            return Double.parseDouble(nextToken());
        }

        public long nl() throws IOException {
            return Long.parseLong(nextToken());
        }

        public String next() throws IOException {
            return nextToken();
        }

        public String nli() throws IOException {
            try {
                return br.readLine();
            } catch (IOException ex) {

            }
            return null;
        }

        public int[] gia(int n) throws IOException {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }

        public int[] gia(int n, int start, int end) throws IOException {
            validate(n, start, end);
            int a[] = new int[n];
            for (int i = start; i < end; i++) {
                a[i] = ni();
            }
            return a;
        }

        public double[] gda(int n) throws IOException {
            double a[] = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }

        public double[] gda(int n, int start, int end) throws IOException {
            validate(n, start, end);
            double a[] = new double[n];
            for (int i = start; i < end; i++) {
                a[i] = nd();
            }
            return a;
        }

        public long[] gla(int n) throws IOException {
            long a[] = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }

        public long[] gla(int n, int start, int end) throws IOException {
            validate(n, start, end);
            long a[] = new long[n];
            for (int i = start; i < end; i++) {
                a[i] = nl();
            }
            return a;
        }

        public void print(String s) throws IOException {
            bw.write(s);
        }

        public void println(String s) throws IOException {
            bw.write(s);
            bw.newLine();
        }

        public void print(int s) throws IOException {
            bw.write(s + "");
        }

        public void println(int s) throws IOException {
            bw.write(s + "");
            bw.newLine();
        }

        public void print(long s) throws IOException {
            bw.write(s + "");
        }

        public void println(long s) throws IOException {
            bw.write(s + "");
            bw.newLine();
        }

        public void print(double s) throws IOException {
            bw.write(s + "");
        }

        public void println(double s) throws IOException {
            bw.write(s + "");
            bw.newLine();
        }

        private String nextToken() throws IndexOutOfBoundsException, IOException {
            if (index == s.length) {
                s = br.readLine().split(" ");
                index = 0;
            }
            return s[index++];
        }

        private void validate(int n, int start, int end) {
            if (start < 0 || end >= n) {
                throw new IllegalArgumentException();
            }
        }
    }
}


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

public class Main {
    static void deal(int n,int[] arr) {
        int[] a = new int[n];
        a[0] = 1;
        int l = 1;
        out.println(toString(a,l));
        for(int i=1;i<n;i++) {
            if(arr[i] == 1) {
                a[l] = 1;
                l++;
            } else {
                int index = l-1;
                while(index>=0 && a[index] != arr[i]-1) {
                    index--;
                }
                a[index]++;
                l = index+1;
            }
            out.println(toString(a,l));
        }
    }

    static String toString(int[] arr,int l) {
        StringBuilder sb = new StringBuilder();
        for(int i=0;i<l-1;i++) {
            sb.append(arr[i]);
            sb.append('.');
        }
        sb.append(arr[l-1]);
        return sb.toString();
    }

	public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int t = sc.nextInt();
        for(int i=0;i<t;i++) {
            int n = sc.nextInt();
            int[] arr = new int[n];
            for(int j=0;j<n;j++) arr[j] = sc.nextInt();
            deal(n,arr);
        }
        out.close();
    }

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
                br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
                while (st == null || !st.hasMoreElements()) {
                        try {
                                st = new StringTokenizer(br.readLine());
                        } catch (IOException e) {
                                e.printStackTrace();
                        }
                }
                return st.nextToken();
        }

        int nextInt() {
                return Integer.parseInt(next());
        }

        long nextLong() {
                return Long.parseLong(next());
        }

        double nextDouble() {
                return Double.parseDouble(next());
        }

        String nextLine(){
                String str = "";
    try {
            str = br.readLine();
    } catch (IOException e) {
            e.printStackTrace();
    }
    return str;
        }

    }
}


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

public class C
{

	static FastIO f;

	public static void main(String args[]) throws IOException
	{
		f = new FastIO();

		int t, n, a, i;
		Node r, p, c;

		t = f.ni();

		while(t-->0)
		{
			n = f.ni();
			r = p = new Node(-1, null);
			// f.out("1\n");

			for(i = 0; i < n; i++)
			{
				a = f.ni();
				if(a != 1)
				{
					while(a != p.i + 1)
						p = p.p;
					p = p.p;
				}
				// if(a == p.i + 1)
				// 	p = p.p;
				// else if(p.p != null && a == p.p.i + 1)
				// 	p = p.p.p;
				c = new Node(a, p);
				p.c.add(c);
				p = c;
			}

			dfs(r, "");
		}

		f.flush();
	}

	public  static void dfs(Node n, String s) throws IOException
	{
		String t;

		if(n.i == -1)
			t = s;
		else
		{
			t = s + n.i + ".";
			f.out(s + n.i + "\n");
		}

		for(Node c : n.c)
			dfs(c, t);
	}

	static class Node
	{
		int i;
		Node p;
		ArrayList<Node> c;

		Node(int x, Node y)
		{
			i = x;
			p = y;
			c = new ArrayList<>();
		}

		@Override
		public int hashCode()
		{
			return super.hashCode();
		}

		@Override
		public boolean equals(Object obj)
		{
			Node that = (Node)obj;

			return super.equals(obj);
		}

		@Override
		public String toString()
		{
			return "[" + "PARAMETERS" + "]";
		}
	}

	public static class FastIO
	{
		BufferedReader br;
		BufferedWriter bw, be;
		StringTokenizer st;

		public FastIO()
		{
			br = new BufferedReader(new InputStreamReader(System.in));
			bw = new BufferedWriter(new OutputStreamWriter(System.out));
			be = new BufferedWriter(new OutputStreamWriter(System.err));
			st = new StringTokenizer("");
		}

		private void read() throws IOException
		{
			st = new StringTokenizer(br.readLine());
		}

		public String ns() throws IOException
		{
			while(!st.hasMoreTokens())
				read();
			return st.nextToken();
		}

		public int ni() throws IOException
		{
			return Integer.parseInt(ns());
		}

		public long nl() throws IOException
		{
			return Long.parseLong(ns());
		}

		public float nf() throws IOException
		{
			return Float.parseFloat(ns());
		}

		public double nd() throws IOException
		{
			return Double.parseDouble(ns());
		}

		public char nc() throws IOException
		{
			return ns().charAt(0);
		}

		public int[] nia(int n) throws IOException
		{
			int[] a = new int[n];
			for(int i = 0; i < n; i++)
				a[i] = ni();

			return a;
		}

		public long[] nla(int n) throws IOException
		{
			long[] a = new long[n];
			for(int i = 0; i < n; i++)
				a[i] = nl();

			return a;
		}

		public char[] nca() throws IOException
		{
			return ns().toCharArray();
		}

		public void out(String s) throws IOException
		{
			bw.write(s);
		}

		public void flush() throws IOException
		{
			bw.flush();
			be.flush();
		}

		public void err(String s) throws IOException
		{
			be.write(s);
		}
	}
}


import java.io.*;
import java.util.*;
 public class Main {
	public static void main(String[] args) throws Exception {
		FastIO io = new FastIO();
		int test=io.nextInt();
		while(test>0)
		{
		    int n=io.nextInt();
		    int arr[]=new int[n];
		    for(int i=0;i<n;i++)arr[i]=io.nextInt();
		    List<int[]> list=new ArrayList<>();
		    Stack<int[]> stk=new Stack<>();
		    int temp[]={1};
		    list.add(temp);
		    stk.push(temp);
		    for(int i=1;i<n;i++)
		    {
		        if(arr[i]==1)
		        {
		            int t[]=stk.peek();
		            int nt[]=new int[t.length+1];
		            for(int j=0;j<t.length;j++)nt[j]=t[j];
		            nt[nt.length-1]=arr[i];
		            stk.push(nt);
		            list.add(nt);
		            continue;
		        }
		        while(stk.size()>0)
		        {
		            int t[]=stk.peek();
		            if(t[t.length-1]+1==arr[i]){
		                int nt[]=new int[t.length];
		                for(int j=0;j<t.length-1;j++)nt[j]=t[j];
		                nt[t.length-1]=arr[i];
		                stk.pop();
		                stk.push(nt);
		                list.add(nt);
		                break;
		            }
		            else
		            {
		                stk.pop();
		            }
		        }
		    }
		    for(int i=0;i<list.size();i++)
		    {
		        StringBuilder sb=new StringBuilder();
		        sb.append(list.get(i)[0]);
		        for(int j=1;j<list.get(i).length;j++)
		        {
		            sb.append("."+list.get(i)[j]);
		        }
		        io.println(sb.toString());
		    }
		    test--;
		}
		io.close();
	}
}

 class FastIO extends PrintWriter {
	private InputStream stream;
	private byte[] buf = new byte[1<<16];
	private int curChar, numChars;

	// standard input
	public FastIO() { this(System.in,System.out); }
	public FastIO(InputStream i, OutputStream o) {
		super(o);
		stream = i;
	}
	// file input
	public FastIO(String i, String o) throws IOException {
		super(new FileWriter(o));
		stream = new FileInputStream(i);
	}

	// throws InputMismatchException() if previously detected end of file
	private int nextByte() {
		if (numChars == -1) throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars == -1) return -1; // end of file
		}
		return buf[curChar++];
	}

	public String nextLine() {
		int c; do { c = nextByte(); } while (c <= '\n');
		StringBuilder res = new StringBuilder();
		do { res.appendCodePoint(c); c = nextByte(); } while (c > '\n');
		return res.toString();
	}

	public String next() {
		int c; do { c = nextByte(); } while (c <= ' ');
		StringBuilder res = new StringBuilder();
		do { res.appendCodePoint(c); c = nextByte(); } while (c > ' ');
		return res.toString();
	}

	public int nextInt() {
		int c; do { c = nextByte(); } while (c <= ' ');
		int sgn = 1; if (c == '-') { sgn = -1; c = nextByte(); }
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res = 10*res+c-'0';
			c = nextByte();
		} while (c > ' ');
		return res * sgn;
	}

  public long nextLong() {
		int c; do { c = nextByte(); } while (c <= ' ');
		long sgn = 1; if (c == '-') { sgn = -1; c = nextByte(); }
		long res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res = 10*res+c-'0';
			c = nextByte();
		} while (c > ' ');
		return res * sgn;
	}

	public double nextDouble() { return Double.parseDouble(next()); }
}


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

public class C{

	private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

	public static void main (String[] args) throws IOException {
        int t = Integer.parseInt(br.readLine());
        while(t-- > 0) {
            int n = Integer.parseInt(br.readLine());
            int prev = 1;
            ArrayList<Integer> nums = new ArrayList<>();
            nums.add(1);
            String till = "1";
            for(int i=0;i<n;i++) {
                int ln = Integer.parseInt(br.readLine());
                if(i == 0) {
                    bw.write("1\n");
                    continue;
                }
                if(ln == 1) {
                    nums.add(1);
                }else if(ln == prev + 1) {
                    nums.set(nums.size()-1, ln);
                }else {
                    int idx = -1;
                    for(int j=nums.size()-1;j>=0;j--) {
                        if(nums.get(j) == ln-1) {
                            idx = j;
                            break;
                        }
                    }
                    ArrayList<Integer> temp = new ArrayList<>();
                    for(int j=0;j<idx;j++) {
                        temp.add(nums.get(j));
                    }
                    temp.add(ln);
                    nums.clear();
                    nums = temp;
                }
                for(int j=0;j<nums.size()-1;j++) {
                    bw.write(nums.get(j) + ".");
                }
                bw.write(nums.get(nums.size()-1) + "\n");
                prev = ln;
            }

        }
        bw.flush();
    }
}