William is a huge fan of planning ahead. That is why he starts his morning routine by creating a nested list of upcoming errands.

A valid nested list is any list which can be created from a list with one item "1" by applying some operations. Each operation inserts a new item into the list, on a new line, just after one of existing items $a_1 \,.\, a_2 \,.\, a_3 \,.\, \,\cdots\, \,.\,a_k$ and can be one of two types:

Add an item $a_1 \,.\, a_2 \,.\, a_3 \,.\, \cdots \,.\, a_k \,.\, 1$ (starting a list of a deeper level), or

Add an item $a_1 \,.\, a_2 \,.\, a_3 \,.\, \cdots \,.\, (a_k + 1)$ (continuing the current level).

Operation can only be applied if the list does not contain two identical items afterwards. And also, if we consider every item as a sequence of numbers, then the sequence of items should always remain increasing in lexicographical order. Examples of valid and invalid lists that are shown in the picture can found in the "Notes" section.

When William decided to save a Word document with the list of his errands he accidentally hit a completely different keyboard shortcut from the "Ctrl-S" he wanted to hit. It's not known exactly what shortcut he pressed but after triggering it all items in the list were replaced by a single number: the last number originally written in the item number.

William wants you to help him restore a fitting original nested list.


-----Input-----

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10$). Description of the test cases follows.

The first line of each test case contains a single integer $n$ ($1 \le n \le 10^3$), which is the number of lines in the list.

Each of the next $n$ lines contains a single integer $a_i$ ($1 \le a_i \le n$), which is what remains of William's nested list.

It is guaranteed that in each test case at least one fitting list exists.

It is guaranteed that the sum of values $n$ across all test cases does not exceed $10^3$.


-----Output-----

For each test case output $n$ lines which represent a valid nested list, which could become the data provided to you by William.

If there are multiple answers, print any.


-----Examples-----

Input
2
4
1
1
2
3
9
1
1
1
2
2
1
2
1
2
Output
1
1.1
1.2
1.3
1
1.1
1.1.1
1.1.2
1.2
1.2.1
2
2.1
2.2


-----Note-----

In the second example test case one example of a fitting list is:

1

1.1

1.1.1

1.1.2

1.2

1.2.1

2

2.1

2.2

This list can be produced by using the sequence of operations shown below:

Original list with a single item $1$.

Insert item $2$ by using the insertion operation of the second type after item $1$.

Insert item $1.1$ by using the insertion operation of the first type after item $1$.

Insert item $1.2$ by using the insertion operation of the second type after item $1.1$.

Insert item $1.1.1$ by using the insertion operation of the first type after item $1.1$.

Insert item $1.1.2$ by using the insertion operation of the second type after item $1.1.1$.

Insert item $1.2.1$ by using the insertion operation of the first type after item $1.2$.

Insert item $2.1$ by using the insertion operation of the first type after item $2$.

Insert item $2.2$ by using the insertion operation of the second type after item $2.1$.

Difficulty: MEDIUM_HARD
Tags: Implementation

Greedy algorithms

Complete search

Tree algorithms

Data structures
Skill types: Complete search

Data structures

Greedy algorithms
Expected Time Complexity: O(N^3)

Starter code:

Solutions:
import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	ans = []
	for _ in range(n):
		a = int(input())
		if not ans:
			ans.append(a)
		elif a == 1:
			ans.append(a)
		else:
			while not ans[-1] + 1 == a:
				ans.pop()
			ans[-1] += 1
		print('.'.join(map(str, ans)))


import math, sys, heapq
for t in range(int(input())):
	n = int(input())
	a = []
	for i in range(n):
		x = int(input())
		if x == 1:
			a.append(1)
		else:
			while 1:
				y = a.pop()
				if y + 1 == x:
					a.append(x)
					break
		print(*a, sep='.')


import sys, os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
for _ in range(int(input())):
	n = int(input())
	ans = []
	a = [[] for i in range(n)]
	cnt = 0
	s = []
	for i in range(n):
		c = int(input())
		if c == 1:
			a[i].append(1)
		else:
			while c != a[i][-1] + 1:
				a[i].pop()
			a[i][-1] = c
		if i != n - 1:
			a[i + 1] = a[i][:]
	for i in a:
		for j in range(len(i) - 1):
			print(i[j], end='.')
		print(i[-1])


import os
import sys
from io import BytesIO, IOBase
import math
from queue import Queue
import collections
import itertools
import bisect
import heapq
import random

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	return l

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def countcon(s, i):
	c = 0
	ch = s[i]
	for i in range(i, len(s)):
		if s[i] == ch:
			c += 1
		else:
			break
	return c

def lis(arr):
	n = len(arr)
	lis = [1] * n
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] > arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
	maximum = 0
	for i in range(n):
		maximum = max(maximum, lis[i])
	return maximum

def isSubSequence(str1, str2):
	m = len(str1)
	n = len(str2)
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m

def maxfac(n):
	root = int(n ** 0.5)
	for i in range(2, root + 1):
		if n % i == 0:
			return n // i
	return n

def p2(n):
	c = 0
	while n % 2 == 0:
		n //= 2
		c += 1
	return c

def seive(n):
	primes = [True] * (n + 1)
	primes[1] = primes[0] = False
	i = 2
	while i * i <= n:
		if primes[i] == True:
			for j in range(i * i, n + 1, i):
				primes[j] = False
		i += 1
	pr = []
	for i in range(0, n + 1):
		if primes[i]:
			pr.append(i)
	return pr

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def denofactinverse(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return pow(fac, m - 2, m)

def numofact(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return fac

def sod(n):
	s = 0
	while n > 0:
		s += n % 10
		n //= 10
	return s
for xyz in range(0, int(input())):
	n = int(input())
	l = []
	for i in range(0, n):
		l.append(int(input()))
	ans = []
	st = []
	for i in range(0, n):
		if l[i] == 1:
			st.append(1)
			cas = ''
			for i in range(0, len(st)):
				cas += str(st[i])
				cas += '.'
			ans.append(cas[:-1])
		else:
			while st[-1] != l[i] - 1:
				st.pop()
			st.pop()
			st.append(l[i])
			cas = ''
			for i in range(0, len(st)):
				cas += str(st[i])
				cas += '.'
			ans.append(cas[:-1])
	for i in ans:
		print(i)


for tc in range(int(input())):
	n = int(input())
	lisT = []
	ans = []
	leN = 0
	for i in range(n):
		a = int(input())
		while 1:
			if a == 1:
				lisT.append(1)
				ans.append('.'.join((str(k) for k in lisT)))
				break
			if a == lisT[-1] + 1:
				lisT[-1] += 1
				ans.append('.'.join((str(k) for k in lisT)))
				break
			lisT.pop()
	for i in ans:
		print(i)


class Node:

	def __init__(self, value, parent):
		self.value = value
		self.parent = parent

def solve(n, A):
	tree = Node(int(A[0]), None)
	ans = [A[0]]
	node = tree
	for a in A[1:]:
		a_i = int(a)
		if a == '1':
			new_node = Node(a_i, node)
			node = new_node
		else:
			while True:
				if node.value == a_i - 1:
					new_node = Node(a_i, node.parent)
					node = new_node
					break
				else:
					node = node.parent
		token = []
		_node = node
		while _node is not None:
			token.append(str(_node.value))
			_node = _node.parent
		ans.append('.'.join(token[::-1]))
	return ans

def main():
	ans = []
	t = int(input())
	for _ in range(t):
		n = int(input())
		A = [input() for _ in range(n)]
		ans.append(solve(n, A))
	for a in ans:
		for c in a:
			print(c)
main()


def solve(n):
	prev = 1
	s = []
	for i in range(n):
		curr = int(input())
		if i == 0:
			print(curr)
			s.append(str(curr))
			continue
		elif curr == prev + 1:
			s[-1] = str(curr)
			print('.'.join(s))
			prev = curr
			continue
		elif curr == 1:
			s.append(str(curr))
			print('.'.join(s))
			prev = curr
			continue
		else:
			for i in range(len(s)):
				if int(s[len(s) - 1 - i]) + 1 == curr:
					del s[len(s) - 1 - i:len(s)]
					s.append(str(curr))
					prev = curr
					print('.'.join(s))
					break
t = int(input())
for i in range(t):
	n = int(input())
	solve(n)


import sys, math
import io, os
from bisect import bisect_left as bl, bisect_right as br, insort
from collections import defaultdict as dd, deque, Counter

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write('\n'.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
INF = float('inf')
mod = int(1000000000.0) + 7
for t in range(int(data())):
	n = int(data())
	l = []
	v = []
	for a in range(n):
		i = int(data())
		if i == 1:
			v.append('1.')
			l.append(1)
		else:
			while l:
				v.pop()
				if i - l.pop() == 1:
					break
			l.append(i)
			v.append(str(i) + '.')
		v1 = ''.join(v)
		out(v1[:len(v1) - 1])


import math
from functools import reduce
from math import comb
from collections import defaultdict
from sys import stdout
NO = 'NO'
YES = 'YES'
MOD = 1000000007
ALPH = 'abcdefghijklmnopqrstuvwxyz'

def input_int():
	return int(input())

def input_list():
	return input().split(' ')

def input_list_int():
	return list(map(int, input_list()))

def list_int_to_str(a, sep=' '):
	return sep.join((str(x) for x in a))
global_ans = []

def pr(a):
	global_ans.append(a)

def solve():
	n = input_int()
	ans = []
	for i in range(n):
		item = input_int()
		if item == 1:
			ans.append(1)
			pr(list_int_to_str(ans, '.'))
		else:
			for j in range(len(ans) - 1, -1, -1):
				if ans[j] + 1 == item:
					ans[j] = item
					ans = ans[0:j + 1]
					pr(list_int_to_str(ans, '.'))
					break
query_count = 1
query_count = input_int()
while query_count:
	query_count -= 1
	solve()
for global_ans_line in global_ans:
	print(global_ans_line)


def arr_in():
	return list(map(int, input().split()))

def mapIn():
	return map(int, input().split())
for ii in range(int(input())):
	n = int(input())
	x = int(input())
	a = [1]
	print(1)
	for i in range(n - 1):
		x = int(input())
		if x == a[-1] + 1:
			a[-1] = x
		elif x == 1:
			a.append(x)
		elif x != 1 and x != a[-1] + 1:
			while len(a) != 0 and x != a[-1] + 1:
				a.pop()
			a[-1] = x
		s = ''
		for y in a:
			s += str(y) + '.'
		print(s[:len(s) - 1])


t = int(input())
for _ in range(t):
	n = int(input())
	stack = []
	for i in range(n):
		ai = int(input())
		if ai == 1:
			stack.append(ai)
		else:
			while ai - stack[-1] != 1:
				stack.pop()
			stack.pop()
			stack.append(ai)
		for j in range(len(stack)):
			if j > 0:
				print('.', end='')
			print(stack[j], end='')
		print()


for _ in range(int(input())):
	n = int(input())
	l = []
	for i in range(n):
		l.append(int(input()))
	ans = ['1']
	temp = ['1']
	for i in range(1, n):
		if l[i] == 1:
			x = ans[-1] + '.' + str(1)
			ans.append(x)
			temp.append(x)
		elif l[i] == l[i - 1] + 1:
			tt = ans[-1].split('.')
			tt.pop(-1)
			tt.append(str(l[i]))
			x = '.'.join(tt)
			ans.append(x)
			temp.append(x)
		else:
			while True:
				if int(temp[-1].split('.')[-1]) == l[i] - 1:
					break
				else:
					x = len(temp[-1].split('.'))
					while len(temp[-1].split('.')) == x:
						temp.pop(-1)
			tt = temp[-1].split('.')
			tt.pop(-1)
			tt.append(str(l[i]))
			x = '.'.join(tt)
			ans.append(x)
			temp.append(x)
	for i in ans:
		print(i)


for _ in range(int(input())):
	n = int(input())
	arr = [int(input()) for i in range(n)]
	ans = [['1']]
	st = [['1']]
	for i in arr[1:]:
		if i == 1:
			p = st[-1][:]
			st.append(p + ['.', '1'])
			ans.append(p + ['.', '1'])
		else:
			v = 10 ** 9
			while st:
				if int(st[-1][-1]) == i:
					v = len(st[-1])
					st.pop()
				elif i - int(st[-1][-1]) == 1:
					if len(st[-1]) < v:
						break
					else:
						st.pop()
				else:
					st.pop()
			if st:
				p = st[-1][:]
				p[-1] = str(i)
				st.append(p)
				ans.append(p)
			else:
				ans.append(str(i))
				st.append(str(i))
	for i in ans:
		print(''.join(i))


from bisect import bisect, bisect_left
from collections import *
from heapq import *
from math import gcd, ceil, sqrt, floor, inf
from itertools import *
from operator import add, mul, sub, xor, truediv, floordiv
from functools import *
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().split())

def RLL():
	return list(map(int, sys.stdin.readline().split()))

def N():
	return int(input())

def A(n):
	return [0] * n

def AI(n, x):
	return [x] * n

def A2(n, m):
	return [[0] * m for i in range(n)]

def G(n):
	return [[] for i in range(n)]

def GP(it):
	return [[ch, len(list(g))] for (ch, g) in groupby(it)]
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
mod = 10 ** 9 + 7
farr = [1]
ifa = []

def fact(x, mod=0):
	if mod:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr) % mod)
	else:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr))
	return farr[x]

