A function f is defined as follows F(N)= (1) +(2*3) + (4*5*6) ... N. Given an integer N the task is to print the F(N)th term.
Example 1:
Input: N = 5
Output: 365527
Explaination: F(5) = 1 + 2*3 + 4*5*6 + 7*8*9*10 
+ 11*12*13*14*15 = 365527.
Your Task:
You do not need to readd input or print anything. Your task is to complete the function sequence() which takes N as input parameter and returns the value of F(N).
Expected Tiime Complexity: O(N^{2})
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ N ≤ 10

Difficulty: EASY
Tags: Mathematics

Complete search
Skill types: Complete search
Expected Time Complexity: O(N2)
Expected Auxiliary Space:  O(1)

Starter code:
#User function Template for python3



class Solution:

    def sequence(self, N):

        # code here

Solutions:
class Solution:

	def sequence(self, N):
		self.ans = 0

		def recursion(digits, count):
			if digits > N:
				return
			temp = 1
			for i in range(digits):
				temp *= count
				count += 1
			self.ans += temp
			recursion(digits + 1, count)
		recursion(1, 1)
		return self.ans


class Solution:

	def sequence(self, N):
		K = 1
		res = self.sequenceUtil(N)
		return res[0]

	def sequenceUtil(self, N):
		if N == 0:
			return [0, 1]
		res = self.sequenceUtil(N - 1)
		ans = res[0]
		K = res[1]
		i = 1
		mul = 1
		while i <= N:
			mul = mul * K
			K += 1
			i += 1
		ans += mul
		return [ans, K]


class Solution:

	def sequence(self, N):
		i = 1
		current = 1
		pro = 0
		return self.sol(i, current, pro, N)

	def sol(self, x, current, pro, n):
		current_pro = 1
		for i in range(x):
			current_pro *= current
			current += 1
		pro += current_pro
		if x == n:
			return pro
		return self.sol(x + 1, current, pro, n)


class Solution:

	def sequence(self, N):
		N -= 1

		def rec(N, c, s, m, d, a):
			if not N:
				a.append(s)
				return s
			for i in range(c):
				d += 1
				m *= d
			s += m
			rec(N - 1, c + 1, s, 1, d, a)
		(c, s, m, d, a) = (2, 0, 1, 1, [])
		rec(N, c, s, m, d, a)
		return a[0] + 1


class Solution:

	def __init__(self):
		self.ans = 0
		self.count = 1
		self.pos = 1

	def sequence(self, N):
		if N == 1:
			return 1
		else:
			x = N * (N + 1) // 2
			m = 1
			for i in range(x - N + 1, x + 1):
				m *= i
			return m + self.sequence(N - 1)


class Solution:

	def sequence(self, N):
		cnt = 1
		ans = 0
		i = 1
		while i <= N:
			mul = 1
			val = 0
			while val < i:
				mul *= cnt
				cnt += 1
				val += 1
			ans += mul
			i += 1
		return ans


class Solution:

	def sequence(self, N):
		if N == 1:
			return 1
		else:
			tn = N * (N + 1) // 2
			prod = 1
			for i in range(tn - N + 1, tn + 1):
				prod *= i
			return prod + self.sequence(N - 1)


class Solution:

	def sequence(self, N):
		s = 0
		for i in range(N + 1):
			s += i
		j = N
		ans = 0
		while j > 0:
			m = 1
			for i in range(j):
				m *= s
				s -= 1
			ans += m
			j -= 1
		return ans


class Solution:

	def recur(self, curr_num, no_of_term, N, ans):
		if no_of_term == N + 1:
			return ans
		temp = 1
		count = 0
		while count < no_of_term:
			temp = temp * curr_num
			curr_num += 1
			count += 1
		ans[0] += temp
		self.recur(curr_num, no_of_term + 1, N, ans)

	def sequence(self, N):
		ans = [0]
		self.recur(1, 1, N, ans)
		return ans[0]


