#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
# define rep(i,a,b) for(int i=(a); i<=(b); ++i)
# define drep(i,a,b) for(int i=(a); i>=(b); --i)
typedef long long int_;
inline int readint(){
	int a = 0; char c = getchar(), f = 1;
	for(; c<'0'||c>'9'; c=getchar())
		if(c == '-') f = -f;
	for(; '0'<=c&&c<='9'; c=getchar())
		a = (a<<3)+(a<<1)+(c^48);
	return a*f;
}

const int MaxN = 1005;
int fa[MaxN], x[MaxN][MaxN];

void print(int id){
	printf("%d",x[id][1]);
	for(int i=2; i<=x[id][0]; ++i)
		printf(".%d",x[id][i]);
	putchar('\n');
}

int main(){
	x[1][0] = x[1][1] = 1;
	for(int T=readint(); T; --T){
		int n = readint();
		readint(); // a[1] = 1
		puts("1"); // only possible one
		for(int i=2; i<=n; ++i){
			int a = readint(); fa[i] = i-1;
			if(a != 1){
				while(x[fa[i]][x[fa[i]][0]] != a-1)
					fa[i] = fa[fa[i]];
				fa[i] = fa[fa[i]]; // real father
			}
			memcpy(x[i],x[fa[i]],(x[fa[i]][0]+1)<<2);
			x[i][++ x[i][0]] = a, print(i);
		}
	}
	return 0;
}

/*
2
4 1 1 2 3
9 1 1 1 2 2 1 2 1 2
*/