def ifact(x, mod):
	global ifa
	fact(x, mod)
	ifa.append(pow(farr[-1], mod - 2, mod))
	for i in range(x, 0, -1):
		ifa.append(ifa[-1] * i % mod)
	ifa.reverse()

def per(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return fact(i) // fact(i - j)
	return farr[i] * ifa[i - j] % mod

def com(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return per(i, j) // fact(j)
	return per(i, j, mod) * ifa[j] % mod

def catalan(n):
	return com(2 * n, n) // (n + 1)

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def floorsum(a, b, c, n):
	if a == 0:
		return b // c * (n + 1)
	if a >= c or b >= c:
		return floorsum(a % c, b % c, c, n) + b // c * (n + 1) + a // c * n * (n + 1) // 2
	m = (a * n + b) // c
	return n * m - floorsum(c, c - b - 1, a, m - 1)

def inverse(a, m):
	a %= m
	if a <= 1:
		return a
	return (1 - inverse(m, a) * m) // a % m

def lowbit(n):
	return n & -n

class BIT:

	def __init__(self, arr):
		self.arr = arr
		self.n = len(arr) - 1

	def update(self, x, v):
		while x <= self.n:
			self.arr[x] += v
			x += x & -x

	def query(self, x):
		ans = 0
		while x:
			ans += self.arr[x]
			x &= x - 1
		return ans

class ST:

	def __init__(self, arr):
		n = len(arr)
		mx = n.bit_length()
		self.st = [[0] * mx for i in range(n)]
		for i in range(n):
			self.st[i][0] = arr[i]
		for j in range(1, mx):
			for i in range(n - (1 << j) + 1):
				self.st[i][j] = max(self.st[i][j - 1], self.st[i + (1 << j - 1)][j - 1])

	def query(self, l, r):
		if l > r:
			return -inf
		s = (r + 1 - l).bit_length() - 1
		return max(self.st[l][s], self.st[r - (1 << s) + 1][s])

class DSU:

	def __init__(self, n):
		self.c = [-1] * n

	def same(self, x, y):
		return self.find(x) == self.find(y)

	def find(self, x):
		if self.c[x] < 0:
			return x
		self.c[x] = self.find(self.c[x])
		return self.c[x]

	def union(self, u, v):
		(u, v) = (self.find(u), self.find(v))
		if u == v:
			return False
		if self.c[u] > self.c[v]:
			(u, v) = (v, u)
		self.c[u] += self.c[v]
		self.c[v] = u
		return True

	def size(self, x):
		return -self.c[self.find(x)]

class UFS:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.ranks = [0] * n

	def find(self, x):
		if x != self.parent[x]:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, u, v):
		(pu, pv) = (self.find(u), self.find(v))
		if pu == pv:
			return False
		if self.ranks[pu] >= self.ranks[pv]:
			self.parent[pv] = pu
			if self.ranks[pv] == self.ranks[pu]:
				self.ranks[pu] += 1
		else:
			self.parent[pu] = pv

class UF:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.ranks = [0] * n
		self.size = AI(n, 1)
		self.edge = A(n)

	def find(self, x):
		if x != self.parent[x]:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, u, v):
		(pu, pv) = (self.find(u), self.find(v))
		if pu == pv:
			self.edge[pu] += 1
			return False
		if self.ranks[pu] >= self.ranks[pv]:
			self.parent[pv] = pu
			self.edge[pu] += self.edge[pv] + 1
			self.size[pu] += self.size[pv]
			if self.ranks[pv] == self.ranks[pu]:
				self.ranks[pu] += 1
		else:
			self.parent[pu] = pv
			self.edge[pv] += self.edge[pu] + 1
			self.size[pv] += self.size[pu]

def Prime(n):
	c = 0
	prime = []
	flag = [0] * (n + 1)
	for i in range(2, n + 1):
		if not flag[i]:
			prime.append(i)
			c += 1
		for j in range(c):
			if i * prime[j] > n:
				break
			flag[i * prime[j]] = prime[j]
			if i % prime[j] == 0:
				break
	return flag

def dij(s, graph):
	d = AI(n, inf)
	d[s] = 0
	heap = [(0, s)]
	vis = A(n)
	while heap:
		(dis, u) = heappop(heap)
		if vis[u]:
			continue
		vis[u] = 1
		for (v, w) in graph[u]:
			if d[v] > d[u] + w:
				d[v] = d[u] + w
				heappush(heap, (d[v], v))
	return d

def bell(s, g):
	dis = AI(n, inf)
	dis[s] = 0
	for i in range(n - 1):
		for (u, v, w) in edge:
			if dis[v] > dis[u] + w:
				dis[v] = dis[u] + w
	change = A(n)
	for i in range(n):
		for (u, v, w) in edge:
			if dis[v] > dis[u] + w:
				dis[v] = dis[u] + w
				change[v] = 1
	return dis

def lcm(a, b):
	return a * b // gcd(a, b)

def lis(nums):
	res = []
	for k in nums:
		i = bisect.bisect_left(res, k)
		if i == len(res):
			res.append(k)
		else:
			res[i] = k
	return len(res)

def RP(nums):
	n = len(nums)
	s = set(nums)
	d = {}
	for (i, k) in enumerate(sorted(s), 1):
		d[k] = i
	bi = BIT([0] * (len(s) + 1))
	ans = 0
	for i in range(n - 1, -1, -1):
		ans += bi.query(d[nums[i]] - 1)
		bi.update(d[nums[i]], 1)
	return ans

def michange(a, b):
	d = defaultdict(deque)
	for (i, x) in enumerate(b):
		d[x].append(i)
	order = A(len(a))
	for (i, x) in enumerate(a):
		if not d:
			return -1
		order[i] = d[x].popleft()
	return RP(order)

class DLN:

	def __init__(self, val):
		self.val = val
		self.pre = None
		self.next = None

def nb(i, j, n, m):
	for (ni, nj) in [[i + 1, j], [i - 1, j], [i, j - 1], [i, j + 1]]:
		if 0 <= ni < n and 0 <= nj < m:
			yield (ni, nj)

def topo(n):
	q = deque()
	res = []
	for i in range(1, n + 1):
		if ind[i] == 0:
			q.append(i)
			res.append(i)
	while q:
		u = q.popleft()
		for v in g[u]:
			ind[v] -= 1
			if ind[v] == 0:
				q.append(v)
				res.append(v)
	return res

@bootstrap
def gdfs(r, p):
	for ch in g[r]:
		if ch != p:
			yield gdfs(ch, r)
	yield None
t = N()
for i in range(t):
	n = N()
	a = N()
	ans = ['1']
	stk = ['1']
	for i in range(n - 1):
		cur = N()
		if cur == 1:
			stk.append(str(cur))
			ans.append('.'.join(stk))
		else:
			while int(stk[-1]) != cur - 1:
				stk.pop()
			stk[-1] = str(cur)
			ans.append('.'.join(stk))
	for ch in ans:
		print(ch)


t = int(input())
for _ in range(t):
	stack = []
	n = int(input())
	for i in range(n):
		a = int(input())
		if a == 1:
			stack.append(a)
			print('.'.join(map(str, stack)))
		else:
			last = stack.pop()
			while a != last + 1:
				last = stack.pop()
			stack.append(a)
			print('.'.join(map(str, stack)))


from collections import deque

def print_deque(stack):
	print('.'.join([str(s) for s in list(stack)]))

def empty_stack(stack, num):
	while len(stack) > 0:
		if stack[-1] == num - 1:
			stack.pop()
			break
		stack.pop()
	return stack
T = int(input())
for t in range(T):
	stack = deque()
	n = int(input())
	for i in range(n):
		num = int(input())
		if len(stack) == 0:
			stack.append(num)
			print_deque(stack)
		elif num == 1:
			stack.append(num)
			print_deque(stack)
		else:
			empty_stack(stack, num)
			stack.append(num)
			print_deque(stack)


import os
import sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		n = int(input())
		prev = [int(input())]
		ans = [[1]]
		for i in range(1, n):
			z = int(input())
			if z == 1:
				prev.append(1)
			else:
				while prev[-1] != z - 1:
					prev.pop()
					if not prev:
						break
				if prev:
					prev[-1] += 1
				else:
					prev = [z]
			ans.append(prev.copy())
		for item in ans:
			print(*item, sep='.')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	n = int(input())
	b = [0 for i in range(1007)]
	p = -1
	for i in range(n):
		a = int(input())
		if a > 1:
			while b[p] != a - 1:
				p -= 1
			p -= 1
		p += 1
		b[p] = a
		print(*b[:p + 1], sep='.')


for _ in range(int(input())):
	n = int(input())
	d = []
	for i in range(n):
		k = int(input())
		if k == 1:
			d.append(1)
		else:
			while d[-1] != k - 1:
				d.pop()
			q = d.pop()
			d.append(q + 1)
		print('.'.join(map(str, d)))


for _ in range(int(input())):
	N = int(input())
	S = []
	for _ in range(N):
		x = int(input())
		if x == 1:
			S.append(x)
		else:
			while S and S[-1] != x - 1:
				S.pop()
			assert S
			S[-1] = x
		print('.'.join(map(str, S)))


t = int(input())
for _ in range(t):
	n = int(input())
	a = []
	for _ in range(n):
		k = int(input())
		if k == 1:
			a.append(k)
		else:
			while a[-1] != k - 1:
				a.pop()
			a[-1] = k
		print(*a, sep='.')


t = int(input())

def print_ol():
	n = int(input())
	levels = []
	for i in range(n):
		x = int(input())
		if x == 1:
			levels.append(1)
		else:
			while levels[-1] + 1 != x:
				levels.pop()
			levels[-1] += 1
		print('.'.join(list(map(str, levels))))
for j in range(t):
	print_ol()


for _ in range(int(input())):
	n = int(input())
	x = int(input())
	l = [1]
	print(1)
	for i in range(1, n):
		x = int(input())
		if x == 1:
			l.append(1)
		else:
			j = len(l) - 1
			while j >= 0:
				if x == l[j] + 1:
					l[j] += 1
					break
				j -= 1
			l = l[:j + 1]
		for j in range(len(l) - 1):
			print(l[j], end='.')
		print(l[-1])


import sys
from math import gcd, sqrt
sys.setrecursionlimit(10 ** 5)
inf = float('inf')
en = lambda x: list(enumerate(x))
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())

def solve():
	n = ii()
	arr = []
	for _ in range(n):
		x = ii()
		if not arr:
			arr += (x,)
		elif x == 1:
			arr += (x,)
		else:
			while arr and arr[-1] != x - 1:
				arr.pop()
			if arr:
				arr.pop()
			arr += (x,)
		print('.'.join((str(i) for i in arr)))
for _ in range(ii()):
	solve()


for _ in range(int(input())):
	n = int(input())
	stack = []
	ans = []
	for i in range(n):
		pooh = int(input())
		if pooh == 1:
			stack.append(pooh)
		else:
			while stack:
				if stack[len(stack) - 1] + 1 == pooh:
					stack[len(stack) - 1] = pooh
					break
				else:
					stack.pop()
			if not stack:
				stack.append(pooh)
		b = stack.copy()
		ans.append(b)
	for i in ans:
		print(*i, sep='.')


t = int(input())
while int(t) > 0:
	n = int(input())
	v = []
	while n > 0:
		char = int(input())
		if len(v) == 0 or char == 1:
			v.append(char)
		else:
			for i in range(len(v) - 1, -1, -1):
				if char == v[i] + 1:
					v[i] = char
					break
				v.pop()
		print('.'.join(map(str, v)))
		n = n - 1
	t = t - 1


t = int(input())
for _ in range(t):
	n = int(input())
	arr = ['', '1']
	a = int(input())
	print(1)
	for __ in range(n - 1):
		a = int(input())
		if a == 1:
			print(arr[-1] + '.1')
			arr.append(arr[-1] + '.1')
		elif int(arr[-1][-1]) + 1 == a:
			arr[-1] = arr[-1][:arr[-1].rfind('.') + 1] + str(a)
			print(arr[-1])
		else:
			while int(arr[-1][arr[-1].rfind('.') + 1:]) != a - 1:
				arr.pop()
			print(arr[-1][:arr[-1].rfind('.') + 1] + str(a))
			arr[-1] = arr[-1][:arr[-1].rfind('.') + 1] + str(a)


for _ in range(int(input())):
	ondszgv = 52
	n = int(input())
	adsd = 52645
	input()
	ddf = 21
	a = ['1']
	z52 = 56
	print('1')
	fv = 85
	for __ in range(n - 1):
		yh = 215
		t = int(input())
		th = 85
		if t == 1:
			ff = 98
			a.append('1')
		else:
			while int(a[-1]) + 1 != t:
				jk = 527
				a.pop()
			a[-1] = str(int(a[-1]) + 1)
		hh = 87
		print('.'.join(a))


import sys, io, os
input = sys.stdin.readline
t = 1

def get_list():
	return [int(i) for i in input().split()]
inf = float('inf')
t = int(input())
for i in range(t):
	n = int(input())
	l = []
	for i in range(n):
		l.append(int(input()))
	stack = []
	for i in range(n):
		if l[i] == 1:
			stack.append(1)
		else:
			while stack and l[i] != stack[-1] + 1:
				stack.pop()
			stack[-1] += 1
		print(*stack, sep='.')