class Solution:

	def solve(self, n, dp, li):
		if n == 1:
			dp[n] = 1
			return dp[n]
		if dp[n] != 0:
			return dp[n]
		m = li[n - 1]
		cnt = 1
		for i in m:
			cnt *= i
		dp[n] = cnt + self.solve(n - 1, dp, li)
		return dp[n]

	def sequence(self, N):
		dp = [0 for i in range(11)]
		tem = []
		cn = 1
		li = []
		for i in range(1, 101):
			tem.append(i)
			if len(tem) == cn:
				li.append(tem)
				tem = []
				cn += 1
		return self.solve(N, dp, li)


class Solution:

	def sequence(self, N):
		k = [0]
		s = 0
		for i in range(1, N + 1):
			d = 1
			for j in range(i):
				k.append(k[-1] + 1)
				d *= k[-1]
			s += d
		return s


class Solution:

	def ft(self, a):
		if a == 1:
			return 1
		return a * self.ft(a - 1)

	def sequence(self, N):
		i = 1
		lis = [1]
		j = 1
		while len(lis) < N:
			k = j
			j += i + 1
			lis.append(self.ft(j) // self.ft(k))
			i += 1
		return sum(lis)


class Solution:

	def sequence(self, N):
		return self.rev(N, 1, 1)

	def rev(self, N, i, count):
		if count == N + 1:
			return 0
		res = count
		ans = 1
		while True:
			ans *= i
			count -= 1
			i += 1
			if count <= 0:
				break
		return ans + self.rev(N, i, res + 1)


class Solution:

	def sequence(self, n):

		def f(a, b):
			if b == 0:
				return 1
			return a * f(a + 1, b - 1)
		ans = 0
		s = 1
		for i in range(1, n + 1):
			ans += f(s, i)
			s += i
		return ans


class Solution:

	def sequence(self, N):
		s = 0
		idx = 1
		for i in range(1, N + 1):
			p = 1
			for j in range(i):
				p *= idx + j
			s += p
			idx += i
		return s


class Solution:

	def sequence(self, N):

		def fib(n, i, prod, sum):
			if i == n + 1:
				return sum
			p = 1 + int(i * (i - 1) / 2)
			for a in range(i):
				prod = prod * p
				p += 1
			sum += prod
			return fib(n, i + 1, 1, sum)
		return fib(N, 1, 1, 0)


class Solution:

	def sequence(self, N):
		s = 0
		k = N * (N + 1) // 2
		for i in range(N + 1, 0, -1):
			p = 1
			for j in range(i - 1):
				p = p * k
				k = k - 1
			s = s + p
		return s - 1


class Solution:

	def sequence(self, N):
		k = 1
		sum = 0
		for i in range(1, N + 1):
			prod = 1
			for j in range(1, i + 1):
				prod *= k
				k += 1
			sum += prod
		return sum


class Solution:

	def sequence(self, N):
		sum = 0
		var = 0
		i = 1
		while i <= N:
			mul = 1
			j = 1
			while j <= i:
				var += 1
				mul = mul * var
				j += 1
			sum += mul
			i += 1
		return sum


class Solution:

	def sequence(self, N):

		def fun(sumi, k, num, pro):
			if k == n + 1:
				return sumi
			for i in range(k):
				pro = pro * num
				num = num + 1
			sumi = sumi + pro
			return fun(sumi, k + 1, num, 1)
		n = N
		return fun(0, 1, 1, 1)


class Solution:

	def sequence(self, N):

		def helper(n, cs, nv):
			if n > N:
				return cs
			value = 1
			for i in range(n):
				value *= nv
				nv += 1
			cs += value
			return helper(n + 1, cs, nv)
		return helper(1, 0, 1)


class Solution:

	def sequence(self, N):
		d = {1: 1, 2: 2, 3: 4, 4: 7, 5: 11, 6: 16, 7: 22, 8: 29, 9: 37, 10: 46}

		def helper(N, cs):
			if N == 1:
				return cs + 1
			start = d[N]
			value = 1
			for i in range(N):
				value *= start + i
			cs += value
			return helper(N - 1, cs)
		ans = helper(N, 0)
		return ans


class Solution:

	def sequence(self, N):
		ans = 1
		res = 0
		temp = 1
		for i in range(1, N + 1):
			j = 0
			ans = 1
			while i > j:
				ans = ans * temp
				temp = temp + 1
				j = j + 1
			res = res + ans
		return res


arr = [1]

class Solution:

	def sequence(self, N):
		while len(arr) < N:
			n = len(arr)
			next_num = n * (n + 1) // 2 + 1
			product = next_num
			for i in range(n):
				next_num += 1
				product *= next_num
			arr.append(product)
		return sum(arr[:N])


class Solution:

	def sequence(self, N):
		sum = 0
		if N == 1:
			sum += 1
			return sum
		p = N * (N + 1) // 2
		return self.sequence(N - 1) + self.fact(p) // self.fact(p - N)

	def fact(self, N):
		if N == 1:
			return 1
		if N == 0:
			return 1
		return self.fact(N - 1) * N


class Solution:

	def sequence(self, N):
		summ = 0
		counter = 1
		for x in range(N):
			mul_counter = x + 1
			in_sum = 1
			while mul_counter != 0:
				in_sum = in_sum * counter
				counter += 1
				mul_counter -= 1
			summ = summ + in_sum
		return summ


class Solution:

	def sequence(self, n):
		b = vk = 1
		for i in range(1, n + 1):
			a = i * (i + 1) // 2
			s = 1
			for j in range(b, a + 1):
				s *= j
			b = a + 1
			vk += s
		return vk - 1


class Solution:

	def sequence(self, n):

		def siva(st, diff, s, ans):
			if diff == n + 1:
				return ans
			for i in range(st, st + diff):
				s *= i
			ans += s
			return siva(st + diff, diff + 1, 1, ans)
		return siva(1, 1, 1, 0)


class Solution:

	def sequence(self, N):
		if N == 0:
			return 0
		sumi = 0
		x = 1
		for i in range(1, N + 1):
			mul = 1
			j = i
			while j > 0:
				mul *= x
				x += 1
				j -= 1
			sumi += mul
		return sumi


class Solution:

	def sequence(self, N):
		(s, b) = (1, 0)
		for i in range(1, N + 1):
			a = 1
			for j in range(1, i + 1):
				a = a * s
				s = s + 1
			b = b + a
		return b


class Solution:

	def sequence(self, N):
		(res, s) = (0, 1)
		for i in range(1, N + 1):
			t = 1
			for j in range(1, i + 1):
				t = t * s
				s += 1
			res += t
		return res


class Solution:

	def seriessum(self, calculated, current, N):
		i = calculated
		curr = 1
		if current == N + 1:
			return 0
		while i < calculated + current:
			curr *= i
			i += 1
		return curr + self.seriessum(i, current + 1, N)

	def sequence(self, N):
		current = 1
		calculated = 1
		d = Solution.seriessum(self, calculated, current, N)
		return d


class Solution:

	def sequence(self, N):

		def seq(N, t):
			if N == 1:
				return t
			return t * seq(N - 1, t + 1)
		if N == 1:
			return 1
		t = N * (N - 1) // 2 + 1
		p = seq(N, t)
		return p + self.sequence(N - 1)


class Solution:

	def sequence(self, N):
		if N == 0:
			return 0
		t1 = self.sequence(N - 1)
		j = N
		s = N * (N - 1) // 2 + 1
		t2 = s + 1
		while j > 1:
			s *= t2
			t2 += 1
			j -= 1
		return s + t1


class Solution:

	def sequence(self, N):
		sm = 0
		k = 1
		for i in range(1, N + 1):
			j = i
			pd = 1
			while j:
				pd = pd * k
				k += 1
				j -= 1
			sm += pd
		return sm


class Solution:

	def sequence(self, N):
		x = 1
		diff = 1
		s = 0
		for i in range(N):
			s_1 = 1
			for j in range(x, x + diff):
				s_1 *= j
			s += s_1
			x += diff
			diff += 1
		return s


class Solution:

	def sequence(self, N):

		def seq(i, t, n):
			if i == t:
				k.append(n)
				return n
			return n * seq(i + 1, t, n + 1)
		ans = 1
		k = [1]
		for i in range(2, N + 1):
			ans += seq(1, i, k[-1] + 1)
		return ans


def seriesSum(calculated, current, N):
	i = calculated
	cur = 1
	if current == N + 1:
		return 0
	while i < calculated + current:
		cur *= i
		i += 1
	return cur + seriesSum(i, current + 1, N)

class Solution:

	def sequence(self, N):
		return seriesSum(1, 1, N)


class Solution:

	def sequence(self, N):

		def fun(n):
			x = n * (n + 1) // 2
			p = x
			for i in range(x - 1, x - n, -1):
				p = p * i
			return p
		if N == 1:
			return 1
		return self.sequence(N - 1) + fun(N)


class Solution:

	def sequence(self, N):
		ans = 0
		p = 1
		v = 1
		for i in range(1, N + 1):
			for j in range(1, i + 1):
				p = p * v
				v += 1
			ans += p
			p = 1
		return ans


class Solution:

	def rec(self, n, k, res, z):
		prd = 1
		if n == 1:
			res.append(1)
			z.append(1)
			return
		else:
			self.rec(n - 1, k - 1, res, z)
			for i in range(res[-1] + 1, res[-1] + k + 1):
				res.append(i)
				prd *= i
			z.append(prd)

	def sequence(self, N):
		res = []
		k = N
		z = []
		self.rec(N, k, res, z)
		return sum(z)


class Solution:

	def sequence(self, N):
		ans = 0
		k = 1
		for i in range(N):
			temp = 1
			for j in range(i + 1):
				temp *= k
				k += 1
			ans += temp
		return ans


class Solution:

	def sequence(self, N):
		result = 0
		number = 1
		for i in range(1, N + 1):
			term = 1
			for j in range(i):
				term *= number
				number += 1
			result += term
		return result


class Solution:

	def sequence(self, N):
		row = 1
		col = 1
		ans = 0
		pre = 1
		for row in range(1, N + 1):
			prd = 1
			for col in range(1, row + 1):
				prd *= pre
				pre += 1
			ans += prd
		return ans


class Solution:

	def seriesSum(self, start, curr_itr, N):
		i = start
		prod = 1
		if curr_itr == N + 1:
			return 0
		while i < start + curr_itr:
			prod *= i
			i += 1
		return prod + self.seriesSum(i, curr_itr + 1, N)

	def sequence(self, N):
		return self.seriesSum(1, 1, N)


import math

class Solution:

	def sequence(self, n):
		if n == 1:
			return 1
		else:
			k = n * (n - 1) // 2
			return self.sequence(n - 1) + math.factorial(k + n) // math.factorial(k)


class Solution:

	def sequence(self, N):
		return self.solve(N, 1, 1)

	def solve(self, n, c, x):
		if n <= 0:
			return 0
		p = 1
		for i in range(c, c + x):
			p = p * i
		return p + self.solve(n - 1, c + x, x + 1)


class Solution:

	def sequence(self, N):

		def solve(n, cnt):
			if n == N + 1:
				return 0
			temp = 1
			for i in range(cnt, n + cnt):
				temp *= i
			return temp + solve(n + 1, n + cnt)
		ans = 1
		cnt = 1
		return solve(1, cnt)


class Solution:

	def sequence(self, N):
		if N == 1:
			return 1
		p = self.sequence(N - 1)
		ans = N * (N + 1) // 2
		cons = N
		pro = 1
		while cons > 0:
			pro = pro * ans
			ans -= 1
			cons -= 1
		p = p + pro
		return p


class Solution:

	def sequence(self, N):
		n = N
		if n == 1:
			return 1
		last = n * (n + 1) // 2
		term = 1
		for i in range(last - n + 1, last + 1):
			term *= i
		return self.sequence(n - 1) + term


import math

class Solution:

	def sequence(self, N):
		if N == 1:
			return 1
		start = N * (N - 1) // 2 + 1
		end = N * (N + 1) // 2
		mul = 1
		for num in range(start, end + 1):
			mul *= num
		return mul + self.sequence(N - 1)


class Solution:

	def sequence(self, N):
		ans = 0
		t = 1
		t1 = 1
		for i in range(1, N + 1):
			for j in range(1, i + 1):
				t = t * t1
				t1 += 1
			ans += t
			t = 1
		return ans
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.sequence(N))


