Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.

You are given a strictly increasing sequence of integers $A_{1}, A_{2}, \ldots, A_{N}$. Your task is to compress this sequence.

The *compressed form* of this sequence is a sequence of ranges separated by commas (characters ','). A *range* is either an integer or a pair of integers separated by three dots (the string "..."). When each range a...b in the compressed form is decompressed into the subsequence $(a, a+1, \ldots, b)$, we should obtain the (comma-separated) sequence $A$ again.

For each maximal contiguous subsequence $(a, a+1, \ldots, b)$ of $A$ such that $b ≥ a+2$, the compressed form of $A$ must contain the range a...b; if $b ≤ a+1$, such a sequence should not be compressed into a range. A contiguous subsequence is maximal if it cannot be extended by at least one element of $A$ next to it. It can be proved that the compressed form of any sequence is unique (i.e. well-defined).

------  Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first line of each test case contains a single integer $N$.
The second line contains $N$ space-separated integers $A_{1}, A_{2}, \ldots, A_{N}$.

------  Output ------
For each test case, print a single line containing one string ― the compressed form of the given sequence.

------  Constraints ------
$1 ≤ T ≤ 100$
$1 ≤ N ≤ 100$
$1 ≤ A_{i} ≤ 1,000$ for each valid $i$
$A_{1} < A_{2} < \ldots < A_{N}$

------  Subtasks ------
Subtask #1 (100 points): original constraints

----- Sample Input 1 ------ 
3

12

1 2 3 5 6 8 9 10 11 12 15 17

4

4 5 7 8

1

4
----- Sample Output 1 ------ 
1...3,5,6,8...12,15,17

4,5,7,8

4
----- explanation 1 ------ 
Example case 1:
- $(1, 2, 3)$ is a contiguous subsequence with length $3$, so it is replaced by the string "1...3"
- $(5, 6)$ is a contiguous subsequence, but only with length $2$, so it is not compressed into a range
- $(8, 9, 10, 11, 12)$ is a contiguous subsequence with length $5$, so it is replaced by "8...12"
- the elements $15$, $17$ are unaffected

Difficulty: MEDIUM

Solutions:
t = int(input())
for z in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	i = 0
	s = str(l[0])
	while i < n - 1:
		j = i + 1
		c = 1
		while j < n:
			if l[i] + j - i == l[j]:
				c += 1
				j += 1
			else:
				break
		if c >= 3:
			i = i + c
			if i < n:
				s = s + '...' + str(l[i - 1]) + ',' + str(l[i])
			else:
				s = s + '...' + str(l[i - 1])
		else:
			i = i + 1
			s = s + ',' + str(l[i])
	print(s)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	string = str(a[0])
	count = 0
	for i in range(1, len(a)):
		if a[i] == a[i - 1] + 1:
			count += 1
		elif count == 0:
			string += ','
			string += str(a[i])
		elif count == 1:
			string += ',' + str(a[i - 1]) + ',' + str(a[i])
			count = 0
		else:
			string += '...' + str(a[i - 1]) + ',' + str(a[i])
			count = 0
	if count == 1:
		string += ',' + str(a[-1])
	elif count > 1:
		string += '...' + str(a[-1])
	else:
		pass
	print(string)


case = int(input())
for _ in range(case):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	length = 0
	number = 0
	i = 0
	while i < n:
		if length == 0:
			print(arr[i], end='')
			length += 1
			number = arr[i] + 1
		elif arr[i] == number:
			length += 1
			number += 1
		elif length == 1:
			print(',', end='')
			length = 0
			number = 0
			i -= 1
		elif length == 2:
			print(',' + str(arr[i - 1]) + ',', end='')
			length = 0
			number = 0
			i -= 1
		elif length >= 3:
			print('...' + str(arr[i - 1]) + ',', end='')
			length = 0
			number = 0
			i -= 1
		i += 1
	if length == 2:
		print(',' + str(arr[i - 1]) + '', end='')
	elif length >= 3:
		print('...' + str(arr[i - 1]) + '', end='')
	print()


