Write a program that receives a number n as input and prints it in the following format as shown below.
Like for n = 2 the pattern will be:
1*2*5*6
--3*4
Example 1:
Input: n = 3
Output: 
1*2*3*10*11*12
--4*5*8*9
----6*7
Explaination: If the pattern shown in question 
is followed, this will be the output.
Your Task:
You do not need to read input or print anything. Your task is to complete the function pattern() which takes n as input parameter and returns a list of string where each string denotes a new line of the pattern.
Expected Time Complexity: O(n^{2})
Expected Auxiliary Space: O(n^{2})
Constraints:
1 ≤ n ≤ 70

Difficulty: EASY
Expected Time Complexity: O(n^{2})
Expected Auxiliary Space: O(n^{2})

Starter code:
#User function Template for python3



class Solution:

    def pattern(self, n):

        # code here

Solutions:
class Solution:

	def pattern(self, n):
		m = n
		c = 1
		lst = []
		for i in range(n):
			str1 = ''
			str1 += '--' * i
			for j in range(n - i):
				str1 += str(c) + '*'
				c += 1
			lst.append(str1)
		for i in range(n):
			for j in range(i + 1):
				lst[-i - 1] += str(c) + '*'
				c += 1
			lst[-i - 1] = lst[-i - 1][:-1]
		return lst


class Solution:

	def pattern(self, n):
		l = n * (n + 1) // 2
		r = l + 1
		sol = []
		for i in range(n):
			for j in range(i + 1):
				if j == 0:
					temp = str(l) + '*' + str(r)
					l -= 1
					r += 1
				else:
					temp = str(l) + '*' + temp + '*' + str(r)
					l -= 1
					r += 1
			sol.insert(0, temp)
		for i in range(n):
			sol[i] = '--' * i + sol[i]
		return sol


class Solution:

	def pattern(self, n):
		res = [''] * n
		rres = [''] * n
		c = 1
		for i in range(n):
			s = ''
			for j in range(n - i):
				s += str(c) + '*'
				c += 1
			res[i] = s
		for i in range(n - 1, -1, -1):
			s = ''
			for j in range(n - i):
				s += str(c) + '*'
				c += 1
			res[i] += s[:-1]
		for i in range(n):
			rres[i] = '-' * (i * 2) + res[i]
		return rres


class Solution:

	def pattern(self, n):
		sept = '-'
		f = 1
		l = n ** 2 + n
		ret = []
		for i in range(n):
			s = ''
			s = s + 2 * i * sept
			for j in range(n - i, 0, -1):
				s = s + str(f) + '*'
				f += 1
			for j in range(n - i, 0, -1):
				if j == 1:
					s = s + str(l - j + 1)
				else:
					s = s + str(l - j + 1) + '*'
			l = l - n + i
			ret.append(s)
		return ret


class Solution:

	def pattern(self, n):
		ar = []
		k = 1
		for i in range(n):
			st = ''
			for j in range(i):
				st += '--'
			for j in range(n - i):
				st += str(k) + '*'
				k += 1
			m = (n - i - 1) * (n - i)
			for l in range(n - i - 1):
				st += str(k + m) + '*'
				m += 1
			st += str(k + m)
			ar.append(st)
		return ar


class Solution:

	def pattern(self, n):
		l = []
		k = n * (n + 1)
		c = 1
		x = 0
		for i in range(n, 0, -1):
			s = ''
			for sp in range(1, x + 1):
				s = s + '-'
			for j in range(1, i + 1):
				s = s + str(c) + '*'
				c += 1
			for j in range(k - i + 1, k):
				s = s + str(j) + '*'
			s = s + str(k)
			l.append(s)
			k -= i
			x += 2
		return l


class Solution:

	def pattern(self, n):
		data = [[] for x in range(n)]
		curr = 1
		for x in [*range(1, n + 1), *range(n, 0, -1)]:
			for y in range(n - x + 1):
				data[x - 1].append(str(curr))
				curr += 1
		data = list(map(lambda dd: '*'.join(dd), data))
		for x in range(n):
			data[x] = '-' * (2 * x) + data[x]
		return data


