#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pb push_back
const long double Pi = 3.141592653;
const ll mod=100000000;
long long INF = 100000000000000000;
bool cmp(pair<int,int>a,pair<int,int>b)
{
    return (a.first<b.first) || (a.first==b.first && a.second<b.second);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;cin>>t;
    while(t--)
    {
        int n;cin>>n;
        int v;cin>>v;
        vector <int>y[n+10];
        for(int i=0;i<=n;i++)
        y[i].clear();
        int a[n];
        y[0].pb(1);
        for(int i=1;i<n;i++)
        {
            int x;cin>>x;
            int j=y[i-1].size();
            int g=j-1;
            //cout<<x<<" "<<g<<"\n";
            if(x!=1)
            {
                //cout<<x<<"\n";
                while(1)
                {
                    //cout<<g<<"\n";
                    if(y[i-1][g]+1==x)
                    {
                        g--;
                        break;
                    }
                    g--;
                }
                //cout<<x<<" "<<g<<"\n";
            }
            for(int r=0;r<=g;r++)
            y[i].pb(y[i-1][r]);
            y[i].pb(x);
        }
        //cout<<y[2].size()<<"\n";
        for(int i=0;i<n;i++)
        {
            //cout<<y[i].size()<<"\n";
            //cout<<y[i][0]<<"\n";
            cout<<y[i][0];
            for(int j=1;j<y[i].size();j++)
            {
                cout<<"."<<y[i][j];
                //cout<<"\n";
            }
            cout<<"\n";
        }
    }
}