for _ in range(int(input())):
	N = int(input())
	arr = list(map(int, input().split()))
	akhir = arr[0]
	panjang = 0
	for i in range(1, N):
		if arr[i] - akhir == 1:
			panjang += 1
		elif panjang == 0:
			print(akhir, end=',')
			panjang = 0
		elif panjang == 1:
			print(akhir - 1, end=',')
			print(akhir, end=',')
			panjang = 0
		else:
			print(akhir - panjang, end='...')
			print(akhir, end=',')
			panjang = 0
		akhir = arr[i]
	if panjang == 0:
		print(akhir)
	elif panjang == 1:
		print(akhir - 1, end=',')
		print(akhir)
	else:
		print(akhir - panjang, end='...')
		print(akhir)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split())) + [1001]
	s = str(a[0])
	mark = 1
	for i in range(1, n + 1):
		if a[i] - a[i - 1] > 1:
			if mark == 1:
				s += ',' + str(a[i])
			elif mark > 2:
				s += '...' + str(a[i - 1]) + ',' + str(a[i])
			else:
				s += ',' + str(a[i - 1]) + ',' + str(a[i])
			mark = 1
		else:
			mark += 1
	print(s.replace(',1001', ''))


tests = int(input())
for i in range(tests):
	length = int(input())
	arr = list(map(int, input().split()))
	temp_arr = []
	ans = str(arr[0])
	for j in range(1, length):
		if arr[j] - arr[j - 1] != 1:
			if len(temp_arr) >= 2:
				ans += '...'
				ans += str(temp_arr[-1]) + ','
			elif len(temp_arr) > 0:
				for k in temp_arr:
					ans += ',' + str(k)
			if len(ans) > 0 and ans[-1] != ',':
				ans += ','
			ans += str(arr[j])
			temp_arr = []
		else:
			temp_arr.append(arr[j])
	if len(temp_arr) >= 2:
		ans += '...'
		ans += str(temp_arr[-1])
	elif len(temp_arr) > 0:
		for k in temp_arr:
			ans += ',' + str(k)
	print(ans)


from bisect import bisect_left, bisect_right
import math
from sys import maxsize
from collections import defaultdict
from bisect import bisect_left
from heapq import heapify, heappush, heappop
from collections import deque
import sys
from math import gcd, sqrt, log10, log2, floor, ceil, sqrt
from collections import deque, defaultdict
input = sys.stdin.readline

def il():
	return [int(a) for a in input().strip().split()]

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

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

def ot(in_p, *args, e=' '):
	if type(in_p) == list:
		print(*in_p, end=e)
	if type(in_p) == str or type(in_p) == int:
		print(in_p, end=e)
		for l in args:
			print(l, end=e)
	print()