class Solution:

	def pattern(self, n):
		(row, column, dashes) = (0, 0, 0)
		(i, j, dash_counter) = (0, 0, 0)
		value = 1
		(k, l, decrementor) = (0, 0, 0)
		column_decrementor = 0
		support = n - 1
		temp = n * n + 1
		temp1 = n * 2 - 1
		z = temp
		tracker = 0
		res = []
		for i in range(1, n + 1):
			s = ''
			for it in range(dash_counter):
				s += '-'
			for j in range(1, 2 * n - dash_counter + 1):
				if j % 2 == 0:
					s += '*'
				else:
					s += str(value)
					value += 1
			for k in range(1, temp1 - decrementor + 1):
				if k % 2 == 0:
					s += '*'
				else:
					if k == 1:
						tracker = temp
					s += str(temp)
					temp += 1
			decrementor += 2
			temp = tracker - support
			support -= 1
			dash_counter += 2
			res.append(s)
		return res


class Solution:

	def pattern(self, n):
		res = [''] * n
		counter = 1
		for i in range(n):
			s = ''
			for j in range(n - i):
				s += str(counter) + '*'
				counter += 1
			res[i] = s
		for i in range(n - 1, -1, -1):
			s = ''
			for j in range(n - i):
				s += str(counter) + '*'
				counter += 1
			res[i] += s[:-1]
		for i in range(n):
			res[i] = '-' * (i << 1) + res[i]
		return res


class Solution:

	def pattern(self, n):
		p = n * (n + 1) // 2 * 2 - (n - 1)
		k = 1
		a = []
		l = 1
		for i in range(n, 0, -1):
			s = ''
			s = s + '-' * ((l - 1) * 2)
			for j in range(i):
				s = s + str(k)
				s = s + '*'
				k = k + 1
			for g in range(i - 1):
				s = s + str(p)
				s = s + '*'
				p = p + 1
			s = s + str(p)
			p = p - (n - l) * 2
			l = l + 1
			a.append(s)
		return a


class Solution:

	def pattern(self, n):
		ans = [''] * n
		counter = 1
		for i in range(0, n):
			s = ''
			for j in range(0, n - i):
				s += str(counter) + '*'
				counter += 1
			ans[i] = s
		for i in range(n - 1, -1, -1):
			s = ''
			for j in range(0, n - i):
				s += str(counter) + '*'
				counter += 1
			ans[i] += s[:-1]
		for i in range(0, n):
			ans[i] = '-' * (i << 1) + ans[i]
		return ans


class Solution:

	def pattern(self, n):
		p = []
		k = 1
		f = n * (n + 1)
		for i in range(1, n + 1):
			s = ''
			for j in range(1, 2 * i - 1):
				s += '-'
			for j in range(1, n - i + 2):
				s += str(k)
				s += '*'
				k += 1
			g = 0
			for j in range(f - (n - i), f + 1):
				g += 1
				s += str(j)
				if g != n - i + 1:
					s += '*'
				f -= 1
			p.append(s)
		return p


class Solution:

	def pattern(self, n):
		l = []
		s = 1
		for i in range(n):
			st = ''
			for j in range(2 * i):
				st += '-'
			for j in range(i, n):
				st += str(s) + '*'
				s += 1
			l.append(st)
		for i in range(n - 1, -1, -1):
			st = ''
			for j in range(i, n):
				st += str(s)
				s += 1
				if j != n - 1:
					st += '*'
			l[i] += st
		return l


class Solution:

	def pattern(self, n):
		a = n
		l = []
		x = 1
		x1 = n * n + 1
		s = ''
		n1 = n
		n2 = n
		for i in range(n):
			s = ''
			if i > 0:
				s += '-' * (2 * i)
			for j in range(n1):
				s += str(x)
				x += 1
				s += '*'
			n1 -= 1
			x2 = x1
			for j in range(n2):
				if j == n2 - 1:
					s += str(x1 + j)
				else:
					s += str(x1 + j)
					s += '*'
			n2 -= 1
			x1 -= n2
			l.append(s)
		return l