def index_finder1(result):
	for i in range(len(result) - 1, -1, -1):
		if result[i] == '.':
			break
	return i + 1

def index_finder3(target, result):
	temp = 0
	for i in range(len(result)):
		j = result.find(target, i)
		if j > temp:
			temp = j
	return temp

def index_finder2(item, result):
	for i in reversed(result.split('.')):
		if item - int(i) == 1:
			result = result[:index_finder3(i, result)] + str(item)
			break
	return result
t = int(input())
for i in range(t):
	n = int(input())
	shopping = []
	for i in range(n):
		j = int(input())
		shopping.append(j)
	result = ''
	for i in range(n):
		if i == 0 and shopping[i] == 1:
			result = str(shopping[i])
		elif shopping[i] == 1:
			result = result + '.1'
		elif shopping[i] - shopping[i - 1] == 1:
			if '.' not in result:
				result = str(shopping[i])
			else:
				result = result[:index_finder1(result)] + str(shopping[i])
		else:
			result = index_finder2(shopping[i], result)
		print(result)


for _ in range(int(input())):
	n = int(input())
	ar = [0]
	for i in range(n):
		x = int(input())
		pos = -1
		for j in range(len(ar) - 1, 0, -1):
			if ar[j] == x - 1:
				pos = j
				break
		if pos != -1:
			for j in range(len(ar) - pos):
				ar.pop()
		ar.append(x)
		for j in range(1, len(ar) - 1):
			print(ar[j], end='.')
		print(ar[-1])


import os, sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 998244353
from math import ceil, gcd, log2
for _ in range(int(input())):
	n = int(input())
	input()
	a = ['1']
	print('1')
	for __ in range(n - 1):
		t = int(input())
		if t == 1:
			a.append('1')
		else:
			while int(a[-1]) + 1 != t:
				a.pop()
			a[-1] = str(int(a[-1]) + 1)
		print('.'.join(a))


for _ in range(int(input())):
	n = int(input())
	a = []
	for i in range(n):
		m = int(input())
		if m == 1:
			a.append(m)
		else:
			while a[-1] != m - 1:
				a.pop()
			a.pop()
			a.append(m)
		print('.'.join(map(str, a)))


import sys
import math
import collections
import heapq
input = sys.stdin.readline
t = int(input())
for w in range(t):
	n = int(input())
	s = []
	k = 0
	for i in range(n):
		a = int(input())
		if s == []:
			s.append(a)
			k += 1
		elif a == 1:
			s.append('.')
			s.append(1)
		else:
			for j in range(len(s) - 1, -1, -1):
				if s[j] != '.':
					if s[j] + 1 == a:
						s = s[:j]
						s.append(a)
						break
		for j in range(len(s)):
			print(s[j], end='')
		print()