def a_pwr_n(a, n, mod):
	if n == 1:
		return a % mod
	if n % 2 == 0:
		val = a_pwr_n(a, n // 2, mod)
		return val % mod * val % mod
	else:
		return a % mod * a_pwr_n(a, n - 1, mod) % mod

def rg(*ag):
	if len(ag) == 3:
		return range(ag[0], ag[1], ag[2])
	elif len(ag) == 2:
		return range(ag[0], ag[1])
	elif len(ag) == 1:
		return range(ag[0])
	else:
		raise 'invalid input'

def ispal(i, j, st):
	while i <= j:
		if st[i] == st[j]:
			i = i + 1
			j = j - 1
		else:
			return False
	return True
mod = 1000000000 + 7
dx = [-1, -2, 1, 2, 2, -2, -1, 1]
dy = [2, 1, 2, 1, -1, -1, -2, -2]
for t in range(ii()):
	n = ii()
	l = il()
	l.append(1)
	c = 0
	for i in range(len(l) - 1):
		a = l[i]
		if l[i] + 1 == l[i + 1]:
			c += 1
		else:
			if c >= 2:
				print(l[i] - c, end='')
				print('...', end='')
				print(l[i], end='')
			elif c == 1:
				print(l[i - 1], end=',')
				print(l[i], end='')
			elif c == 0:
				print(l[i], end='')
			if i < n - 1:
				print(',', end='')
			c = 0
	print()


testCases = int(input())
for testCase in range(testCases):
	n = int(input())
	a = list(map(int, input().split()))
	out = str(a[0]) + ','
	flag = False
	for i in range(1, n - 1):
		if a[i] + 1 == a[i + 1] and a[i] - 1 == a[i - 1] and (flag == False):
			out += '...'
			flag = True
		elif a[i] + 1 == a[i + 1] and a[i] - 1 == a[i - 1] and (flag == True):
			continue
		else:
			out += str(a[i]) + ','
			flag = False
	out += str(a[n - 1])
	out = out.replace(',.', '.')
	if n == 1:
		print(*a)
	else:
		print(out)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	i = 0
	(p, q) = (a[0], a[0])
	boo = True
	for x in range(a[0], a[-1] + 1):
		if x == a[i]:
			if boo:
				p = a[i]
				boo = False
			else:
				q = a[i]
			i += 1
		elif not boo:
			if p < q:
				print(str(p) + '...' + str(q), end=',') if q - p > 1 else print(str(p) + ',' + str(q), end=',')
			else:
				print(p, end=',')
			boo = True
	if p < q:
		print(str(p) + '...' + str(q)) if q - p > 1 else print(str(p) + ',' + str(q))
	else:
		print(p)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = ''
	i = 0
	while i < n:
		if i != 0:
			s = s + ','
		j = i
		count = 1
		while j < n - 1 and a[j] + 1 == a[j + 1]:
			count += 1
			j += 1
		if count >= 3:
			s += str(a[i]) + '...' + str(a[j])
			i = j + 1
		else:
			s += str(a[i])
			i += 1
	print(s)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = ''
	i = 0
	while i < n:
		if i != 0:
			s += ','
		j = i
		cnt = 1
		while j < n - 1 and a[j] + 1 == a[j + 1]:
			cnt += 1
			j += 1
		if cnt >= 3:
			s += str(a[i]) + '...' + str(a[j])
			i = j + 1
		else:
			s += str(a[i])
			i += 1
	print(s)


t = int(input())
for _ in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	i = 0
	while i < n:
		count = 1
		j = i
		while i < n - 1 and l[i + 1] - l[i] == 1:
			count += 1
			i += 1
		if count >= 3:
			print(str(l[j]) + '...' + str(l[i]), end='')
		elif count == 2:
			print(str(l[j]) + ',' + str(l[i]), end='')
		else:
			print(str(l[j]), end='')
		if i < n - 1:
			print(',', end='')
		i += 1
	print()


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	i = 0
	s = ''
	while i < n:
		if i != 0:
			s = s + ','
		j = i
		count = 1
		while j < n - 1 and arr[j] + 1 == arr[j + 1]:
			count += 1
			j += 1
		if count >= 3:
			s = s + str(arr[i]) + '...' + str(arr[j])
			i = j + 1
		else:
			s = s + str(arr[i])
			i += 1
	print(s)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = [a[0]]
	c = ''
	for i in range(1, n):
		if a[i] == a[i - 1] + 1:
			b += [a[i]]
		else:
			if len(b) == 1:
				c += str(b[0]) + ','
			elif len(b) == 2:
				c += str(b[0]) + ',' + str(b[1]) + ','
			else:
				c += str(b[0]) + '...' + str(b[-1]) + ','
			b = [a[i]]
	if len(b) == 1:
		c += str(b[0]) + ','
	elif len(b) == 2:
		c += str(b[0]) + ',' + str(b[1]) + ','
	else:
		c += str(b[0]) + '...' + str(b[-1]) + ','
	print(c[:-1])


for _ in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	x_rep = [x[0]]
	l = 1
	for i in range(1, n):
		if x[i] != x[i - 1] + 1:
			if l >= 3:
				x_rep += ['...', x[i - 1], ',', x[i]]
			elif l == 2:
				x_rep += [',', x[i - 1], ',', x[i]]
			elif l == 1:
				x_rep += [',', x[i]]
			l = 1
		else:
			l += 1
	if l >= 3:
		x_rep += ['...', x[i]]
	elif l == 2:
		x_rep += [',', x[i]]
	for i in x_rep:
		print(i, end='')
	print()


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	s = ''
	i = 0
	while i <= n - 1:
		j = i
		cnt = 1
		while j < n - 1 and arr[j] + 1 == arr[j + 1]:
			j += 1
			cnt += 1
		if cnt > 2:
			s = s + ',' + str(arr[i]) + '...' + str(arr[j])
			i = j + 1
		else:
			s = s + ',' + str(arr[i])
			i += 1
	print(s[1:])


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	temp = [1] * n
	for i in range(1, n):
		if arr[i] == arr[i - 1] + 1:
			temp[i] = temp[i - 1] + 1
	string = ''
	i = n - 1
	while i >= 0:
		if temp[i] > 2:
			s = i - temp[i] + 1
			e = i
			string = ',' + str(arr[s]) + '...' + str(arr[e]) + string
			i = i - temp[i]
		else:
			string = ',' + str(arr[i]) + string
			i = i - 1
	print(string[1:])


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	temp = [0] * n
	temp[0] = 1
	for i in range(1, n):
		if arr[i] - 1 == arr[i - 1]:
			temp[i] = temp[i - 1] + 1
		else:
			temp[i] = 1
	s = ''
	i = n - 1
	while i >= 0:
		if temp[i] <= 2:
			s = ',' + str(arr[i]) + s
			i -= 1
		else:
			start = i - (temp[i] - 1)
			end = i
			s = ',' + str(arr[start]) + '...' + str(arr[end]) + s
			i = i - temp[i]
	print(s[1:])


for u in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	i = 0
	ans = []
	while i < n:
		j = i + 1
		x = l[i]
		while j < n and abs(l[j] - x) == 1:
			x = l[j]
			j += 1
		j -= 1
		if abs(j - i) > 1:
			ans.append(str(l[i]) + '...' + str(l[j]))
		else:
			ans.append(str(l[i]))
			if j != i:
				ans.append(str(l[j]))
		i = j + 1
	print(','.join(ans))


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = []
	a = 0
	b = 0
	for i in range(1, n):
		if l1[b] == l1[i] - 1:
			b = i
		else:
			if a == b:
				l2.append(l1[b])
			elif a == b - 1:
				l2.extend([l1[a], l1[b]])
			else:
				l2.append(str(l1[a]) + '...' + str(l1[b]))
			a = b = i
	if a == b:
		l2.append(l1[b])
	elif a == b - 1:
		l2.extend([l1[a], l1[b]])
	else:
		l2.append(str(l1[a]) + '...' + str(l1[b]))
	print(*l2, sep=',')


for _ in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input().split()]
	result = []
	stack = []
	for elt in arr:
		if len(stack) == 0 or elt == stack[-1] + 1:
			stack.append(elt)
		elif elt != stack[-1] + 1:
			if len(stack) == 1:
				result.append(str(stack[0]))
			elif len(stack) > 2:
				result.append(str(stack[0]) + '...' + str(stack[-1]))
			else:
				result.append(str(stack[0]))
				result.append(str(stack[-1]))
			stack.clear()
			stack.append(elt)
		else:
			pass
	if len(stack) == 1:
		result.append(str(stack[0]))
	elif len(stack) == 2:
		result.append(str(stack[0]))
		result.append(str(stack[-1]))
	else:
		result.append(str(stack[0]) + '...' + str(stack[-1]))
	print(','.join(result))