class Solution:

	def pattern(self, n):
		s = []
		s1 = []
		a = n * (n + 1)
		m = a // 2
		for i in range(1, a + 1):
			if i <= m:
				s += ['*' + str(i)]
			else:
				s1 += ['*' + str(i)]
		s1 = s1[::-1]
		e = []
		j = 0
		for i in range(1, n + 1):
			b = ''.join(s[-i:] + s1[-i:][::-1])
			e += [b[1:]]
			del s[-i:]
			del s1[-i:]
		e = e[::-1]
		for i in range(len(e)):
			e[i] = '-' * j + e[i]
			j += 2
		return e


class Solution:

	def pattern(self, n):
		k = n
		f = 0
		t = n
		res = []
		while n > 0:
			ans = []
			ans.append('-' * 2 * (t - n))
			for i in range(1, n + 1):
				if i == 1:
					f += 1
					ans.append(f)
				else:
					f += 1
					ans.extend(['*', f])
			f = f - n
			for i in range(1, n + 1):
				f += 1
				ans.extend(['*', f + k * k])
			k -= 1
			n -= 1
			res.append(''.join(map(str, ans)))
		return res


a = int(input())
for t in range(a):
	n = int(input())
	j = 1
	p = n * n
	p = p + n
	for i in range(1, n + 1):
		w = []
		if i > 1:
			print((i - 1) * '--', end='')
		for l in range(0, n - i + 1):
			print(j, end='*')
			j = j + 1
		for k in range(0, n - i + 1):
			w.append(p)
			p = p - 1
		w.sort()
		for i in range(0, len(w)):
			if i == len(w) - 1:
				print(w[i])
			else:
				print(w[i], end='*')


class Solution:

	def pattern(self, n):
		total = int(n * (n + 1) / 2 * 2)
		interval = 0
		result = []
		for i in range(n, 0, -1):
			subStr = ''
			subStr += '-' * (n - i) * 2
			for j in range(interval + 1, interval + i + 1):
				subStr += str(j)
				subStr += '*'
			for k in range(total - i - interval + 1, total - interval + 1):
				subStr += str(k)
				if total - interval != k:
					subStr += '*'
			interval += i
			result.append(subStr)
		return result


class Solution:

	def pattern(self, n):
		x = [''] * n
		a = n * (n + 1)
		y = []
		for i in range(a):
			y.append(i + 1)
		for i in range(1, n + 1):
			x[i - 1] += '-' * (2 * (i - 1))
			for j in y[:n - i + 1]:
				x[i - 1] += str(j) + '*'
				y.remove(j)
			for j in y[-(n - i + 1):]:
				x[i - 1] += str(j) + '*'
				y.remove(j)
			x[i - 1] = x[i - 1][:-1]
		return x


class Solution:

	def pattern(self, n):
		x = []
		number = 1
		for i in range(n, 0, -1):
			c = ''
			c += '-' * ((n - i) * 2)
			for j in range(i):
				c += str(number)
				c += '*'
				number += 1
			x.append(c)
		x = x[::-1]
		y = []
		for i in range(1, n + 1):
			a = x[i - 1]
			for j in range(i):
				a += str(number)
				number += 1
				a += '*'
			y.append(a[:-1])
		return y[::-1]


class Solution:

	def pattern(self, n):
		ans = []
		noof = n * (n + 1)
		cop = n
		(a, b) = (1, noof)
		hyp = 0
		while cop:
			strr = ''
			for i in range(hyp):
				strr += '-'
			hyp += 2
			for i in range(cop):
				strr += str(a) + '*'
				a += 1
			last = b - cop
			for i in range(cop):
				last += 1
				if last == b:
					strr += str(last)
				else:
					strr += str(last) + '*'
			b = b - cop
			cop -= 1
			ans.append(strr)
		return ans


class Solution:

	def pattern(self, n):
		for i in range(n):
			ans = []
			d = n * (n + 1)
			x = 0
			for i in range(n, 0, -1):
				s = '' + '-' * (n - i) * 2
				j = x + 1
				l = 1
				while l <= i * 2:
					s += str(j) + '*'
					if l == i:
						x = j
						j = d - x
					j += 1
					l += 1
				ans.append(s[:-1])
			return ans