class Solution:

	def sequence(self, n):
		x = 1
		total = 0
		for i in range(n):
			curr = 1
			for j in range(i + 1):
				curr *= x
				x += 1
			total += curr
		return total
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.sequence(N))


class Solution:

	def sequence(self, N):
		if N == 1:
			return 1
		else:
			t = 1
			for i in range(1, N + 1):
				t *= (N - 1) * N // 2 + i
		return t + self.sequence(N - 1)
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.sequence(N))


class Solution:

	def sequence(self, N):
		return self.funct(N)

	def funct(self, N):
		temp = N
		sum = 1
		n = N * (N + 1) // 2
		if N == 1:
			return 1
		while temp:
			sum = sum * n
			n -= 1
			temp -= 1
		res = sum
		return res + self.funct(N - 1)
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.sequence(N))


class Solution:

	def sequence(self, N):
		if N == 1:
			return 1
		else:
			p = int(N * (N + 1) / 2)
			k = 0
			c = 1
			while k < N:
				c *= p
				p -= 1
				k += 1
			return c + self.sequence(N - 1)
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.sequence(N))


class Solution:

	def sequence(self, N):

		def dfs(count, s=1):
			if count == N + 1:
				self.Sum += s
				return
			for _ in range(count):
				s = s * self.i
				self.i += 1
			self.Sum += s
			dfs(count + 1)
		self.Sum = 0
		self.i = 1
		dfs(1)
		return self.Sum - 1