t = int(input())
for i in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	p = li[0]
	x = [li[0]]
	f = []
	for i in li[1:]:
		if p + 1 == i:
			x.append(i)
			p = i
		else:
			f.append(x)
			x = [i]
			p = i
	else:
		f.append(x)
	a = []
	for i in f:
		if len(i) > 2:
			a.append(str(i[0]) + '...' + str(i[-1]))
		elif len(i) == 2:
			a.append(str(i[0]))
			a.append(str(i[1]))
		else:
			a.append(str(i[0]))
	s = ','
	print(s.join(a))


subtask = int(input())

def answer(compressed):
	answer = []
	for i in compressed:
		if len(i) == 1:
			answer.append(i[0])
		elif len(i) == 2:
			answer.append(i[0])
			answer.append(i[1])
		else:
			answer.append(f'{i[0]}...{i[-1]}')
	print(*answer, sep=',')
for _ in range(subtask):
	N = int(input())
	arr = [int(i) for i in input().split()]
	compressed = []
	S = 0
	while S < len(arr):
		if S + 1 == len(arr):
			compressed.append([arr[S]])
			break
		else:
			temp = []
			while S + 1 < len(arr) and arr[S] + 1 == arr[S + 1]:
				temp.append(arr[S])
				S += 1
			temp.append(arr[S])
			S += 1
			compressed.append(temp)
	answer(compressed)