class Solution:

	def pattern(self, n):
		m = (n + 1) * n
		l = 1
		ans = []
		for i in range(n):
			temp = []
			temp2 = []
			for j in range(n - i):
				temp.append(str(l))
				l += 1
				temp2.append(str(m))
				m -= 1
			temp2 = temp2[::-1]
			temp.extend(temp2)
			temp = '*'.join(temp)
			for p in range(2 * i):
				temp = '-' + temp
			ans.append(temp)
		return ans


class Solution:

	def pattern(self, n):
		ansf = []
		ansl = []
		count = 0
		for i in range(n):
			s = []
			for j in range(n - i):
				count += 1
				s.append(str(count))
			ansf.append(2 * i * '-' + '*'.join(s))
		for i in range(n):
			s = []
			for j in range(i + 1):
				count += 1
				s.append(str(count))
			ansl.append('*'.join(s))
		ansl.reverse()
		ans = []
		for i in range(n):
			ans.append(ansf[i] + '*' + ansl[i])
		return ans


class Solution:

	def pattern(self, n):
		t = int(n * (n + 1) / 2 * 2)
		h = 0
		r = []
		for i in range(n, 0, -1):
			s = ''
			s += '-' * (n - i) * 2
			for j in range(h + 1, h + i + 1):
				s += str(j)
				s += '*'
			for k in range(t - i - h + 1, t - h + 1):
				s += str(k)
				if t - h != k:
					s += '*'
			h += i
			r.append(s)
		return r


class Solution:

	def pattern(self, n):
		s = []
		s.extend(range(1, n * (n + 1) + 1))
		l = list(map(str, s))
		ans = []
		for i in range(n, 0, -1):
			ans.append('-' * ((n - i) * 2) + '*'.join(l[:i]) + '*' + '*'.join(l[-1 * i:]))
			l = l[i:-i]
		return ans


class Solution:

	def pattern(self, n):
		lines = []
		x = n * (n + 1)
		start = 1
		end = x
		prev = x
		for i in range(n):
			line = '--' * i
			arr = [str(j) for j in range(start, start + n - i)] + [str(j) for j in range(end - n + i + 1, prev + 1)]
			start += n - i
			end = end - n + i
			prev = end
			line += '*'.join(arr)
			lines += [line]
		return lines


class Solution:

	def pattern(self, n):
		b = n * (n + 1)
		l = []
		for i in range(b):
			l.append(str(i + 1))
		i = 0
		j = b - 1
		e = []
		c = 0
		for m in range(n, 0, -1):
			t = ''
			t += c * '-'
			p = []
			g = []
			for q in range(m):
				p.append(l[i])
				g.append(l[j])
				i += 1
				j -= 1
			p.extend(g[::-1])
			t += '*'.join(p)
			e.append(t)
			c += 2
		return e