def divisors(M):
	d = []
	i = 1
	while M >= i ** 2:
		if M % i == 0:
			d.append(i)
			if i ** 2 != M:
				d.append(M // i)
		i = i + 1
	return d

def popcount(x):
	x = x - (x >> 1 & 1431655765)
	x = (x & 858993459) + (x >> 2 & 858993459)
	x = x + (x >> 4) & 252645135
	x = x + (x >> 8)
	x = x + (x >> 16)
	return x & 127

def eratosthenes(n):
	res = [0 for i in range(n + 1)]
	prime = set([])
	for i in range(2, n + 1):
		if not res[i]:
			prime.add(i)
			for j in range(1, n // i + 1):
				res[i * j] = 1
	return prime

def factorization(n):
	res = []
	for p in prime:
		if n % p == 0:
			while n % p == 0:
				n //= p
			res.append(p)
	if n != 1:
		res.append(n)
	return res

def euler_phi(n):
	res = n
	for x in range(2, n + 1):
		if x ** 2 > n:
			break
		if n % x == 0:
			res = res // x * (x - 1)
			while n % x == 0:
				n //= x
	if n != 1:
		res = res // n * (n - 1)
	return res

def ind(b, n):
	res = 0
	while n % b == 0:
		res += 1
		n //= b
	return res

def isPrimeMR(n):
	d = n - 1
	d = d // (d & -d)
	L = [2, 3, 5, 7, 11, 13, 17]
	for a in L:
		t = d
		y = pow(a, t, n)
		if y == 1:
			continue
		while y != n - 1:
			y = y * y % n
			if y == 1 or t == n - 1:
				return 0
			t <<= 1
	return 1

def findFactorRho(n):
	from math import gcd
	m = 1 << n.bit_length() // 8
	for c in range(1, 99):
		f = lambda x: (x * x + c) % n
		(y, r, q, g) = (2, 1, 1, 1)
		while g == 1:
			x = y
			for i in range(r):
				y = f(y)
			k = 0
			while k < r and g == 1:
				ys = y
				for i in range(min(m, r - k)):
					y = f(y)
					q = q * abs(x - y) % n
				g = gcd(q, n)
				k += m
			r <<= 1
		if g == n:
			g = 1
			while g == 1:
				ys = f(ys)
				g = gcd(abs(x - ys), n)
		if g < n:
			if isPrimeMR(g):
				return g
			elif isPrimeMR(n // g):
				return n // g
			return findFactorRho(g)

def primeFactor(n):
	i = 2
	ret = {}
	rhoFlg = 0
	while i * i <= n:
		k = 0
		while n % i == 0:
			n //= i
			k += 1
		if k:
			ret[i] = k
		i += 1 + i % 2
		if i == 101 and n >= 2 ** 20:
			while n > 1:
				if isPrimeMR(n):
					(ret[n], n) = (1, 1)
				else:
					rhoFlg = 1
					j = findFactorRho(n)
					k = 0
					while n % j == 0:
						n //= j
						k += 1
					ret[j] = k
	if n > 1:
		ret[n] = 1
	if rhoFlg:
		ret = {x: ret[x] for x in sorted(ret)}
	return ret

def divisors(n):
	res = [1]
	prime = primeFactor(n)
	for p in prime:
		newres = []
		for d in res:
			for j in range(prime[p] + 1):
				newres.append(d * p ** j)
		res = newres
	res.sort()
	return res

def xorfactorial(num):
	if num == 0:
		return 0
	elif num == 1:
		return 1
	elif num == 2:
		return 3
	elif num == 3:
		return 0
	else:
		x = baseorder(num)
		return 2 ** x * ((num - 2 ** x + 1) % 2) + function(num - 2 ** x)

def xorconv(n, X, Y):
	if n == 0:
		res = [X[0] * Y[0] % mod]
		return res
	x = [X[i] + X[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	y = [Y[i] + Y[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	z = [X[i] - X[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	w = [Y[i] - Y[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	res1 = xorconv(n - 1, x, y)
	res2 = xorconv(n - 1, z, w)
	former = [(res1[i] + res2[i]) * inv for i in range(2 ** (n - 1))]
	latter = [(res1[i] - res2[i]) * inv for i in range(2 ** (n - 1))]
	former = list(map(lambda x: x % mod, former))
	latter = list(map(lambda x: x % mod, latter))
	return former + latter

def merge_sort(A, B):
	(pos_A, pos_B) = (0, 0)
	(n, m) = (len(A), len(B))
	res = []
	while pos_A < n and pos_B < m:
		(a, b) = (A[pos_A], B[pos_B])
		if a < b:
			res.append(a)
			pos_A += 1
		else:
			res.append(b)
			pos_B += 1
	res += A[pos_A:]
	res += B[pos_B:]
	return res

class UnionFindVerSize:

	def __init__(self, N):
		self._parent = [n for n in range(0, N)]
		self._size = [1] * N
		self.group = N

	def find_root(self, x):
		if self._parent[x] == x:
			return x
		self._parent[x] = self.find_root(self._parent[x])
		stack = [x]
		while self._parent[stack[-1]] != stack[-1]:
			stack.append(self._parent[stack[-1]])
		for v in stack:
			self._parent[v] = stack[-1]
		return self._parent[x]

	def unite(self, x, y):
		gx = self.find_root(x)
		gy = self.find_root(y)
		if gx == gy:
			return
		self.group -= 1
		if self._size[gx] < self._size[gy]:
			self._parent[gx] = gy
			self._size[gy] += self._size[gx]
		else:
			self._parent[gy] = gx
			self._size[gx] += self._size[gy]

	def get_size(self, x):
		return self._size[self.find_root(x)]

	def is_same_group(self, x, y):
		return self.find_root(x) == self.find_root(y)

class WeightedUnionFind:

	def __init__(self, N):
		self.parent = [i for i in range(N)]
		self.size = [1 for i in range(N)]
		self.val = [0 for i in range(N)]
		self.flag = True
		self.edge = [[] for i in range(N)]

	def dfs(self, v, pv):
		stack = [(v, pv)]
		new_parent = self.parent[pv]
		while stack:
			(v, pv) = stack.pop()
			self.parent[v] = new_parent
			for (nv, w) in self.edge[v]:
				if nv != pv:
					self.val[nv] = self.val[v] + w
					stack.append((nv, v))

	def unite(self, x, y, w):
		if not self.flag:
			return
		if self.parent[x] == self.parent[y]:
			self.flag = self.val[x] - self.val[y] == w
			return
		if self.size[self.parent[x]] > self.size[self.parent[y]]:
			self.edge[x].append((y, -w))
			self.edge[y].append((x, w))
			self.size[x] += self.size[y]
			self.val[y] = self.val[x] - w
			self.dfs(y, x)
		else:
			self.edge[x].append((y, -w))
			self.edge[y].append((x, w))
			self.size[y] += self.size[x]
			self.val[x] = self.val[y] + w
			self.dfs(x, y)

class Dijkstra:

	class Edge:

		def __init__(self, _to, _cost):
			self.to = _to
			self.cost = _cost

	def __init__(self, V):
		self.G = [[] for i in range(V)]
		self._E = 0
		self._V = V

	@property
	def E(self):
		return self._E

	@property
	def V(self):
		return self._V

	def add_edge(self, _from, _to, _cost):
		self.G[_from].append(self.Edge(_to, _cost))
		self._E += 1

	def shortest_path(self, s):
		import heapq
		que = []
		d = [10 ** 15] * self.V
		d[s] = 0
		heapq.heappush(que, (0, s))
		while len(que) != 0:
			(cost, v) = heapq.heappop(que)
			if d[v] < cost:
				continue
			for i in range(len(self.G[v])):
				e = self.G[v][i]
				if d[e.to] > d[v] + e.cost:
					d[e.to] = d[v] + e.cost
					heapq.heappush(que, (d[e.to], e.to))
		return d

def Z_algorithm(s):
	N = len(s)
	Z_alg = [0] * N
	Z_alg[0] = N
	i = 1
	j = 0
	while i < N:
		while i + j < N and s[j] == s[i + j]:
			j += 1
		Z_alg[i] = j
		if j == 0:
			i += 1
			continue
		k = 1
		while i + k < N and k + Z_alg[k] < j:
			Z_alg[i + k] = Z_alg[k]
			k += 1
		i += k
		j -= k
	return Z_alg

class BIT:

	def __init__(self, n, mod=0):
		self.BIT = [0] * (n + 1)
		self.num = n
		self.mod = mod

	def query(self, idx):
		res_sum = 0
		mod = self.mod
		while idx > 0:
			res_sum += self.BIT[idx]
			if mod:
				res_sum %= mod
			idx -= idx & -idx
		return res_sum

	def update(self, idx, x):
		mod = self.mod
		while idx <= self.num:
			self.BIT[idx] += x
			if mod:
				self.BIT[idx] %= mod
			idx += idx & -idx
		return

class dancinglink:

	def __init__(self, n, debug=False):
		self.n = n
		self.debug = debug
		self._left = [i - 1 for i in range(n)]
		self._right = [i + 1 for i in range(n)]
		self.exist = [True for i in range(n)]

	def pop(self, k):
		if self.debug:
			assert self.exist[k]
		L = self._left[k]
		R = self._right[k]
		if L != -1:
			if R != self.n:
				(self._right[L], self._left[R]) = (R, L)
			else:
				self._right[L] = self.n
		elif R != self.n:
			self._left[R] = -1
		self.exist[k] = False

	def left(self, idx, k=1):
		if self.debug:
			assert self.exist[idx]
		res = idx
		while k:
			res = self._left[res]
			if res == -1:
				break
			k -= 1
		return res

	def right(self, idx, k=1):
		if self.debug:
			assert self.exist[idx]
		res = idx
		while k:
			res = self._right[res]
			if res == self.n:
				break
			k -= 1
		return res

class SparseTable:

	def __init__(self, A, merge_func, ide_ele):
		N = len(A)
		n = N.bit_length()
		self.table = [[ide_ele for i in range(n)] for i in range(N)]
		self.merge_func = merge_func
		for i in range(N):
			self.table[i][0] = A[i]
		for j in range(1, n):
			for i in range(0, N - 2 ** j + 1):
				f = self.table[i][j - 1]
				s = self.table[i + 2 ** (j - 1)][j - 1]
				self.table[i][j] = self.merge_func(f, s)

	def query(self, s, t):
		b = t - s + 1
		m = b.bit_length() - 1
		return self.merge_func(self.table[s][m], self.table[t - 2 ** m + 1][m])

class BinaryTrie:

	class node:

		def __init__(self, val):
			self.left = None
			self.right = None
			self.max = val

	def __init__(self):
		self.root = self.node(-10 ** 15)

	def append(self, key, val):
		pos = self.root
		for i in range(29, -1, -1):
			pos.max = max(pos.max, val)
			if key >> i & 1:
				if pos.right is None:
					pos.right = self.node(val)
					pos = pos.right
				else:
					pos = pos.right
			elif pos.left is None:
				pos.left = self.node(val)
				pos = pos.left
			else:
				pos = pos.left
		pos.max = max(pos.max, val)

	def search(self, M, xor):
		res = -10 ** 15
		pos = self.root
		for i in range(29, -1, -1):
			if pos is None:
				break
			if M >> i & 1:
				if xor >> i & 1:
					if pos.right:
						res = max(res, pos.right.max)
					pos = pos.left
				else:
					if pos.left:
						res = max(res, pos.left.max)
					pos = pos.right
			elif xor >> i & 1:
				pos = pos.right
			else:
				pos = pos.left
		if pos:
			res = max(res, pos.max)
		return res

def solveequation(edge, ans, n, m):
	x = [0] * m
	used = [False] * n
	for v in range(n):
		if used[v]:
			continue
		y = dfs(v)
		if y != 0:
			return False
	return x

	def dfs(v):
		used[v] = True
		r = ans[v]
		for (to, dire, id) in edge[v]:
			if used[to]:
				continue
			y = dfs(to)
			if dire == -1:
				x[id] = y
			else:
				x[id] = -y
			r += y
		return r

class SegmentTree:

	def __init__(self, init_val, segfunc, ide_ele):
		n = len(init_val)
		self.segfunc = segfunc
		self.ide_ele = ide_ele
		self.num = 1 << (n - 1).bit_length()
		self.tree = [ide_ele] * 2 * self.num
		self.size = n
		for i in range(n):
			self.tree[self.num + i] = init_val[i]
		for i in range(self.num - 1, 0, -1):
			self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

	def update(self, k, x):
		k += self.num
		self.tree[k] = x
		while k > 1:
			self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
			k >>= 1

	def query(self, l, r):
		if r == self.size:
			r = self.num
		res = self.ide_ele
		l += self.num
		r += self.num
		while l < r:
			if l & 1:
				res = self.segfunc(res, self.tree[l])
				l += 1
			if r & 1:
				res = self.segfunc(res, self.tree[r - 1])
			l >>= 1
			r >>= 1
		return res

	def bisect_l(self, l, r, x):
		l += self.num
		r += self.num
		Lmin = -1
		Rmin = -1
		while l < r:
			if l & 1:
				if self.tree[l] <= x and Lmin == -1:
					Lmin = l
				l += 1
			if r & 1:
				if self.tree[r - 1] <= x:
					Rmin = r - 1
			l >>= 1
			r >>= 1
		if Lmin != -1:
			pos = Lmin
			while pos < self.num:
				if self.tree[2 * pos] <= x:
					pos = 2 * pos
				else:
					pos = 2 * pos + 1
			return pos - self.num
		elif Rmin != -1:
			pos = Rmin
			while pos < self.num:
				if self.tree[2 * pos] <= x:
					pos = 2 * pos
				else:
					pos = 2 * pos + 1
			return pos - self.num
		else:
			return -1
import sys, random, bisect
from collections import deque, defaultdict
from heapq import heapify, heappop, heappush
from itertools import permutations
from math import gcd, log
input = lambda : sys.stdin.readline().rstrip()
mi = lambda : map(int, input().split())
li = lambda : list(mi())
for _ in range(int(input())):
	n = int(input())
	a = [int(input()) for i in range(n)]
	ans = [['1'] for i in range(n)]
	for i in range(1, n):
		if a[i] == 1:
			ans[i] = [s for s in ans[i - 1]] + ['1']
		else:
			m = len(ans[i - 1])
			for j in range(m - 1, -1, -1):
				if int(ans[i - 1][j]) + 1 == a[i]:
					ans[i] = [ans[i - 1][k] for k in range(j + 1)]
					ans[i][-1] = str(a[i])
					break
	for i in range(n):
		print('.'.join(ans[i]))


import random
import collections
import string
import math
import copy
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
mo = 998244353

def exgcd(a, b):
	if not b:
		return (1, 0)
	(y, x) = exgcd(b, a % b)
	y -= a // b * x
	return (x, y)

def getinv(a, m):
	(x, y) = exgcd(a, m)
	return -1 if x == 1 else x % m

def comb(n, b):
	res = 1
	b = min(b, n - b)
	for i in range(b):
		res = res * (n - i) * getinv(i + 1, mo) % mo
	return res % mo

def quickpower(a, n):
	res = 1
	while n:
		if n & 1:
			res = res * a % mo
		n >>= 1
		a = a * a % mo
	return res

def dis(a, b):
	return abs(a[0] - b[0]) + abs(a[1] - b[1])

def getpref(x):
	if x > 1:
		return x * (x - 1) >> 1
	else:
		return 0

def orafli(upp):
	primes = []
	marked = [False for i in range(upp + 3)]
	prvs = [i for i in range(upp + 3)]
	for i in range(2, upp):
		if not marked[i]:
			primes.append(i)
		for j in primes:
			if i * j >= upp:
				break
			marked[i * j] = True
			prvs[i * j] = j
			if i % j == 0:
				break
	return (primes, prvs)

def lower_ord(c: str) -> int:
	return ord(c) - 97

def upper_ord(c: str) -> int:
	return ord(c) - 65

def read_list():
	return [int(i) for i in input().split()]

def read_int():
	s = input().split()
	if len(s) == 1:
		return int(s[0])
	else:
		return map(int, s)

def ask(s):
	print(f'? {s}', flush=True)

def answer(s):
	print(f'{s}', flush=True)
import functools
import itertools
from fractions import Fraction

def solve():
	n = read_int()
	ans = []
	buf = []
	i = 0
	pref = []

	def try_construct(l: list) -> int:
		nonlocal n, i, ans
		while i < n:
			ci = read_int()
			i += 1
			if ci == len(l) + 1:
				l.append([])
				buf.append('.'.join(pref + [f'{len(l)}']))
			elif ci == 1:
				l[-1].append([])
				pref.append(f'{len(l)}')
				buf.append('.'.join(pref + ['1']))
				pi = try_construct(l[-1])
				if pi == len(l) + 1:
					l.append([])
					buf.append('.'.join(pref + [f'{len(l)}']))
				else:
					pref.pop()
					return pi
			else:
				pref.pop()
				return ci
	try_construct(ans)
	print('\n'.join(buf))
t = int(input())
for ti in range(t):
	solve()


for _ in range(int(input())):
	s = ''
	lst = []
	for _ in range(int(input())):
		n = input()
		if n == '1':
			lst.insert(0, n)
		else:
			f = lst.index(str(int(n) - 1))
			lst = lst[f:]
			lst[0] = n
		print('.'.join(lst[::-1]))


def solve():
	v = []
	for _ in range(int(input())):
		x = int(input())
		if x == 1:
			v.append(x)
		else:
			while v[-1] != x - 1:
				v.pop()
			v[-1] += 1
		for i in range(len(v)):
			if i < len(v) - 1:
				print(v[i], end='.')
			else:
				print(v[i])
for _ in range(int(input())):
	solve()


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	alst = [int(input()) for _ in range(n)]
	ans = []
	for a in alst:
		if a == 1:
			ans.append('1')
			print('.'.join(ans))
			continue
		while ans and int(ans[-1]) != a - 1:
			ans.pop()
		if not ans:
			ans.append(str(a))
		else:
			ans.pop()
			ans.append(str(a))
		print('.'.join(ans))
for _ in range(int(input())):
	main()


import sys
import math
from bisect import bisect_left
import heapq
from collections import deque
from functools import reduce
from itertools import permutations

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return input()

def FACT(n, mod):
	s = 1
	facts = [1]
	for i in range(1, n + 1):
		s *= i
		s %= mod
		facts.append(s)
	return facts[n]

def C(n, k, mod):
	return FACT(n, mod) * pow(FACT(k, mod) * FACT(n - k, mod) % mod, mod - 2, mod) % mod

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)
for _ in range(II()):
	n = II()
	stack = []
	for i in range(n):
		a = II()
		if a == 1:
			stack.append(a)
		else:
			while stack[-1] != a - 1:
				stack.pop()
			temp = stack.pop()
			stack.append(a)
		print('.'.join(map(str, stack)))


from collections import deque

def compression(n, A):
	L = deque()
	for a in A:
		if a == 1:
			L.append(a)
		else:
			b = a - 1
			while L[-1] != b:
				L.pop()
			L[-1] = a
		yield '.'.join(map(str, L))

def main():
	t = readint()
	L = []
	for _ in range(t):
		n = readint()
		A = [readint() for _ in range(n)]
		L.extend(compression(n, A))
	print('\n'.join(L))
import sys

def readint():
	return int(input())

def readinti():
	return map(int, input().split())

def readintl():
	return list(readinti())

def readintll(k):
	return [readintl() for _ in range(k)]

def log(*args, **kwargs):
	print(*args, **kwargs, file=sys.stderr)
main()


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
from collections import defaultdict as dd
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
stdmap = lambda : map(int, stdstr().split())
stdarr = lambda : list(map(int, stdstr().split()))
mod = 1000000007
import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
from collections import defaultdict as dd
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
stdmap = lambda : map(int, stdstr().split())
stdarr = lambda : list(map(int, stdstr().split()))
mod = 1000000007
for _ in range(stdint()):
	n = stdint()
	lasts = []
	for i in range(n):
		lasts.append(stdint())
	res = [[1]]
	done = dd(bool)
	done[1,] = True
	indx = dd(list)
	indx[1].append(0)
	for i in range(1, n):
		curr = lasts[i]
		if curr == 1:
			ne = res[-1].copy()
			ne.append(curr)
			done[tuple(ne)] = True
			res.append(ne)
			indx[curr].append(i)
		else:
			prev = curr - 1
			l = indx[prev]
			for j in range(len(l) - 1, -1, -1):
				tx = res[l[j]].copy()[:-1]
				tx.append(curr)
				if not done[tuple(tx)] and tx >= res[-1]:
					res.append(tx)
					done[tuple(tx)] = True
					indx[curr].append(i)
					break
	for i in res:
		ix = list(map(str, i))
		print('.'.join(ix))


for _ in range(int(input())):
	n = int(input())
	a = []
	for i in range(n):
		a.append(int(input()))
	ans = [a[0]]
	print(ans[0])
	for i in range(1, n):
		if a[i] == 1:
			ans.append(1)
		else:
			for j in range(len(ans) - 1, -1, -1):
				if ans[j] == a[i] - 1:
					ans[j] = a[i]
					break
				else:
					ans.pop()
		print(ans[0], end='')
		for j in range(1, len(ans)):
			print('.', end='')
			print(ans[j], end='')
		print()


from sys import stdin, stdout
input = stdin.readline

def output(ans):
	for i in ans[:-1]:
		stdout.write(str(i) + '.')
	stdout.write(str(ans[-1]) + '\n')
for _ in range(int(input())):
	n = int(input())
	stack = []
	for i in range(n):
		element = int(input())
		if element == 1:
			stack.append(1)
			output(stack)
		else:
			while len(stack) > 0:
				ele = stack.pop()
				if ele + 1 == element:
					break
			stack.append(element)
			output(stack)


import os
import sys
from io import BytesIO, IOBase
import math
from collections import Counter

def func(n, array):
	level = 0
	last = []
	for i in array:
		if i == 1:
			level += 1
			last.append(1)
		else:
			for j in range(len(last) - 1, -1, -1):
				if last[j] + 1 == i:
					last = last[:j + 1]
					last[-1] = i
					break
		print('.'.join(map(str, last)))

def main():
	num_test = int(parse_input())
	result = []
	for _ in range(num_test):
		n = int(parse_input())
		array = []
		for i in range(n):
			array.append(int(parse_input()))
		func(n, array)
parse_input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def prS():
	print('.'.join(map(str, a)))
for _ in range(int(input())):
	n = int(input())
	l = []
	for i in range(n):
		l.append(int(input()))
	a = [l[0]]
	print(a[0])
	for i in range(1, n):
		if l[i] == 1:
			a.append(1)
		else:
			while l[i] != a[-1] + 1:
				del a[-1]
			a[-1] = l[i]
		prS()


import bisect
import copy
import decimal
import fractions
import heapq
import itertools
import math
import random
import sys
from collections import Counter, deque, defaultdict
from functools import lru_cache, reduce
from heapq import heappush, heappop, heapify, _heappop_max, _heapify_max

def _heappush_max(heap, item):
	heap.append(item)
	heapq._siftdown_max(heap, 0, len(heap) - 1)
from math import gcd as Gcd
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
t = int(readline())
for _ in range(t):
	n = int(readline())
	stack = []
	for _ in range(n):
		i = int(readline())
		if not stack:
			stack.append(i)
		elif stack[-1] + 1 == i:
			stack[-1] += 1
		elif i == 1:
			stack.append(i)
		else:
			while stack[-1] + 1 != i:
				stack.pop()
			stack[-1] = i
		print(*stack, sep='.')


for _ in range(int(input())):
	stack = []
	n = int(input())
	a = [int(input()) for _ in range(n)]
	stack.append(a[0])
	print(stack[-1])
	for x in a[1:]:
		if x == stack[-1]:
			if x == 1:
				stack.append(1)
				print(*stack, sep='.')
			else:
				while len(stack) > 0:
					if stack.pop() == x - 1:
						stack.append(x)
						print(*stack, sep='.')
						break
		elif x > stack[-1]:
			if x == stack[-1] + 1:
				stack[-1] = x
				print(*stack, sep='.')
			else:
				while len(stack) > 0:
					if stack.pop() == x - 1:
						stack.append(x)
						print(*stack, sep='.')
						break
		elif x == 1:
			stack.append(1)
			print(*stack, sep='.')
		else:
			while len(stack) > 0:
				if stack.pop() == x - 1:
					stack.append(x)
					print(*stack, sep='.')
					break


def next(st, prev, cur):
	arr = st.split('.')
	if len(arr) == 1:
		if prev == cur - 1:
			return str(cur)
		else:
			return str(prev) + '.' + str(cur)
	elif prev == cur - 1:
		arr[len(arr) - 1] = cur
		ss = ''
		for a in arr:
			ss = ss + str(a) + '.'
		return ss[0:len(ss) - 1]
	elif cur == 1:
		arr.append(1)
		ss = ''
		for a in arr:
			ss = ss + str(a) + '.'
		return ss[0:len(ss) - 1]
	else:
		counter = 0
		mark = -1
		for a in arr:
			if int(a) == cur - 1:
				mark = counter
			counter += 1
		if mark == -1:
			return st + '.' + str(cur)
		else:
			ans = ''
			for i in range(mark):
				ans += arr[i] + '.'
			ans += str(cur)
			return ans
t = int(input())
while t > 0:
	n = int(input())
	a = [0] * n
	for i in range(n):
		a[i] = int(input())
	ans = [''] * n
	ans[0] = str(a[0])
	for i in range(1, n):
		ans[i] = next(ans[i - 1], a[i - 1], a[i])
	for s in ans:
		print(s)
	t -= 1


import heapq

def sol(A):
	ans = []
	for a in A:
		if a > 1:
			while ans and ans.pop() != a - 1:
				None
			ans.append(a)
		else:
			ans.append(a)
		print('.'.join(map(str, ans)))
x = int(input())
for _ in range(x):
	n = int(input())
	arr = []
	for _ in range(n):
		arr.append(int(input()))
	sol(arr)


def findr(a, i, cur):
	for k in range(cur, -1, -1):
		if a[k] == i:
			return k
t = int(input())
for _ in range(t):
	n = int(input())
	a = []
	b = [[]]
	urov_last_num = [0 for __ in range(1000)]
	urov_strings = ['']
	for k in range(n):
		a.append(int(input()))
	print('1')
	urov = 0
	urov_last_num[0] = 1
	for k in range(1, n):
		if a[k] - a[k - 1] == 1:
			urov_last_num[urov] += 1
		elif a[k] == 1:
			urov_strings.append('')
			urov_strings[urov + 1] = f'{urov_strings[urov]}{urov_last_num[urov]}.'
			urov += 1
			urov_last_num[urov] = 1
		else:
			urov = findr(urov_last_num, a[k] - 1, urov - 1)
			urov_last_num[urov] += 1
		print(f'{urov_strings[urov]}{urov_last_num[urov]}')


t = int(input())
for q in range(t):
	n = int(input())
	a = []
	i = 0
	while i < n:
		temp = int(input())
		if temp == 1:
			a.append(1)
		elif temp == a[-1] + 1:
			a[-1] += 1
		else:
			while True:
				a.pop()
				if temp == a[-1] + 1:
					a[-1] += 1
					break
		print(*a, sep='.')
		i += 1


import os, sys, time, collections as c, math, pprint as p, itertools as it, operator as op, bisect as bs, functools as fn
(maxx, localsys, mod) = (float('inf'), 0, int(1000000000.0 + 7))
nCr = lambda n, r: reduce(mul, range(n - r + 1, n + 1), 1) // factorial(r)
ceil = lambda n, x: (n + x - 1) // x
(osi, oso) = ('/home/priyanshu/Documents/sublimetextproject/input.txt', '/home/priyanshu/Documents/sublimetextproject/output.txt')
if os.path.exists(osi):
	sys.stdin = open(osi, 'r')
	sys.stdout = open(oso, 'w')
input = sys.stdin.readline

def maps():
	return map(int, input().split())

def A():
	for _ in range(int(input())):
		(n, m) = maps()
		s = list(input().rstrip('\n'))
		yes = [None] * n
		if m >= n:
			m = m % n + n
		while m:
			for i in range(n):
				if s[i] == '0':
					cnt = 0
					if i > 0 and s[i - 1] == '1':
						cnt += 1
					if i < n - 1 and s[i + 1] == '1':
						cnt += 1
					if cnt == 1:
						yes[i] = True
			for i in range(n):
				if yes[i] == True:
					yes[i] = False
					s[i] = '1'
			m -= 1
		print(''.join(s))

def B():
	for _ in range(int(input())):
		n = int(input())
		a = list(maps())
		(ans, i, j) = ([], 0, n - 1)
		while i < j:
			ans.append(('1', i + 1, j + 1))
			ans.append(('2', i + 1, j + 1))
			ans.append(('2', i + 1, j + 1))
			ans.append(('1', i + 1, j + 1))
			ans.append(('2', i + 1, j + 1))
			ans.append(('2', i + 1, j + 1))
			i += 1
			j -= 1
		print(len(ans))
		for i in ans:
			print(*i)

def C():
	for _ in range(int(input())):
		s = []
		for _ in range(int(input())):
			x = int(input())
			if x == 1:
				s.append(x)
			else:
				while s and s[-1] != x - 1:
					s.pop()
				s[-1] = x
			print('.'.join(map(str, s)))
C()


from sys import stdin, stdout
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	stack = []
	for i in range(n):
		k = int(input())
		if k == 1:
			stack.append(1)
		else:
			while stack and stack[-1] + 1 != k:
				stack.pop()
			else:
				stack[-1] += 1
		stdout.write('.'.join(map(str, stack)) + '\n')


t = int(input())
for i in range(t):
	n = int(input())
	a = []
	for i in range(n):
		a.append(int(input()))
	string = [1]
	print(*string)
	for i in range(1, n):
		if a[i] == 1:
			string = string + [1]
			print('.'.join([str(i) for i in string]))
		else:
			for j in range(len(string) - 1, -1, -1):
				if string[j] == a[i] - 1:
					string = string[:j] + [a[i]]
					print('.'.join([str(i) for i in string]))
					break


t = int(input())
for _ in range(t):
	n = int(input())
	ans = []
	for _ in range(n):
		a = int(input())
		if not ans:
			ans.append(a)
		elif a == 1:
			ans.append(a)
		else:
			while not ans[-1] + 1 == a:
				ans.pop()
			ans[-1] += 1
		print('.'.join(map(str, ans)))


for _ in range(int(input())):
	l1 = ['1']
	for __ in range(int(input())):
		n = int(input())
		if __ == 0:
			continue
		if n == 1:
			l1.append(l1[-1] + '.1')
		else:
			shit = l1[-1].split('.')
			while n - int(shit[-1]) != 1:
				shit.pop()
			shit.pop()
			shit.append(n)
			l1.append('.'.join([str(___) for ___ in shit]))
	for i in l1:
		print(i)


t = int(input())
for i in range(t):
	n = int(input())
	a = int(input())
	last = [a]
	print(1)
	for i in range(1, n):
		a = int(input())
		flag = False
		if a == 1:
			last.append(1)
			flag = True
		while not flag:
			if a - 1 == last[-1]:
				last[-1] += 1
				flag = True
			else:
				last = last[:-1]
		print('.'.join(list(map(str, last))))


import sys
input = sys.stdin.readline

def I():
	return input().strip()

def II():
	return int(input().strip())

def LI():
	return [*map(int, input().strip().split())]
import copy, string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter, OrderedDict
from itertools import permutations, combinations, groupby
from operator import itemgetter
for _ in range(II()):
	n = II()
	arr = []
	for elem in range(n):
		inp = II()
		if inp == 1:
			arr.append(1)
			print('.'.join([str(i) for i in arr]))
			continue
		for i in range(len(arr) - 1, -1, -1):
			if arr[i] + 1 == inp:
				arr[i] = arr[i] + 1
				arr = arr[0:i + 1]
				print('.'.join([str(i) for i in arr]))
				break


from copy import deepcopy
import os
import sys
from io import BytesIO, IOBase
from functools import lru_cache, reduce
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from bisect import bisect, bisect_left, bisect_right
import math
import threading
import time

def I():
	return input()

def get_int():
	return int(input())

def get_list():
	return list(map(int, input().split()))

def get_map():
	return map(int, input().split())

def get_list_str(li, s=' '):
	print(s.join(map(str, li)))

def solve():
	n = get_int()
	ls = []
	for _ in range(n):
		x = get_int()
		ls.append(x)
	prev = ls[0]
	ans = [str(ls[0])]
	stack = [ls[0]]
	for i in range(1, n):
		if ls[i] == prev + 1:
			stack[-1] = ls[i]
		elif ls[i] == 1:
			stack.append(ls[i])
		else:
			while stack:
				top = stack.pop(-1)
				if ls[i] == 1 + top:
					stack.append(ls[i])
					break
			if not stack:
				stack.append(ls[i])
		prev = ls[i]
		res = '.'.join([str(val) for val in stack])
		ans.append(res)
	for val in ans:
		print(val)

def main():
	testcases = True
	if testcases:
		t = get_int()
		for _ in range(t):
			solve()
	else:
		solve()
main()


from sys import stdin, stdout
intn = lambda : int(stdin.readline())
strs = lambda : stdin.readline()[:-1]
lstr = lambda : list(stdin.readline()[:-1])
mint = lambda : map(int, stdin.readline().split())
lint = lambda : list(map(int, stdin.readline().split()))
out = lambda x: stdout.write(str(x) + '\n')
out_ = lambda x: stdout.write(str(x) + ' ')

def main():
	for _ in range(intn()):
		n = intn()
		a = intn()
		l = [str(a)]
		for i in range(1, n):
			a = intn()
			x = l[i - 1]
			if a == 1:
				l.append(x + '.1')
				continue
			e = len(x)
			for j in range(len(x) - 1, -1, -1):
				if x[j] == '.':
					if a == int(x[j + 1:e]) + 1:
						l.append(x[:j + 1] + str(a))
						break
					e = j
			else:
				l.append(str(a))
		print(*l, sep='\n')
main()


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 998244353
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	n = Int()
	a = []
	for i in range(n):
		a.append(Int())
	ans = []
	st = []
	for i in range(n):
		if a[i] == 1:
			st.append(1)
		else:
			while st[-1] != a[i] - 1:
				st.pop()
			st.pop()
			st.append(a[i])
		print(*st, sep='.')


from sys import stdin, stdout, setrecursionlimit
stdin.readline

def mp():
	return list(map(int, stdin.readline().strip().split()))

def it():
	return int(stdin.readline().strip())
from collections import defaultdict as dd, Counter as C, deque
from math import ceil, gcd, sqrt, factorial, log2, floor
from bisect import bisect_right as br, bisect_left as bl
for _ in range(it()):
	n = it()
	v = []
	for t in range(n):
		x = it()
		if x == 1:
			v.append(x)
		else:
			while v[-1] != x - 1:
				del v[-1]
			del v[-1]
			v.append(x)
		print('.'.join(map(str, v)))


import sys
input = iter(sys.stdin.read().splitlines()).__next__

def solve():
	n = int(input())
	input()
	a = [int(input()) for i in range(n - 1)]
	l = ['1']
	stack = [1]
	stack_str = ['1']
	for e in a:
		if e == 1:
			stack.append(1)
			stack_str.append('1')
		else:
			while e != stack[-1] + 1:
				stack.pop()
				stack_str.pop()
			stack[-1] = e
			stack_str[-1] = str(e)
		l.append('.'.join(stack_str))
	return l
t = int(input())
output = []
for _ in range(t):
	output.extend(solve())
print(*output, sep='\n')


import sys
T = int(sys.stdin.readline().strip())
for t in range(0, T):
	n = int(sys.stdin.readline().strip())
	x = int(sys.stdin.readline().strip())
	ans = [[x]]
	for i in range(0, n - 1):
		x = int(sys.stdin.readline().strip())
		ans.append(ans[-1][:])
		if x == 1:
			ans[-1].append(x)
		else:
			while x != ans[-1][-1] + 1:
				ans[-1].pop()
			ans[-1][-1] = ans[-1][-1] + 1
	for x in ans:
		print('.'.join(list(map(str, x))))


t = int(input())
for _ in range(t):
	n = int(input())
	stack = []
	arr = []
	for i in range(n):
		k = int(input())
		if k == 1:
			stack.append(k)
			arr.append('1')
		else:
			while stack[-1] != k - 1:
				stack.pop()
				arr.pop()
			stack[-1] += 1
			arr[-1] = str(k)
		print('.'.join(arr))


t = int(input())
for _ in range(t):
	n = int(input())
	d = []
	for i in range(n):
		a = int(input())
		if a == 1:
			d.append(1)
		else:
			while d and d[-1] != a - 1:
				d.pop()
			d[-1] += 1
		print(*d, sep='.')


def list_print(lst):
	print('.'.join((str(x) for x in lst)))

def solve():
	n = int(input())
	last_pos = []
	for _ in range(n):
		last_pos.append(int(input()))
	lst = [1] * n
	index = 0
	assert last_pos[0] == 1
	list_print(lst[:index + 1])
	for i in range(1, n):
		if last_pos[i] == 1:
			index += 1
			lst[index] = 1
			list_print(lst[:index + 1])
			continue
		for last in range(index, -1, -1):
			if lst[last] + 1 == last_pos[i]:
				index = last
				lst[index] += 1
				list_print(lst[:index + 1])
				break
for _ in range(int(input().strip())):
	solve()


import sys
from sys import stdin
tt = int(stdin.readline())
for loop in range(tt):
	n = int(stdin.readline())
	a = [int(stdin.readline()) for i in range(n)]
	ans = []
	for i in range(n):
		if a[i] == 1:
			ans.append(1)
		else:
			while ans[-1] != a[i] - 1:
				del ans[-1]
			del ans[-1]
			ans.append(a[i])
		print('.'.join(map(str, ans)))


def pr(v):
	s = ''
	for j in range(len(v)):
		s += v[j] + '.'
	print(s[:-1])
t = int(input())
while t:
	t -= 1
	n = int(input())
	(ans, i) = ([], 0)
	while i < n:
		temp = int(input())
		if temp == 1:
			ans.append(str(temp))
			pr(ans)
		elif int(ans[-1]) == temp - 1:
			ans.pop()
			ans.append(str(temp))
			pr(ans)
		else:
			while int(ans[-1]) != temp - 1:
				ans.pop()
			ans.pop()
			ans.append(str(temp))
			pr(ans)
		i += 1


t = int(input())
for test in range(t):
	n = int(input())
	stack = []
	for i in range(n):
		a_i = int(input())
		if a_i == 1:
			stack.append(a_i)
		elif a_i > 1:
			while len(stack) and stack[-1] != a_i - 1:
				stack.pop()
			stack[-1] += 1
		print(*stack, sep='.')


import io
import os
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from heapq import heappush, heappop, heapify
from math import gcd, inf

def solve(N, A):
	ans = []
	stack = []
	for i in range(N):
		x = A[i]
		line = [x]
		while stack:
			if x == 1:
				line = stack[-1] + line
				break
			elif stack[-1][-1] + 1 == x:
				line = stack[-1][:-1] + line
				break
			else:
				l = len(stack[-1])
				while stack and len(stack[-1]) == l:
					stack.pop()
		stack.append(line)
		ans.append('.'.join(map(str, line)))
	return '\n'.join(ans)
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(1, TC + 1):
	(N,) = [int(x) for x in input().split()]
	A = [int(input()) for i in range(N)]
	ans = solve(N, A)
	print(ans)


import os
import sys
from io import BytesIO, IOBase
import math
from collections import Counter

def a(n, x):
	l = 0
	q = []
	for i in x:
		if i == 1:
			l += 1
			q.append(1)
		else:
			for j in range(len(q) - 1, -1, -1):
				if q[j] + 1 == i:
					q = q[:j + 1]
					q[-1] = i
					break
		print('.'.join(map(str, q)))

def main():
	n = int(parse_input())
	for _ in range(n):
		n = int(parse_input())
		x = []
		for i in range(n):
			x.append(int(parse_input()))
		a(n, x)
parse_input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def f(a):
	prev = a[0]
	st = [a[0]]
	print(a[0])
	for i in a[1:]:
		if i == 1:
			st.append(i)
			print('.'.join(list(map(str, st))))
			continue
		else:
			t = None
			for ind in range(0, len(st)):
				if i - st[ind] == 1:
					t = ind
			st = st[:t] + [i]
			print('.'.join(list(map(str, st))))
for i in range(int(input())):
	a = []
	for n in range(int(input())):
		a.append(int(input()))
	f(a)


t = int(input())
for i in range(t):
	n = int(input())
	arr = []
	for i in range(n):
		arr.append(int(input()))
	stack = []
	for i in range(n):
		if arr[i] == 1:
			stack.append(arr[i])
			print('.'.join(map(str, stack)))
			continue
		while stack and stack[-1] != arr[i] - 1:
			stack.pop()
		try:
			stack.pop()
		except:
			pass
		stack.append(arr[i])
		print('.'.join(map(str, stack)))


from sys import stdin
T = int(stdin.readline())
for t in range(T):
	n = int(stdin.readline())
	(S, R) = ([], [])
	for i in range(n):
		a = int(stdin.readline())
		if a == 1:
			S.append(a)
		else:
			while S[-1] != a - 1:
				S.pop()
			S.pop()
			S.append(a)
		R.append('.'.join(map(str, S)))
	print('\n'.join(R))


ans = []
t = int(input())
while t:
	t -= 1
	n = int(input())
	l = ['1']
	ans.append('1')
	for i in range(n):
		a = int(input())
		if i == 0:
			continue
		if a == 1:
			l.append('.')
			l.append(str(a))
			ans.append(''.join(l))
			continue
		while int(l[-1]) != a - 1:
			l.pop()
			l.pop()
		l.pop()
		l.append(str(a))
		ans.append(''.join(l))
print('\n'.join(ans))


import os
import sys
from io import BytesIO, IOBase
from collections import Counter
import math as mt
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)
mod = int(1000000000.0) + 7

def power(k, n):
	if n == 0:
		return 1
	if n % 2:
		return power(k, n - 1) * k % mod
	t = power(k, n // 2)
	return t * t % mod

def totalPrimeFactors(n):
	count = 0
	if n % 2 == 0:
		count += 1
		while n % 2 == 0:
			n //= 2
	i = 3
	while i * i <= n:
		if n % i == 0:
			count += 1
			while n % i == 0:
				n //= i
		i += 2
	if n > 2:
		count += 1
	return count

def main():
	for _ in range(int(input())):
		n = int(input())
		a = []
		for i in range(n):
			a.append(int(input()))
		ans = [[-1 for i in range(n + 1)] for j in range(n + 1)]
		x = 0
		y = 0
		ans[x][y] = 1
		for i in range(1, n):
			if a[i] == 1:
				for j in range(n):
					if ans[i - 1][j] == -1:
						ans[i][j] = 1
						break
					ans[i][j] = ans[i - 1][j]
			else:
				y = -1
				z = -1
				for j in range(n - 1, -1, -1):
					if ans[i - 1][j] == a[i] - 1:
						y = j
						break
					if ans[i - 1][j] != -1 and z != -1:
						z = j
				if y != -1:
					for j in range(y):
						ans[i][j] = ans[i - 1][j]
					ans[i][y] = ans[i - 1][y] + 1
				else:
					ans[i][z + 1] = a[i]
					for j in range(z + 1):
						ans[i][j] = ans[i - 1][j]
		for i in range(n):
			for j in range(n):
				if ans[i][j] == -1:
					break
				if j == 0:
					print(str(ans[i][j]), end='')
				else:
					print('.' + str(ans[i][j]), end='')
			print('')
	return
main()


def p(f):
	n = len(f)
	for i in range(n - 1):
		print(str(f[i]) + '.', end='')
	print(f[n - 1])
q = int(input())
for qe in range(q):
	n = int(input())
	l = []
	for i in range(n):
		l = l + [int(input())]
	f = [l[0]]
	j = 0
	z = []
	for i in range(1, n):
		k = l[i]
		z += [f]
		if k == 1:
			f = f[:] + [1]
			j += 1
		else:
			m = len(f)
			while f[j] + 1 != k:
				j -= 1
			f = f[:j] + [k]
	z += [f]
	for i in range(len(z)):
		p(z[i])


t = int(input())
for _ in range(t):
	n = int(input())
	stack = []
	for i in range(n):
		ai = int(input())
		if ai == 1:
			stack.append(ai)
		else:
			while ai - stack[-1] != 1:
				stack.pop()
			stack[-1] += 1
		ps = [str(s) for s in stack]
		print('.'.join(ps))


import sys
input = sys.stdin.readline

def im():
	return map(int, input().split())

def ii():
	return int(input())

def il():
	return list(map(int, input().split()))

def ins():
	return input()[:-1]
from collections import deque
for _ in range(ii()):
	n = ii()
	s = deque()
	for _ in range(n):
		a = ii()
		if a == 1:
			if s:
				temp = s[0][:]
				temp.append(a)
				st = ''
				for i in temp:
					st += str(i) + '.'
				st = st[:-1]
				print(st)
				s.insert(0, temp)
			else:
				s.insert(0, [a])
				print(a)
		else:
			while s[0][-1] != a - 1:
				ln = len(s[0])
				while len(s[0]) == ln:
					s.popleft()
			temp = s[0][:]
			temp[-1] += 1
			st = ''
			for i in temp:
				st += str(i) + '.'
			st = st[:-1]
			print(st)
			s.insert(0, temp)


for _ in range(int(input())):
	n = int(input())
	li = [int(input()) for _ in range(n)]
	st = []
	for n in li:
		if n == 1:
			st.append(1)
		else:
			while st[-1] != n - 1:
				st.pop()
			st.append(st.pop() + 1)
		print('.'.join(map(str, st)))


for _ in range(int(input())):
	size = int(input())
	nums = []
	index = [1]
	for i in range(size):
		nums.append(int(input()))
		index.append(0)
	lvl = 1
	print(1)
	for i in range(1, size):
		if nums[i] == 1:
			lvl += 1
			index[lvl - 1] = 1
		elif nums[i] == nums[i - 1] + 1:
			index[lvl - 1] += 1
		else:
			lvl -= 1
			while index[lvl - 1] != nums[i] - 1:
				lvl -= 1
			index[lvl - 1] += 1
		for j in range(lvl - 1):
			print(index[j], end='.')
		print(index[lvl - 1])


from sys import stdout, stdin, setrecursionlimit
from io import BytesIO, IOBase
from collections import *
from itertools import *
from bisect import *
from string import *
from queue import *
from heapq import *
from math import *
from re import *
from os import *

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = read(self._fd, max(fstat(self._fd).st_size, 8192))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = read(self._fd, max(fstat(self._fd).st_size, 8192))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(stdin, stdout) = (IOWrapper(stdin), IOWrapper(stdout))
(graph, mod, szzz) = ({}, 10 ** 9 + 7, lambda : sorted(zzz()))

def getStr():
	return input()

def getInt():
	return int(input())

def listStr():
	return list(input())

def getStrs():
	return input().split()

def isInt(s):
	return '0' <= s[0] <= '9'

def input():
	return stdin.readline().strip()

def zzz():
	return [int(i) for i in input().split()]

def output(answer, end='\n'):
	stdout.write(str(answer) + end)

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)
dx = [-1, 1, 0, 0, 1, -1, 1, -1]
dy = [0, 0, 1, -1, 1, -1, -1, 1]
daysInMounth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
num = getInt()
for _ in range(num):
	n = getInt()
	arr = []
	for i in range(n):
		item = getInt()
		if item == 1:
			arr.append(item)
		else:
			while arr[-1] != item - 1:
				arr.pop()
			arr[-1] += 1
		print(*arr, sep='.')


from sys import stdin, stderr
input = stdin.readline

def dbp(*args, **kwargs):
	print(*args, file=stderr, **kwargs)

def get_int_list():
	return [int(x) for x in input().strip().split()]

def do_thing():
	n = int(input())
	last = []
	for i in range(n):
		end = int(input())
		if not last:
			print(end)
			last = [end]
			continue
		if end == 1:
			last.append(1)
			print('.'.join((str(x) for x in last)))
		else:
			ok = False
			for idx in range(len(last) - 1, -1, -1):
				if last[idx] + 1 != end:
					continue
				last[idx] = end
				last = last[:idx + 1]
				ok = True
				break
			if not ok:
				raise Exception('couldna do it')
			print('.'.join((str(x) for x in last)))

def multicase():
	maxcc = int(input().strip())
	for cc in range(maxcc):
		do_thing()
multicase()


for _ in range(int(input())):
	n = int(input())
	a = []
	for i in range(n):
		k = int(input())
		if k == 1:
			a.append(k)
		else:
			while len(a) > 0 and a[-1] + 1 != k:
				a.pop()
			a[-1] += 1
		print('.'.join((str(x) for x in a)))


t = int(input())
for test in range(t):
	n = int(input())
	s = []
	tog = 0
	while tog < n:
		a = int(input())
		if len(s) == 0 or a == 1:
			s.append(a)
		else:
			while True:
				if a - s[-1] == 1:
					s[-1] += 1
					break
				s.pop(-1)
				if len(s) == 0:
					s.append(a)
					break
		for i in range(len(s) - 1):
			print(str(s[i]) + '.', end='')
		print(str(s[-1]))
		tog += 1


import sys

def Ints():
	return map(int, sys.stdin.readline().strip().split())

def Strs():
	return map(str, sys.stdin.readline().strip().split())

def Array():
	return list(map(int, sys.stdin.readline().strip().split()))

def Str():
	return sys.stdin.readline().strip()

def Int():
	return int(sys.stdin.readline().strip())

def MOD():
	return 1000000007
t = Int()
for i in range(t):
	n = Int()
	a = []
	for i in range(n):
		a.append(Int())
	stack = []
	depth = 0
	for i in range(n):
		if not stack:
			stack.append((str(a[i]), i, depth + 1))
		elif a[i] == 1:
			(sno, index, d) = stack[-1]
			stack.append((sno + '.1', i, d + 1))
		elif a[i] == 1 + a[stack[-1][1]]:
			(sno, index, d) = stack[-1]
			sno = sno.split('.')
			sno[-1] = str(a[i])
			stack[-1] = ('.'.join(sno), i, d)
		else:
			d = stack[-1][2]
			while stack and a[stack[-1][1]] != a[i] - 1:
				stack.pop()
			(sno, index, d1) = stack[-1]
			sno = sno.split('.')
			sno[-1] = str(a[i])
			stack[-1] = ('.'.join(sno), i, d1)
		print(stack[-1][0])


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	N = int(input())
	prev = [0]
	for i in range(N):
		a = int(input())
		if a != 1:
			while prev[-1] != a - 1:
				prev.pop()
			prev.pop()
		prev.append(a)
		print('.'.join(map(str, prev[1:])))


for _ in range(int(input())):
	n = int(input())
	arr = []
	while n:
		n -= 1
		a = int(input())
		if a == 1:
			arr.append(1)
		else:
			while arr and arr[-1] != a - 1:
				arr.pop()
			arr[-1] += 1
		print(*arr, sep='.')


t = int(input())

def solve():
	n = int(input())
	l = []
	for i in range(n):
		l.append(int(input()))
	s = [1]
	print(1)
	for i in range(1, n):
		if s[-1] == l[i] - 1:
			s[-1] = l[i]
		elif l[i] == 1:
			s.append(1)
		else:
			while s[-1] != l[i] - 1:
				s.pop()
			s[-1] = l[i]
		print('.'.join(map(str, s)))
for i in range(t):
	solve()


final = []
t = int(input())
for z in range(t):
	n = int(input())
	ls = []
	for j in range(n):
		inp = int(input())
		if len(ls) == 0:
			ls.append(inp)
		elif inp == ls[-1] + 1:
			ls[-1] = inp
			activels = False
		elif inp == 1:
			ls.append(1)
		else:
			while len(ls) > 0:
				if inp == ls[-1] + 1:
					ls[-1] = inp
					break
				ls = ls[:-1]
		final.append('.'.join(map(str, ls)))
for i in final:
	print(i)


from sys import stdin, stdout, setrecursionlimit
input = stdin.readline
inf = float('inf')
from functools import cmp_to_key
from collections import defaultdict as dd
from collections import Counter, deque
from heapq import *
import math
from math import floor, ceil, sqrt

def geti():
	return map(int, input().strip().split())

def getl():
	return list(map(int, input().strip().split()))

def getis():
	return map(str, input().strip().split())

def getls():
	return list(map(str, input().strip().split()))

def gets():
	return input().strip()

def geta():
	return int(input())

def print_s(s):
	stdout.write(s + '\n')

def solve():
	for _ in range(geta()):
		n = geta()
		prev = None
		ans = []
		for i in range(n):
			now = geta()
			if not ans:
				ans.append([now])
			else:
				if now == 1:
					ans.append(ans[-1][:] + [1])
					continue
				temp = ans[-1][:]
				while temp and temp[-1] + 1 != now:
					temp.pop()
				if temp:
					temp[-1] += 1
					ans.append(temp[:])
				else:
					temp.append(now)
					ans.append(temp[:])
		for i in ans:
			i = list(map(str, i))
			print('.'.join(i))
solve()


import sys

def input():
	return sys.stdin.buffer.readline().rstrip()

def inputa():
	return list(map(int, input().split()))

def out(var):
	sys.stdout.write(str(var) + '\n')

def outa(var):
	sys.stdout.write('.'.join(map(str, var)) + '\n')

def setup():
	import os
	dir_path = os.path.dirname(os.path.realpath(__file__))
	sys.stdin = open(os.path.join(dir_path, 'input.txt'), 'r')
	sys.stdout = open(os.path.join(dir_path, 'output.txt'), 'w')
for _ in range(int(input())):
	n = int(input())
	arr = []
	for _ in range(n):
		arr.append(int(input()))
	stack = [[1]]
	print(1)
	for i in arr[1:]:
		while i not in [1, stack[-1][-1] + 1]:
			stack.pop()
		if stack[-1][-1] + 1 == i:
			stack[-1][-1] += 1
		else:
			stack.append(stack[-1] + [1])
		outa(stack[-1])


import sys
input = sys.stdin.readline
import math

def print_this(last_ele):
	for i in range(len(last_ele)):
		if i == len(last_ele) - 1:
			print(last_ele[i])
		else:
			print(last_ele[i], end='.')
t = int(input())
for i in range(t):
	n = int(input())
	x = int(input())
	depth = []
	for i in range(n + 1):
		depth.append([])
	last_ele = [1]
	curr_depth = 1
	depth[curr_depth].append(last_ele)
	print_this(last_ele)
	for i in range(1, n):
		x = int(input())
		if x == 1:
			arr = last_ele.copy()
			arr.append(x)
			last_ele = arr
			curr_depth = curr_depth + 1
		else:
			for d in range(curr_depth, 0, -1):
				if x - depth[d][-1][-1] == 1:
					last_ele = depth[d][-1]
					arr = last_ele.copy()
					arr[-1] = arr[-1] + 1
					last_ele = arr
					curr_depth = d
					break
		depth[curr_depth].append(last_ele)
		print_this(last_ele)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	s = []
	while n > 0:
		n -= 1
		a = int(input())
		if a == 1:
			s += [1]
		else:
			while s[-1] != a - 1:
				s.pop()
			s[-1] += 1
		print(*s, sep='.')


from copy import copy
for __ in range(int(input())):
	n = int(input())
	result = []
	for i in range(n):
		x = int(input())
		temp = [] if i == 0 else copy(result[-1])
		if x == 1:
			temp.append(1)
		else:
			for j in reversed(range(len(temp))):
				if x - temp[j] == 1:
					temp[j] = x
					temp = temp[:j + 1]
					break
		result.append(temp)
	for x in result:
		print('.'.join((str(y) for y in x)))


for _ in range(int(input())):
	x = int(input())
	zz = [int(input()) for _ in range(x)]
	stack = []
	for k in zz:
		if k == 1:
			stack.append(1)
		else:
			while k != stack[-1] + 1:
				stack.pop()
			stack[-1] += 1
		print('.'.join(map(str, stack)))


from sys import stdin
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	a = []
	s = []
	for i in range(n):
		m = int(stdin.readline())
		if m == 1:
			s.append(1)
			a.append('1')
		else:
			while s[-1] != m - 1:
				s.pop()
				a.pop()
			s[-1] += 1
			a[-1] = str(m)
		print('.'.join(a))


from typing import List

def solve(n: int, a: List[int]) -> None:
	stack = []
	for i in range(n):
		num = a[i]
		if not stack:
			stack.append(num)
		elif num == 1:
			stack.append(num)
		elif num <= stack[-1]:
			while stack and num - stack[-1] != 1:
				stack.pop()
			if not stack:
				stack.append(num)
			else:
				stack[-1] = num
		else:
			while stack and num - stack[-1] != 1:
				stack.pop()
			if not stack:
				stack.append(num)
			else:
				stack[-1] = num
		l = ''
		for x in stack:
			l += str(x) + '.'
		l = l[:-1]
		print(l)
	return
test_cases = int(input())
for _ in range(test_cases):
	n = int(input())
	a = []
	for i in range(n):
		a.append(int(input()))
	solve(n, a)


for _ in range(int(input())):
	x = int(input())
	Ans = []
	s = []
	for i in range(x):
		a = int(input())
		if a == 1:
			s.append(1)
			Ans.append(list(s))
		else:
			while s[-1] != a - 1:
				s.pop()
			s[-1] += 1
			Ans.append(list(s))
	for i in range(len(Ans)):
		for j in range(len(Ans[i])):
			if j != len(Ans[i]) - 1:
				print(Ans[i][j], '.', sep='', end='')
			else:
				print(Ans[i][j])


import sys
import math

def int_arr():
	return list(map(int, sys.stdin.readline().split()))

def str_arr():
	return list(map(str, sys.stdin.readline().split()))

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	n = int(input())
	ans = ['1.']
	trash = input()
	for i in range(n - 1):
		num = int(input())
		temp = ans[-1]
		temp = temp.replace(str(num - 1), '?')
		if num == 1:
			ans.append(ans[-1] + str(1) + '.')
			continue
		for l in range(len(temp)):
			if temp[l] == '?':
				ind = l
		val = temp[:ind] + str(num) + '.'
		val = val.replace('?', str(num - 1))
		ans.append(val)
	for k in ans:
		print(k[:-1])


theta = 0
import sys, io, os
theta = 0
input = sys.stdin.readline
theta = 0
theta = 0
t = int(input())
theta = 0
for i in range(t):
	theta = 0
	n = int(input())
	theta = 0
	theta = 0
	l = [int(input()) for i in range(n)]
	theta = 0
	stack = []
	theta = 0
	for i in range(n):
		theta = 0
		if l[i] == 1:
			theta = 0
			stack.append(1)
			theta = 0
		else:
			theta = 0
			while stack and l[i] != stack[-1] + 1:
				theta = 0
				stack.pop()
				theta = 0
			theta = 0
			stack[-1] += 1
			theta = 0
		theta = 0
		print(*stack, sep='.')
		theta = 0


for _ in range(int(input())):
	n = int(input())
	l = []
	for i in range(n):
		l += [int(input())]
	a = [[l[0]]]
	for i in range(1, n):
		if l[i] == 1:
			a += [a[-1] + [1]]
		else:
			j = len(a[-1]) - 1
			while a[-1][j] + 1 != l[i]:
				j -= 1
			a += [a[-1][:j] + [l[i]]]
	for i in range(len(a)):
		for j in range(len(a[i]) - 1):
			print(str(a[i][j]) + '.', end='')
		print(a[i][-1])


from collections import deque
for _ in range(int(input())):
	n = int(input())
	stk = deque()
	a = int(input())
	assert a == 1
	stk.append(a)
	print('.'.join(map(str, stk)))
	for i in range(1, n):
		a = int(input())
		if a == 1:
			stk.append(a)
		else:
			while a != stk[-1] + 1:
				stk.pop()
			stk[-1] += 1
		print('.'.join(map(str, stk)))


import os
import sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		n = int(input())
		a = [int(input()) for _ in range(n)]
		ans = [[a[0]]]
		for i in range(1, n):
			z = len(ans[-1])
			if a[i] == 1:
				ans.append(ans[-1] + [1])
			elif ans[-1][-1] + 1 == a[i]:
				ans.append(ans[-1][:z - 1] + [a[i]])
			else:
				z = 0
				for j in range(len(ans[-1]) - 2, -1, -1):
					if ans[-1][j] == a[i] - 1:
						z = j
						break
				ans.append(ans[-1][:z] + [a[i]])
		for i in ans:
			c = []
			for j in range(len(i) - 1):
				c.extend([str(i[j]), '.'])
			c.append(str(i[-1]))
			print(''.join(c))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	n = int(input())
	s = []
	lens = 0
	for __ in range(n):
		x = int(input())
		if x == 1:
			s.append(x)
			lens += 1
			print('.'.join([str(x) for x in s]))
		else:
			while 1:
				if lens == 0:
					break
				if s[-1] != x - 1:
					s.pop()
					lens -= 1
				if s[-1] == x - 1:
					s.pop()
					lens -= 1
					break
			if lens == 0:
				s.append(x)
				lens += 1
			else:
				s.append(x)
				lens += 1
			print('.'.join([str(x) for x in s]))


t = int(input())
for i in range(t):
	a = []
	n = int(input())
	for j in range(n):
		e = int(input())
		if e == 1:
			a.append(e)
			print(*a, sep='.')
		else:
			for k in range(len(a)):
				if a[k] == e - 1:
					m = k
			a = a[:m]
			a.append(e)
			print(*a, sep='.')


for ii in range(int(input())):
	n = int(input())
	x = []
	for jj in range(n):
		s = input()
		if '1' == s:
			x.append(s)
			print('.'.join(x))
		elif int(x[-1]) == int(s) - 1:
			x.pop()
			x.append(s)
			print('.'.join(x))
		else:
			while int(x[-1]) != int(s) - 1:
				x.pop()
			x.pop()
			x.append(str(s))
			print('.'.join(x))


a = int(input())
from collections import *
import heapq
for i in range(a):
	ans = []
	n = int(input())
	for i in range(n):
		s = int(input())
		ans.append(s)
	stack = []
	for i in range(len(ans)):
		if i == 0:
			stack.append(ans[i])
			print(ans[i])
			continue
		else:
			if ans[i] == 1:
				stack.append(ans[i])
			else:
				while len(stack) and stack[-1] != ans[i] - 1:
					stack.pop()
				if stack[-1] == ans[i] - 1:
					stack[-1] = ans[i]
				else:
					stack.append(ans[i])
			for i in range(len(stack)):
				print(stack[i], end='')
				if i != len(stack) - 1:
					print('.', end='')
				else:
					print('')


tests = int(input())
for _ in range(tests):
	lines = int(input())
	res = []
	for x in range(lines):
		num = input()
		if int(num) == 1:
			res.append(num)
		else:
			while int(res[-1]) != int(num) - 1:
				del res[-1]
			res[-1] = num
		print('.'.join(res))


import sys
import math
input = sys.stdin.readline
imp = 'IMPOSSIBLE'
t = int(input())
for test in range(t):
	n = int(input())
	a = []
	res = {'ma': 0}
	ma = [0 for i in range(n)]
	h = []
	for i in range(n):
		b = int(input())
		a.append(b)
		if b == 1:
			for j in range(n):
				if ma[j] == 0:
					ma[j] = 1
					pr = ''
					for k in range(j):
						pr = pr + str(ma[k]) + '.'
					pr += str(b)
					print(pr)
					break
		else:
			for j in reversed(range(n)):
				if ma[j] == b - 1:
					ma[j] += 1
					pr = ''
					for k in range(j):
						pr = pr + str(ma[k]) + '.'
					pr += str(b)
					print(pr)
					for k in range(j + 1, n):
						ma[k] = 0
					break


from sys import stdin, stdout
from heapq import heapify, heappush, heappop, heappushpop
from collections import defaultdict as dd, deque as dq, Counter as C
from bisect import bisect_left as bl, bisect_right as br
from itertools import combinations as cmb, permutations as pmb
from math import factorial as f, ceil, gcd, sqrt, log, inf
mi = lambda : map(int, input().split())
ii = lambda : int(input())
li = lambda : list(map(int, input().split()))
mati = lambda r: [li() for _ in range(r)]
lcm = lambda a, b: a * b // gcd(a, b)
MOD = 10 ** 9 + 7

def soe(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def solve():
	n = ii()
	ii()
	arr = [[] for x in range(n)]
	arr[0].append(1)
	for x in range(1, n):
		p = ii()
		idx = len(arr[x - 1]) - 1
		if p != 1:
			while True:
				if arr[x - 1][idx] == p - 1:
					idx -= 1
					break
				idx -= 1
		for y in range(0, idx + 1):
			arr[x].append(arr[x - 1][y])
		arr[x].append(p)
	for x in range(n):
		print('.'.join([str(l) for l in arr[x]]))
for _ in range(ii()):
	solve()


import sys
input = sys.stdin.buffer.readline
for _ in range(int(input())):
	n = int(input())
	usable = [[] for i in range(n + 1)]
	usable[0].append([1, 0])
	deepest = [1, 0]
	for i in range(n):
		b = int(input())
		if len(usable[b - 1]) == 0:
			assert b == 1
			new = deepest.copy()
			new[0] += 1
			new.append(1)
			usable[1].append(new)
			deepest = new
		else:
			new = usable[b - 1][-1].copy()
			new[-1] += 1
			for k in range(n + 1):
				j = usable[k]
				while j and j[-1][0] >= new[0]:
					j.pop()
			usable[b].append(new)
			deepest = new
		print('.'.join(map(str, new[1:])))


for _ in range(int(input())):
	nt = int(input())
	a = []
	for _ in range(nt):
		kx = int(input())
		if kx == 1:
			a.append(kx)
		else:
			while a[-1] != kx - 1:
				a.pop()
			a[-1] = kx
		print(*a, sep='.')


def solve(a, n):
	results = []
	prevResult = []
	for (i, x) in enumerate(a):
		if x == 1:
			currResult = prevResult + [1]
		else:
			for i in range(len(prevResult) - 1, -1, -1):
				if prevResult[i] == x - 1:
					currResult = prevResult[:i + 1]
					currResult[i] = x
					break
		prevResult = currResult
		results.append('.'.join([str(x) for x in currResult]))
	return results
t = int(input())
results = []
for _ in range(t):
	n = int(input())
	a = [int(input()) for _ in range(n)]
	result = solve(a, n)
	results.append(result)
for result in results:
	for line in result:
		print(line)


import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	s = []
	for i in range(n):
		v = int(input())
		if v == 1:
			s.append(1)
		else:
			while s[-1] + 1 != v:
				s.pop()
			s[-1] = v
		print('.'.join(map(str, s)))
for i in range(int(input())):
	solve()


def read_int():
	return int(input())

def read_ints():
	return map(int, input().split(' '))
t = read_int()
for case_num in range(t):
	n = read_int()
	stk = []
	for _ in range(n):
		trailing = read_int()
		if trailing == 1:
			stk.append(1)
			print('.'.join(map(str, stk)))
		else:
			while trailing != stk[-1] + 1:
				stk.pop()
			stk.pop()
			stk.append(trailing)
			print('.'.join(map(str, stk)))


t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	s = [1]
	print(1)
	for k in range(n - 1):
		a = input()
		if a == '1':
			s.append(1)
		else:
			while int(a) != int(s[-1]) + 1:
				s.pop()
			s[-1] = int(a)
		for rpo in range(len(s) - 1):
			print(s[rpo], end='')
			print('.', end='')
		print(s[-1])


import sys
import os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
	sys.stderr = open('error.txt', 'w')
depth = 1000005
mod = 1000000007
lim = mod * mod
sys.setrecursionlimit(depth)
linp = lambda : list(minp())
minp = lambda : map(int, input().split())
from math import inf, ceil, sqrt, log2
from collections import defaultdict
dd = lambda x: defaultdict(lambda : x)
for _ in range(int(input())):
	stack = []
	for i in range(int(input())):
		n = int(input())
		if n == 1:
			stack.append(1)
		else:
			while stack[-1] != n - 1:
				stack.pop()
			stack[-1] = n
		print('.'.join((str(c) for c in stack)))


def printNum(v):
	for j in range(len(v)):
		if j != 0:
			print('.', end='')
		print(v[j], end='')
	print()

def main():
	for tc in range(int(input())):
		n = int(input())
		sz = 0
		v = []
		for i in range(n):
			x = int(input())
			if x == 1:
				if sz == 0:
					v.append([1])
				else:
					cur = v[sz - 1].copy()
					cur.append(1)
					v.append(cur)
				sz += 1
			else:
				while sz > 0 and v[sz - 1][len(v[sz - 1]) - 1] != x - 1:
					v.pop()
					sz -= 1
				v[sz - 1][len(v[sz - 1]) - 1] += 1
			printNum(v[sz - 1])
main()


t = int(input())
for _ in range(0, t):
	n = int(input())
	a = []
	a.append(int(input()))
	print(*a)
	l = 1
	for i in range(1, n):
		x = int(input())
		if x == 1:
			a.append(x)
			l = l + 1
			print(*a, sep='.')
		else:
			while x - 1 != a[l - 1]:
				a.pop()
				l = l - 1
			if x - 1 == a[l - 1]:
				a.pop()
				a.append(x)
				print(*a, sep='.')


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b
S1 = 'abcdefghijklmnopqrstuvwxyz'
S2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
for _ in range(int(inp())):
	n = iinp()
	pre = ''
	ml = []
	for i in range(n):
		k = iinp()
		if k == 1 or len(ml) == 0:
			x = k
		else:
			while len(ml) > 0 and ml[-1] != k - 1:
				ml.pop()
			if len(ml):
				ml.pop()
			x = k
		ml.append(x)
		print('.'.join(map(str, ml)))


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		current = []
		for _ in range(n):
			ai = int(input())
			if ai == 1:
				current.append(1)
			else:
				while current[-1] != ai - 1:
					current.pop()
				current[-1] += 1
			print(*current, sep='.')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for t in range(int(input())):
	n = int(input())
	a = []
	for i in range(n):
		x = int(input())
		if x == 1:
			a.append(x)
		else:
			while a:
				y = a.pop()
				if x == y + 1:
					a.append(x)
					break
			if not a:
				a.append(x)
		print('.'.join([str(x) for x in a]))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline()

def RL():
	return map(int, sys.stdin.readline().split())

def RLL():
	return list(map(int, sys.stdin.readline().split()))

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
from heapq import *
from collections import deque as dq
from math import ceil, floor, sqrt, pow, factorial, log2
from collections import Counter
for ii in range(N()):
	n = N()
	st = []
	for i in range(n):
		a = N()
		if len(st) == 0:
			st.append(str(a))
			print(a)
		elif a == 1:
			st.append('1')
			print('.'.join(st))
		else:
			while a != int(st[-1]) + 1:
				st.pop()
			st[-1] = str(int(st[-1]) + 1)
			print('.'.join(st))


import sys
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
import os, sys, atexit
from io import BytesIO, StringIO
_OUTPUT_BUFFER = StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		arr = [0] * n
		for i in range(n):
			arr[i] = int(input())
		if n == 1:
			print(1)
			continue
		stk = [[-1, '']]
		prev = 1
		print(1)
		for i in range(1, n):
			curr = arr[i]
			if curr == prev + 1:
				print(stk[-1][1] + '{}'.format(curr))
				prev = curr
			elif curr == 1:
				stk.append([prev, stk[-1][1] + '{}.'.format(prev)])
				print(stk[-1][1] + '{}'.format(curr))
				prev = curr
			else:
				while True:
					prev = stk.pop()
					if prev[0] + 1 == curr:
						print(stk[-1][1] + '{}'.format(curr))
						prev = curr
						break
main()


t = int(input())
ans = []
for _ in range(t):
	n = int(input())
	lst = [1]
	levels = [1]
	level = 0
	num = int(input())
	for i in range(n - 1):
		num = int(input())
		if num == 1:
			level += 1
			if len(levels) <= level:
				levels.append(1)
			else:
				levels[level] = 1
		else:
			while levels[level] != num - 1:
				level -= 1
			levels[level] = num
		lst.append('.'.join([str(k) for k in levels][:level + 1]))
	ans.extend(lst)
print(*ans, sep='\n')


for _ in range(int(input())):
	n = int(input())
	s = []
	i = 0
	while i < n:
		ref = input()
		i += 1
		if len(s) == 0:
			s.append(ref)
			print(ref)
			continue
		elif ref == '1':
			s.append('1')
		else:
			while len(s) > 0:
				if int(s[-1]) == int(ref) - 1:
					s.pop(-1)
					break
				s.pop(-1)
			s.append(ref)
		j = 1
		l = len(s)
		print(s[0], end='')
		while j < l:
			print('.' + s[j], end='')
			j += 1
		print('')


for I in range(int(input())):
	n = int(input())
	z = []
	for I in range(n):
		a = int(input())
		if a == 1:
			z.append(1)
		else:
			while z[-1] != a - 1:
				z.pop()
			q = z.pop()
			z.append(q + 1)
		print('.'.join(map(str, z)))


import sys
import io, os
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	n = int(input())
	A = [int(input()) for i in range(n)]
	ans = []
	for (i, a) in enumerate(A):
		if i == 0:
			ans.append(str(a))
		else:
			temp = ans[-1]
			L = list(temp.split('.'))
			p = -1
			for j in range(len(L)):
				if int(L[j]) == a - 1:
					p = j
			if p != -1:
				L = L[0:p] + [str(a)]
			else:
				L = L + [str(a)]
			ans.append('.'.join(L))
	for i in range(n):
		print(ans[i])


import sys, os
import math
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		n = int(input())
		if n == 1:
			print(int(input()))
			continue
		arr = []
		for i in range(n):
			arr.append(int(input()))

		def rec(i, lis):
			if i == n:
				return lis
			else:
				(k, p) = (lis[-1], arr[i])
				if p == 1:
					ans = rec(i + 1, lis + [lis[-1] + '.1'])
					if ans:
						return ans
				j = -1
				cur = ''
				while -j <= len(k):
					if k[j] == '.':
						if int(cur) + 1 == p:
							ans = rec(i + 1, lis + [k[:j + 1] + str(p)])
							if ans:
								return ans
						cur = ''
					else:
						cur = k[j] + cur
					j -= 1
				if cur and int(cur) + 1 == p:
					ans = rec(i + 1, lis + [str(p)])
					if ans:
						return ans
		for i in rec(1, ['1']):
			print(i)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def MI():
	return map(int, input().split())

def outP(var):
	sys.stdout.write(str(var) + '\n')
MOD = 10 ** 9 + 7
mod = 998244353
main()


def solve():
	N = int(input())
	A = [int(input()) for _ in range(N)]
	st = [0]
	for a in A:
		if a == st[-1] + 1:
			st[-1] = a
		elif a == 1:
			st.append(1)
		else:
			while a != st[-1] + 1:
				st.pop()
			st[-1] = a
		for i in range(len(st) - 1):
			print(st[i], end='.')
		print(st[-1])
T = int(input())
for _ in range(T):
	solve()


for _ in range(int(input())):
	q = []
	for p in range(int(input())):
		q.append(int(input()))
	temp = [1]
	for i in range(len(q)):
		if i == 0:
			print(1)
		else:
			found = False
			for n in range(len(temp)):
				if temp[len(temp) - n - 1] + 1 == q[i]:
					temp[len(temp) - n - 1] += 1
					temp = temp[:len(temp) - n]
					print(*temp, sep='.')
					found = True
					break
			if found == False:
				temp.append(1)
				print(*temp, sep='.')