t = int(input())
for k in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	p = [0] * n
	count = 0
	z = n - 1
	for i in range(n - 2, -1, -1):
		if l[i + 1] - l[i] != 1:
			p[i] = i + 1
			count = 0
			z = i
		else:
			count += 1
			if count >= 2:
				p[i] = z
			else:
				p[i] = i + 1
	print(l[0], end='')
	i = 0
	while i < n - 1:
		if p[i] - i >= 2:
			print('...', end='')
			print(l[p[i]], end='')
			i = p[i]
		else:
			print(',', end='')
			print(l[p[i]], end='')
			i = p[i]
	if k != t - 1:
		print()


T = int(input())
for i in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	t = [a[0]]
	flag = 0
	b = []
	for i in range(n):
		if i != n - 1:
			if a[i] + 1 == a[i + 1]:
				flag = 0
				t.append(a[i + 1])
			else:
				flag = 1
				b.append(t)
				t = []
				t.append(a[i + 1])
	if len(t) != 0:
		b.append(t)
	c = []
	for i in b:
		if len(i) == 1:
			c.append(str(i[0]))
		elif len(i) == 2:
			c.append(str(i[0]))
			c.append(str(i[1]))
		else:
			c.append(str(i[0]) + '...' + str(i[-1]))
	print(','.join(c))


t = input()
t = int(t)
for _ in range(t):
	n = input()
	n = int(n)
	inp = input().split(' ')
	inp = [int(x) for x in inp]
	s = inp[0]
	j = 1
	if n == 1:
		print(s)
	else:
		for i in range(1, n):
			if inp[i] - 1 == inp[i - 1]:
				j += 1
				if i == n - 1:
					if j <= 2:
						print('{},{}'.format(s, inp[i]))
					else:
						print('{}...{}'.format(s, inp[i]))
			elif i != n - 1:
				if j == 1:
					print('{},'.format(s), end='')
					s = inp[i]
				elif j == 2:
					print('{},{},'.format(s, inp[i - 1]), end='')
					s = inp[i]
					j = 1
				elif j > 2:
					print('{}...{},'.format(s, inp[i - 1]), end='')
					s = inp[i]
					j = 1
			elif j == 1:
				print('{},{}'.format(s, inp[i]))
			elif j == 2:
				print('{},{},{}'.format(s, inp[i - 1], inp[i]))
			elif j > 2:
				print('{}...{},{}'.format(s, inp[i - 1], inp[i]))


for T in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	B = [A[0]]
	result1 = []
	result2 = []
	for i in range(N - 1):
		if A[i] + 1 == A[i + 1]:
			B.append(A[i + 1])
		else:
			result1.append(B)
			B = []
			B.append(A[i + 1])
	result1.append(B)
	for e in range(len(result1)):
		if len(result1[e]) == 1:
			result2.append(str(result1[e][0]))
		elif len(result1[e]) == 2:
			result2.append(str(result1[e][0]))
			result2.append(str(result1[e][1]))
		else:
			result2.append(str(result1[e][0]) + '...' + str(result1[e][-1]))
	print(','.join(result2))


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = []
	f = 0
	temp = []
	temp.append(a[0])
	for i in range(n - 1):
		if a[i] == a[i + 1] - 1:
			f = 0
			temp.append(a[i + 1])
		else:
			f = 1
			b.append(temp)
			temp = []
			temp.append(a[i + 1])
	if len(temp) != 0:
		b.append(temp)
	c = []
	for i in b:
		if len(i) == 1:
			c.append(str(i[0]))
		elif len(i) == 2:
			c.append(str(i[0]))
			c.append(str(i[1]))
		else:
			c.append(str(i[0]) + '...' + str(i[-1]))
	print(','.join(c))


for _ in range(int(input())):
	n = int(input())
	seq = list(map(int, input().split()))
	ans = []
	res = []
	temp = [seq[0]]
	for i in range(1, n):
		if seq[i] == seq[i - 1] + 1:
			temp.append(seq[i])
		else:
			ans.append(temp)
			temp = [seq[i]]
	ans.append(temp)
	for j in ans:
		if len(j) == 2:
			res.append(j[0])
			res.append(j[1])
		elif len(j) < 2:
			res.append(j[0])
		else:
			res.append(str(j[0]) + '...' + str(j[-1]))
	print(*res, sep=',')