class Solution:

	def pattern(self, n):
		store = []
		no = 1
		for i in range(n):
			curr = []
			for j in range(n - i):
				curr.append(no)
				no += 1
			store.extend(curr)
		for i in range(n):
			curr = []
			for j in range(n - i):
				curr.append(no)
				no += 1
			store.extend(curr)
		f = store[0:len(store) // 2]
		s = store[len(store) // 2:]
		s = s[::-1]
		ans = []
		for i in range(len(f)):
			push1 = []
			push2 = []
			for j in range(n - i):
				push1.append(str(f.pop(0)))
				push1.append('*')
			push1 = push1[:-1]
			for j in range(n - i):
				push2.append(str(s.pop(0)))
				push2.append('*')
			push1.extend(push2[::-1])
			push1.insert(0, '--' * i)
			ans.append(''.join(push1))
		return ans


class Solution:

	def pattern(self, n):
		res = []
		l = n * (n + 1)
		a = list(range(1, l + 1))
		seed = 0
		for x in range(n, 0, -1):
			arr = a[seed:seed + x]
			if seed == 0:
				arr = arr + a[-x - seed:]
			else:
				arr = arr + a[-x - seed:-seed]
			resStr = '--' * (n - x) + '*'.join([str(m) for m in arr])
			res.append(resStr)
			seed += x
		return res


class Solution:

	def pattern(self, n):
		u = n * (n + 1)
		nums = list(range(1, u + 1))
		c_j = 0
		c_k = u - n
		dash = 2
		ans = []
		pres_string = ''
		for i in range(n):
			for j in range(n - i):
				pres_string += str(nums[c_j + j])
				pres_string += '*'
			c_j += j + 1
			for k in range(n - i):
				pres_string += str(nums[c_k + k])
				if k != n - i - 1:
					pres_string += '*'
			c_k -= k
			ans.append(pres_string)
			pres_string = '-' * dash
			dash += 2
		return ans


class Solution:

	def pattern(self, n):
		rtr = [[] for i in range(n)]
		num = 1
		for j in range(n, 0, -1):
			for k in range(n):
				if k < n - j:
					rtr[n - j].append('--')
				else:
					rtr[n - j].append(str(num))
					rtr[n - j].append('*')
					num += 1
		for j in range(1, n + 1):
			for k in range(j):
				rtr[n - j].append(str(num))
				rtr[n - j].append('*')
				num += 1
		rtr = [x[:-1] for x in rtr]
		rtr = [''.join(x) for x in rtr]
		return rtr


class Solution:

	def pattern(self, n):
		lst3 = []
		lst4 = []
		lst = list(range(n * (n + 1)))
		lst.pop(0)
		lst.append(lst[-1] + 1)
		f = 0
		y = 0
		for i in range(n, 0, -1):
			w = 0
			lst1 = []
			for j in range(2):
				for k in range(f, f + i):
					if w == 0:
						lst1.append(lst[k])
					else:
						lst1.append(lst[-k - 1])
				w = 1
			lst1.sort()
			f += i
			lst2 = []
			for x in lst1:
				lst2.append(str(x) + '*')
			lst2 = ''.join(lst2)
			lst2 = lst2[:-1]
			lst3 = ['-' * y + lst2]
			y += 2
			lst2 = []
			lst4.append(lst3[0])
		return lst4


class Solution:

	def pattern(self, n):
		a = []
		for i in range(1, n * (n + 1) + 1):
			a.append(i)
			a.append('*')
		a.pop()
		b = []
		z = 0
		y = n * 2 - 1
		for i in range(n):
			b.append('-' * z + ''.join(map(str, a[:n * 2])) + ''.join(map(str, a[len(a) - y:])))
			a.pop()
			a = a[n * 2:len(a) - y]
			n -= 1
			y -= 2
			z += 2
		return b


class Solution:

	def pattern(self, n):
		l = 1
		r = n * (n + 1)
		lst = []
		for i in range(n, -1, -1):
			str1 = ''
			for space in range(n, i - 1, -1):
				if space < n:
					str1 += '--'
			for j in range(1, i + 1):
				str1 += str(l) + '*'
				l += 1
			for j in range(1, i + 1):
				str1 += str(r - n + 1)
				if j < i:
					str1 += '*'
				r += 1
			r = r - (i - 1) * 2 - 1
			lst.append(str1)
		return lst


class Solution:

	def pattern(self, n):
		r = []
		ln = 0
		for row in range(n):
			rs = '--' * row
			for s in range(n - row):
				ln += 1
				rs += str(ln) + '*'
			r.append(rs)
		for row in range(n - 1, -1, -1):
			for s in range(n - row):
				ln += 1
				r[row] += str(ln) + '*'
		return [rs[:-1] for rs in r]


class Solution:

	def pattern(self, n):
		arr = []
		for i in range(n):
			arr.append('--' * i)
		counter = 0
		index = 0
		for j in range(n, 0, -1):
			for b in range(j):
				counter += 1
				arr[index] = arr[index] + str(counter) + '*'
			index += 1
		for k in range(n, 0, -1):
			for c in range(n - k + 1):
				counter += 1
				arr[k - 1] = arr[k - 1] + str(counter) + '*'
		for l in range(n):
			arr[l] = arr[l][:-1]
		return arr


class Solution:

	def pattern(self, n):
		ans = []
		num = 1
		for i in range(n):
			s = ''
			for j in range(i):
				s += '--'
			for j in range(n - i):
				s += str(num) + '*'
				num += 1
			ans.append(s)
		for i in range(n - 1, -1, -1):
			s = ''
			for j in range(n - i):
				s += str(num) + '*'
				num += 1
			s = s[:-1]
			ans[i] = ans[i] + s
		return ans


class Solution:

	def pattern(self, n):
		start = 1
		end = n * (n + 1)
		c = 0
		arr = []
		while c < n:
			temp = []
			line = []
			i = 0
			j = 0
			while i < n - c:
				line.append(str(start + i))
				i += 1
			while j < n - c:
				temp.append(str(end - j))
				j += 1
			line += temp[::-1]
			s = '-' * 2 * c
			ans = '*'.join(line)
			s += ans
			arr.append(s)
			start += n - c
			end -= n - c
			c += 1
		return arr


class Solution:

	def pattern(self, n):
		N = n * (n + 1)
		l = [i for i in range(1, N + 1)]
		result = []
		for i in range(n):
			S = '--' * i
			for j in range(n - i):
				S += str(l[0])
				l.remove(l[0])
				S += '*'
			for k in range(n - i):
				S += str(l[-n + k + i])
				l.remove(l[-n + k + i])
				if n - i - k > 1:
					S += '*'
			result.append(S)
		return result


class Solution:

	def pattern(self, n):
		(start, end) = (1, n * (n + 1))
		lines = []
		for i in range(n, 0, -1):
			row = list(range(start, start + i)) + list(range(end - i + 1, end + 1))
			lines.append('-' * (2 * (n - i)) + '*'.join((str(v) for v in row)))
			start += i
			end -= i
		return lines


class Solution:

	def pattern(self, n):
		ans = [[] for i in range(n)]
		val = 1
		for i in range(n):
			for j in range(val, val + n - i):
				ans[i].append(j)
			val = ans[i][-1] + 1
		val = val
		for i in range(n - 1, -1, -1):
			for j in range(val, val + n - i):
				ans[i].append(j)
			val = ans[i][-1] + 1
		out = []
		for i in range(n):
			val = '' + 2 * i * '-'
			for j in range(len(ans[i]) - 1):
				val += str(ans[i][j]) + '*'
			val += str(ans[i][-1])
			out.append(val)
		return out


class Solution:

	def pattern(self, n):
		res = []
		c = 1
		for i in range(n, 0, -1):
			t = []
			for j in range(i):
				t.append(c)
				c += 1
			res.append(t)
		for i in range(1, n + 1):
			t = res[n - i]
			for j in range(i):
				t.append(c)
				c += 1
			res[n - i] = t
		for i in range(n):
			res[i] = '-' * (i * 2) + '*'.join(map(str, res[i]))
		return res


class Solution:

	def pattern(self, n):
		count = 1
		list = []
		for i in range(n):
			list.append('')
			for j in range(n):
				if i > j:
					list[i] = str(list[i]) + '--'
				else:
					list[i] = str(list[i]) + str(count) + '*'
					count = count + 1
		for i in range(n):
			for j in range(i + 1):
				if j == 0:
					list[n - 1 - i] = str(list[n - 1 - i]) + str(count)
				else:
					list[n - 1 - i] = str(list[n - 1 - i]) + '*' + str(count)
				count = count + 1
		return list


class Solution:

	def pattern(self, n):
		res = ['' for i in range(n)]
		num = 1
		for row in range(0, n):
			numTerms = n - row
			for d in range(2 * row):
				res[row] += '-'
			for i in range(numTerms):
				res[row] += str(num) + '*'
				num += 1
		for row in range(n - 1, -1, -1):
			numTerms = n - row
			for i in range(1, numTerms):
				res[row] += str(num) + '*'
				num += 1
			res[row] += str(num)
			num += 1
		return res


class Solution:

	def pattern(self, n):
		dashCount = 0
		output = []
		i = 1
		for j in range(n):
			string = '-' * dashCount
			temp = []
			for k in range(n - j):
				temp.append(str(i))
				i += 1
			string += '*'.join(temp)
			output.append(string + '*')
			dashCount += 2
		for j in range(n):
			string = output[n - j - 1]
			temp = []
			for k in range(j + 1):
				temp.append(str(i))
				i += 1
			string += '*'.join(temp)
			output[n - j - 1] = string
		return output