class Solution:

	def solve(self, n, start, count):
		if n <= 0:
			return 0
		p = 1
		for i in range(start, start + count):
			p = p * i
		return p + self.solve(n - 1, start + count, count + 1)

	def sequence(self, N):
		return self.solve(N, 1, 1)


class Solution:

	def sequence(self, n):
		temp = 0
		sums = 0
		for i in range(n):
			mul = 1
			for j in range(i + 1):
				temp += 1
				mul *= temp
			sums += mul
		return sums


class Solution:

	def sequence(self, N):
		if N == 1:
			return 1
		(ans, term) = self.solver(N)
		return ans

	def solver(self, n):
		if n == 1:
			return [1, 1]
		(ans, term) = self.solver(n - 1)
		first = term + n - 1
		res = 1
		for i in range(first, first + n):
			res *= i
		res = res + ans
		return (res, first)


class Solution:

	def sequence(self, n):
		if n == 1:
			return 1
		curr = 1
		x = sum(range(0, n)) + 1
		for i in range(n):
			curr *= x
			x += 1
		return curr + self.sequence(n - 1)


def helper(n, N, ans, c):
	sol = 1
	if c == N + 1:
		return ans
	for i in range(n, n + c):
		sol = sol * i
	ans += sol
	n = i + 1
	return helper(n, N, ans, c + 1)