for _ in range(int(input())):
	n = int(input())
	num = list(map(int, input().split()))
	ans = []
	ans1 = []
	temp = [num[0]]
	for k in range(1, n):
		if num[k] == num[k - 1] + 1:
			temp.append(num[k])
		else:
			ans.append(temp)
			temp = [num[k]]
	ans.append(temp)
	for i in ans:
		if len(i) > 2:
			ans1.append(str(i[0]) + '...' + str(i[-1]))
		elif len(i) == 2:
			ans1.append(i[0])
			ans1.append(i[1])
		else:
			ans1.append(i[0])
	print(*ans1, sep=',')


t = int(input())
for k in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	c = 1
	a1 = a[0]
	s1 = a[0]
	ans = []
	for i in range(1, n):
		z = a[i] - 1
		if z == a1:
			c += 1
			a1 = a[i]
			stop = a[i]
		else:
			if c == 1:
				ans.append(s1)
			elif c == 2:
				ans.append(s1)
				ans.append(stop)
			else:
				st = str(s1) + '...' + str(stop)
				ans.append(st)
			c = 1
			a1 = a[i]
			s1 = a[i]
		if i == n - 1:
			if c == 1:
				ans.append(s1)
			elif c == 2:
				ans.append(s1)
				ans.append(stop)
			else:
				st = str(s1) + '...' + str(stop)
				ans.append(st)
	for j in range(0, len(ans)):
		if j == len(ans) - 1:
			print(ans[j])
		else:
			print(ans[j], end=',')
	if n == 1:
		print(a[0])


t = int(input())
for j in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	c = 1
	w = [ar[0]]
	st = ''
	for i in range(1, n):
		if ar[i] - ar[i - 1] == 1:
			w.append(ar[i])
			c += 1
		else:
			if c == 1:
				st = st + str(w[0]) + ','
			elif c == 2:
				st = st + (str(w[0]) + ',' + str(w[1]) + ',')
			elif c >= 3:
				st = st + (str(w[0]) + '...' + str(w[len(w) - 1]) + ',')
			w = [ar[i]]
			c = 1
	if c == 1:
		st = st + str(w[0])
	elif c == 2:
		st = st + (str(w[0]) + ',' + str(w[1]))
	elif c >= 3:
		st = st + (str(w[0]) + '...' + str(w[len(w) - 1]))
	print(st)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	i = 0
	s = ''
	if n == 1:
		print(l[0])
		continue
	while i < n:
		j = i + 1
		k = 0
		while j < n:
			if l[j] - l[j - 1] > 1:
				break
			k += 1
			j += 1
		if j - 1 == i:
			s += str(l[i]) + ','
			i = j
			continue
		if k > 1:
			s += str(l[i]) + '...' + str(l[j - 1]) + ','
		else:
			s += str(l[i]) + ',' + str(l[j - 1]) + ','
		i = j
	print(s[:-1])


T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	s = ''
	i = 0
	while i < n:
		j = i + 1
		while j < n and a[j] == a[i] + (j - i):
			j = j + 1
		if j - i == 2:
			s = s + str(a[i]) + ',' + str(a[j - 1]) + ','
		elif j - i > 2:
			s = s + str(a[i]) + '...' + str(a[j - 1]) + ','
		else:
			s = s + str(a[i]) + ','
		i = j
	ls = len(s)
	if s[ls - 1] == ',':
		print(s[:ls - 1])
	else:
		print(s)


t = int(input())

class union_find:

	def __init__(self, n):
		self.n = n
		self.parent_of = [-1] * (n + 1)
		self.child_of = {}
		for i in range(n + 1):
			self.child_of[i] = [i]

	def union(self, x, y):
		(x, size_x) = self.find(x)
		(y, size_y) = self.find(y)
		if size_y > size_x:
			(x, y) = (y, x)
		for i in self.child_of[y]:
			self.parent_of[i] = x
			self.parent_of[x] = self.parent_of[x] - 1
		self.child_of[x] = self.child_of[x] + self.child_of[y]
		del self.child_of[y]

	def find(self, i):
		if self.parent_of[i] < 0:
			return (i, abs(self.parent_of[i]))
		else:
			return (self.parent_of[i], abs(self.parent_of[self.parent_of[i]]))

	def display(self):
		print(self.child_of)
		print(self.parent_of)
for T in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	if n == 1:
		print(s[0])
	else:
		unif = union_find(max(s))
		present = {}
		for i in range(n - 1):
			present[s[i]] = 1
			if s[i] + 1 == s[i + 1]:
				unif.union(s[i], s[i + 1])
		present[s[n - 1]] = 1
		parent = list(unif.child_of.keys())
		ans = []
		for i in parent:
			try:
				present[i] == 1
				child = unif.child_of[i]
				if len(child) >= 3:
					ans.append(str(child[0]) + '...' + str(child[-1]))
				else:
					for i in child:
						ans.append(str(i))
			except:
				pass
		lena = len(ans)
		for i in range(lena):
			if i == lena - 1:
				print(ans[i])
			else:
				print(ans[i], end=',')


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	if n == 1:
		print(l[0])
	elif n == 2:
		print(str(l[0]) + ',' + str(l[1]), end='')
	else:
		l.append(-1)
		j = 0
		a = []
		while j < n:
			if l[j] == l[j + 1] - 1 == l[j + 2] - 2:
				temp1 = l[j]
				for k in range(j, n):
					if l[k] == l[k + 1] - 1:
						j += 1
					else:
						temp = l[k]
						j += 1
						break
				a.extend([temp1, '.', '.', '.', temp, ','])
			else:
				a.extend([l[j], ','])
				j += 1
		for j in range(len(a) - 1):
			print(a[j], end='')
	print()


for i in range(int(input())):
	a = int(input())
	lis = list(map(int, input().split()))
	b = 0
	l = []
	s = ''
	for i in range(a):
		if i == 0:
			l.append(lis[i])
		elif lis[i] - lis[i - 1] == 1:
			l.append(lis[i])
		else:
			if len(l) > 2:
				s += str(l[0]) + '...' + str(l[-1]) + ','
			elif len(l) <= 2:
				for j in l:
					s += str(j) + ','
			l = [lis[i]]
	if l:
		if len(l) > 2:
			s += str(l[0]) + '...' + str(l[-1]) + ','
		elif len(l) <= 2:
			for j in l:
				s += str(j) + ','
	print(s.rstrip(','))


K = int(input())
for i in range(K):
	m = int(input())
	a = list(map(int, input().split()))
	i = 0
	c = []
	s = ''
	while i < m - 1:
		if abs(a[i] - a[i + 1]) == 1:
			c.append(a[i])
			i += 1
		else:
			if len(c) >= 2:
				if abs(a[i] - a[i - 1]) == 1:
					c.append(a[i])
					s += str(c[0]) + '...' + str(c[-1]) + ','
			else:
				for j in c:
					s += str(j) + ','
			if a[i] not in c:
				s += str(a[i]) + ','
			i += 1
			c = []
	if len(c) >= 2:
		if abs(a[i] - a[i - 1]) == 1:
			c.append(a[i])
			s += str(c[0]) + '...' + str(c[-1]) + ','
	else:
		for j in c:
			s += str(j) + ','
		if a[i] not in c:
			s += str(a[i]) + ','
	print(s[:-1])


for _ in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	Count = 1
	SA = [A[0]]
	Ans = ''
	for i in range(1, N):
		if A[i] - A[i - 1] == 1:
			SA.append(A[i])
			Count += 1
		else:
			if Count == 1:
				Ans = Ans + str(SA[0]) + ','
			elif Count == 2:
				Ans = Ans + (str(SA[0]) + ',' + str(SA[1]) + ',')
			elif Count >= 3:
				Ans = Ans + (str(SA[0]) + '...' + str(SA[len(SA) - 1]) + ',')
			SA = [A[i]]
			Count = 1
	if Count == 1:
		Ans = Ans + str(SA[0])
	elif Count == 2:
		Ans = Ans + (str(SA[0]) + ',' + str(SA[1]))
	elif Count >= 3:
		Ans = Ans + (str(SA[0]) + '...' + str(SA[len(SA) - 1]))
	print(Ans)


for i in range(int(input())):
	n = int(input())
	y = list(map(int, input().split()))
	f = 0
	k = []
	s = ''
	for i in range(n):
		if i == 0:
			k.append(y[i])
		elif y[i] - y[i - 1] == 1:
			k.append(y[i])
		else:
			if len(k) > 2:
				s += str(k[0]) + '...' + str(k[-1]) + ','
			elif len(k) <= 2:
				for j in k:
					s += str(j) + ','
			k = [y[i]]
	if k:
		if len(k) > 2:
			s += str(k[0]) + '...' + str(k[-1]) + ','
		elif len(k) <= 2:
			for j in k:
				s += str(j) + ','
	print(s.rstrip(','))