class Solution:

	def sequence(self, N):
		return helper(1, N, 0, 1)


class Solution:

	def mul(self, mat):
		res = 1
		for x in mat:
			res *= x
		return res

	def sequence(self, N):
		if N == 1:
			return 1
		val = self.sequence(N - 1)
		to = N * (N + 1) // 2
		return val + self.mul([to - i for i in range(N)])


class Solution:

	def sequence(self, N):

		def rec(N, calculated, current, s):
			i = calculated
			if current == N + 1:
				return s
			curr = 1
			while i < calculated + current:
				curr = curr * i
				i = i + 1
			s = s + curr
			return rec(N, i, current + 1, s)
		res = rec(N, 1, 1, 0)
		return res


class Solution:

	def sequence(self, N):
		s = 0
		count = 1
		for i in range(1, N + 1):
			x = 1
			for j in range(1, i + 1):
				x = x * count
				count += 1
			s += x
		return s


class Solution:

	def sequence(self, N):
		if N == 1:
			return 1
		sum = self.sequence(N - 1)
		temp = N
		k = 1
		Initial = 1
		while temp > 1:
			Initial += k
			k += 1
			temp -= 1
		product = 1
		temp = N
		while temp > 0:
			product *= Initial
			temp -= 1
			Initial += 1
		return sum + product


class Solution:

	def sequence(self, N):
		if N == 1:
			return 1
		c = N * (N - 1) // 2 + 1
		prod = 1
		for i in range(1, N + 1):
			prod *= c
			c += 1
		return prod + self.sequence(N - 1)