def compress(start, last, ans):
	if start is None:
		start = last = i
	elif i - 1 == last:
		last = i
	elif last - start == 1:
		ans += str(start) + ',' + str(last) + ','
		start = last = i
	elif last == start:
		ans += str(start) + ','
		start = last = i
	else:
		ans += str(start) + '...' + str(last) + ','
		start = last = i
	return (start, last, ans)
for _ in range(int(input())):
	n = int(input())
	a = map(int, input().split())
	start = None
	last = None
	ans = ''
	for i in a:
		(start, last, ans) = compress(start, last, ans)
	(start, last, ans) = compress(start, last, ans)
	print(ans.rstrip(','))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split(' ')))
	s = str(a[0])
	c = 1
	for i in range(1, n):
		if a[i] == a[i - 1] + 1:
			c = c + 1
			end = a[i]
			if i == n - 1:
				if c > 2:
					s = s + '...' + str(a[i])
				else:
					s = s + ',' + str(a[i])
		else:
			if c > 2:
				s = s + '...' + str(end)
			elif c == 2:
				s = s + ',' + str(a[i - 1])
			c = 1
			if i != n - 1:
				s = s + ',' + str(a[i])
			else:
				s = s + ',' + str(a[i])
	print(s)


t = int(input())
for _ in range(t):
	n = int(input())
	numbers = list(map(int, input().split(' ')))
	if n >= 3:
		(Str, i) = (str(numbers[0]), 1)
		while i < n:
			if numbers[i - 1] != numbers[i] - 1:
				Str += ','
				Str += str(numbers[i])
				i += 1
			else:
				j = i
				while i < n and numbers[i] - 1 == numbers[i - 1]:
					i += 1
				if i - 1 == j:
					Str += ','
					Str += str(numbers[j])
				else:
					Str += '...'
					Str += str(numbers[i - 1])
		print(Str)
	else:
		for i in range(n - 1):
			print(numbers[i], end=',')
		print(numbers[-1])


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	i = 0
	c = []
	s = ''
	while i < n - 1:
		if abs(arr[i] - arr[i + 1]) == 1:
			c.append(arr[i])
			i += 1
		else:
			if len(c) >= 2:
				if abs(arr[i] - arr[i - 1]) == 1:
					c.append(arr[i])
					s += str(c[0]) + '...' + str(c[-1]) + ','
			else:
				for j in c:
					s += str(j) + ','
			if arr[i] not in c:
				s += str(arr[i]) + ','
			i += 1
			c = []
	if len(c) >= 2:
		if abs(arr[i] - arr[i - 1]) == 1:
			c.append(arr[i])
			s += str(c[0]) + '...' + str(c[-1]) + ','
	else:
		for j in c:
			s += str(j) + ','
		if arr[i] not in c:
			s += str(arr[i]) + ','
	print(s[:-1])


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	j = 0
	while j < n:
		f = 0
		print(l[j], end='')
		if j + 2 < n and l[j] == l[j + 1] - 1 and (l[j + 1] == l[j + 2] - 1):
			print('...', end='')
			j = j + 2
			while j + 1 < n and l[j] == l[j + 1] - 1:
				f = 1
				j = j + 1
			j = j - 1
		elif j != n - 1:
			print(',', end='')
		j = j + 1
	print()


for _ in range(int(input())):
	(n, l, count) = (int(input()), [], 1)
	q = str()
	li = list(map(int, input().split()))
	for i in range(n):
		li.append(0)
	for i in range(1, n + n):
		if li[i] - li[i - 1] == 1:
			count += 1
		elif count > 2:
			a = i - count
			b = str(li[a]) + '...' + str(li[i - 1])
			l.append(b)
			count = 1
		elif count == 2:
			l.append(str(li[i - 2]))
			l.append(str(li[i - 1]))
			count = 1
		else:
			l.append(str(li[i - 1]))
	for i in range(len(l)):
		if l[i] != '0':
			q += l[i] + ','
	print(q[:len(q) - 1])