class Solution:

	def sequence(self, N):
		res = 0
		mul = 1
		v = 0
		for i in range(1, N + 1):
			p = v + 1
			v += i
			for j in range(p, v + 1):
				mul *= j
			res += mul
			mul = 1
		return res


class Solution:

	def __init__(self):
		self.finalOutput = 0

	def helper(self, N):
		if N == 1:
			self.finalOutput += 1
			return
		startingPoint = N * (N - 1) // 2 + 1
		endingPoint = startingPoint + N
		currOutput = startingPoint
		for i in range(startingPoint + 1, endingPoint):
			currOutput *= i
		self.finalOutput += currOutput
		self.helper(N - 1)

	def sequence(self, N):
		self.helper(N)
		return self.finalOutput


class Solution:

	def sequence(self, N):
		res = []

		def helper(N):
			if N == 1:
				return 1
			n = int(N * (N + 1) / 2)
			prod = 1
			for i in range(N):
				prod = prod * n
				n = n - 1
			return prod + helper(N - 1)
		return helper(N)


class Solution:

	def sequence(self, N):
		prev = 2
		res = 1
		num = 2
		while num <= N:
			res1 = 1
			for i in range(prev, prev + num):
				res1 *= i
			res += res1
			prev = prev + num
			num += 1
		return res


import functools

class Solution:

	def sequence(self, N):
		solution = 0
		start = 1
		for n in range(N):
			end = start + n
			solution += functools.reduce(lambda x, y: x * y, range(start, end + 1))
			start = end + 1
		return solution


class Solution:

	def sequence(self, N):
		count = 1
		no = 1
		sum = 0
		temp = 1
		while count <= N:
			for i in range(count):
				temp = temp * no
				no = no + 1
			sum = sum + temp
			temp = 1
			count = count + 1
		return sum


class Solution:

	def sequence(self, N):
		total = 0
		num = 1
		for i in range(1, N + 1):
			sum = 1
			k = i
			for j in range(1, k + 1):
				sum *= num
				num += 1
			total += sum
		return total


class Solution:

	def sequence(self, N):
		res = 0
		x = 1
		if N == 0:
			return 0
		else:
			for i in range(1, N + 1):
				prod = 1
				j = i
				while j > 0:
					prod *= x
					x += 1
					j -= 1
				res += prod
			return res


class Solution:

	def sequence(self, N):
		m = 0
		a = []

		def solve(n, i, j, m, a):
			d = 1
			for k in range(j, j + i):
				d *= k
			if n == i:
				m += d
				a.append(m)
				return m
			solve(n, i + 1, j + i, m + d, a)
		solve(N, 1, 1, m, a)
		return a[-1]


class Solution:

	def sequence(self, N):

		def f1(n):
			if n == 1:
				return 1
			else:
				return f1(n - 1) + n - 1

		def f2(n, x, s):
			if n == x:
				return s
			else:
				return f2(n, x + 1, s + 1) * s
		if N == 1:
			return 1
		else:
			s = f1(N)
			x = 1
			return self.sequence(N - 1) + f2(N, x, s)


class Solution:

	def sequence(self, N):
		if N == 1:
			return 1
		else:
			mul = 1 + N * (N - 1) / 2
			sum = 1
			for i in range(N):
				sum = sum * mul
				mul += 1
			return int(sum) + self.sequence(N - 1)


class Solution:

	def sequence(self, N):
		i = 1
		s = 0
		for n in range(1, N + 1):
			cur = 1
			for _ in range(n):
				cur *= i
				i += 1
			s += cur
		return s


class Solution:

	def sequence(self, N):
		n = N
		sum1 = 0
		j = 1
		for i in range(1, n + 1):
			t = 1
			for k in range(1, i + 1):
				t = t * j
				j = j + 1
			sum1 = sum1 + t
		return sum1


class Solution:

	def sequence(self, N):
		l = []
		z = 1
		for i in range(1, N + 1):
			s = 1
			for j in range(i):
				s = s * z
				z = z + 1
			l.append(s)
		return sum(l)