On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.

For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.

Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.

For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.

Write a program that, for a given $n$, finds a sequence of all possible rating increments.


-----Input-----

The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.

Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.


-----Output-----

Output the answers for each of $t$ test cases. Each answer should be contained in two lines.

In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.

In the following line print $m$ integers in ascending order — the values of possible rating increments.


-----Example-----
Input
4
5
11
1
3

Output
4
0 1 2 5 
6
0 1 2 3 5 11 
2
0 1 
3
0 1 3

Source: codeforces | Difficulty: MEDIUM
Tags: Number theory

Sorting

Mathematics

Complete search


Solutions:
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

def solve():
	n = int(input())
	ans = set()
	ans.add(0)
	ans.add(1)
	ans.add(n)
	i = 2
	while i * i <= n:
		if n / i == n // i:
			ans.add(int(i))
			ans.add(int(n // i))
		else:
			ans.add(int(i))
			ans.add(n // i)
		i += 1
	l = sorted(list(ans))
	print(len(ans))
	print(' '.join(map(str, l)))
T = int(input())
for _ in range(T):
	solve()


for _ in range(int(input())):
	n = int(input())
	a = [0, 1, n]
	d = 2
	while d * d <= n:
		a += (d,)
		a += (n // d,)
		d += 1
	a = sorted(set(a))
	print(len(a))
	print(' '.join(map(str, a)))


for _ in range(int(input())):
	N = int(input())
	S = set()
	S.add(0)
	S.add(N)
	for i in range(1, int(N ** 0.5) + 1):
		S.add(i)
		S.add(int(N // i))
	print(len(S))
	L = sorted(S)
	for i in L:
		print(i, end=' ')
	print()


t = int(input())
while t:
	s = set()
	l = []
	n = int(input())
	for i in range(1, 10 ** 5):
		s.add(n // i)
	s = list(s)
	s.sort()
	for i in range(s[0]):
		l.append(i)
	print(len(s) + len(l))
	print(*l + s)
	t -= 1


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')
import math
testcases = int(input())
for j in range(testcases):
	n = int(input())
	possible = [0, 1]
	setty = set([0, 1])
	if math.ceil(math.sqrt(n)) ** 2 == n:
		for s in range(2, math.ceil(math.sqrt(n)) + 1):
			if not s in setty:
				possible.append(s)
			setty.add(s)
		for s in range(len(possible)):
			if s > 0:
				if not n // possible[s] in setty:
					possible.append(n // possible[s])
				setty.add(n // possible[s])
	else:
		for s in range(2, math.ceil(math.sqrt(n))):
			if not s in setty:
				possible.append(s)
			setty.add(s)
		for s in range(len(possible)):
			if s > 0:
				if not n // possible[s] in setty:
					possible.append(n // possible[s])
				setty.add(n // possible[s])
	possible.sort()
	possible = [str(k) for k in possible]
	print(len(possible))
	print(' '.join(possible))


import math
import os
import sys
input = lambda : sys.stdin.readline().strip('\r\n')

def cin():
	return sys.stdin.readline().strip('\r\n')

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

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

def cout(ans):
	sys.stdout.write(str(ans))

def endl():
	sys.stdout.write(str('\n'))

def ende():
	sys.stdout.write(str(' '))

def main():
	for _ in range(int(input())):
		n = int(cin())
		l = [0]
		st = set({})
		i = 2
		prev = 1
		if n > 1:
			while 1:
				if n // i == 1:
					l.append(prev)
					break
				elif math.trunc(n // i) in st:
					prev = i
				else:
					l.append(prev)
					if n % i:
						prev = n // (n // i)
						i = prev
					else:
						prev = i
					st.add(math.trunc(n // i))
				i += 1
		l.append(n)
		cout(len(l))
		endl()
		for i in l:
			cout(i)
			ende()
		endl()
main()


t = int(input())
for _ in range(t):
	vis = set()
	s = set()
	n = int(input())
	for i in range(1, int(n ** 0.5) + 2):
		if n // i not in vis:
			vis.add(n // i)
			s.add(n // i)
	res = sorted(s)
	res = list(range(res[0] - 1, -1, -1))[::-1] + res
	print(len(res))
	print(*res)


import math
R = lambda : int(input())
t = R()
for _ in range(t):
	n = R()
	a = {0, 1}
	for i in range(1, int(math.sqrt(n)) + 1):
		a.add(int(n / i))
		a.add(i)
	print(len(a))
	for x in sorted(a):
		print(x, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	s = set()
	s.add(0)
	i = 1
	while i * i <= n:
		s.add(i)
		s.add(n // i)
		i += 1
	print(len(s))
	print(*sorted(list(s)))


from math import sqrt
for _ in range(int(input())):
	n = int(input())
	ans = set([])
	for i in range(1, int(sqrt(n)) + 1):
		ans.add(i)
		ans.add(n // i)
	ans.add(0)
	ans = list(ans)
	ans.sort()
	print(len(ans))
	for i in ans:
		print(i, end=' ')
	print()


t = int(input())
for i in range(t):
	ans = 0
	n = int(input())
	s = set([0])
	ans = [0]
	i = n
	while i > 0:
		tmp = n // i
		if tmp not in s:
			s.add(tmp)
			ans.append(tmp)
		i = min(n // (tmp + 1), i - 1)
	print(len(ans))
	print(*ans)


for nt in range(int(input())):
	n = int(input())
	a = [0]
	for i in range(1, int(n ** 0.5) + 1):
		a.append(n // i)
		a.append(i)
	a = sorted(list(set(a)))
	print(len(a))
	print(*a)


t = int(input())
for ij in range(0, t):
	n = int(input())
	ans = [0]
	ans1 = []
	for i in range(1, int(pow(n, 0.5)) + 1):
		ans.append(i)
	for i in range(1, int(pow(n, 0.5)) + 1):
		ans1.append(n // i)
	if ans[-1] == ans1[-1]:
		ans.pop(-1)
	for i in range(len(ans1) - 1, -1, -1):
		ans.append(ans1[i])
	print(len(ans))
	for i in ans:
		print(i, end=' ')
	print()


import sys
input = sys.stdin.readline
import math
Q = int(input())
Query = [int(input()) for _ in range(Q)]
for N in Query:
	ans = set()
	T = int(math.sqrt(N)) + 2
	for n in range(T):
		if n ** 2 <= N:
			ans.add(n)
	for n in range(1, T):
		ans.add(N // n)
	A = sorted(list(ans))
	print(len(A))
	print(*A)


for t in range(int(input())):
	n = int(input())
	seq = []
	i = n + 1
	while i > 0:
		a = n // i
		i = n // (a + 1)
		seq.append(a)
	print(len(seq))
	print(*seq)


import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations

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

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

def nu():
	return int(input())

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	gg = find_gcd(x, y)
	return x * y // gg
mm = 1000000007

def solve():
	t = nu()
	for tt in range(t):
		n = nu()
		ss = set()
		for i in range(1, min(n + 1, int(ma.sqrt(n)) + 101)):
			ss.add(n // i)
			op = n // i
			ox = n // op
			ss.add(ox)
		ss.add(0)
		print(len(ss))
		op = list(ss)
		op.sort()
		print(*op)
solve()


n = int(input())
for i in range(n):
	k = int(input())
	srt = int(k ** 0.5)
	base = [p for p in range(srt + 1)]
	res = [k // j for j in range(srt, 0, -1)]
	if srt == res[0]:
		res = base + res[1:]
	else:
		res = base + res
	print(len(res))
	print(' '.join(map(str, res)))


import math as m
t = int(input())
while t:
	t -= 1
	a = []
	n = int(input())
	for i in range(1, m.ceil(n ** 0.5) + 1):
		a.append(n // i)
		a.append(n // (n // i))
	a.append(1)
	a.append(0)
	a = set(a)
	a = list(a)
	a.sort()
	print(len(a))
	print(*a)


t = int(input())
while t != 0:
	n = int(input())
	list1 = [0]
	i = 1
	while i <= n:
		p = n // i
		if n // p == i:
			list1.append(i)
			i += 1
		else:
			list1.append(n // p)
			i = n // p + 1
	print(len(list1))
	print(*list1)
	t -= 1


def bin_s(z, a):
	lo = 1
	hi = z
	k = a // z
	ans = 1
	while lo <= hi:
		mid = (lo + hi) // 2
		if a // mid == k:
			ans = mid
			hi = mid - 1
		else:
			lo = mid + 1
	return ans
for _ in ' ' * int(input()):
	a = int(input())
	z = a + 1
	f = []
	while z > 0:
		k = bin_s(z, a)
		f.append(a // z)
		z = k - 1
	print(len(f))
	print(*f)


def solution():
	n = int(input())
	x = int(n ** 0.5)
	l = [0]
	i = 1
	while i <= x:
		a = n // i
		l.append(i)
		l.append(a)
		i += 1
	l = list(set(l))
	l.sort()
	print(len(l))
	print(*l)
for _ in range(int(input())):
	solution()


import sys
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	ans = [0]
	div = n
	while div >= 1:
		val = n // div
		if ans[-1] != val:
			ans.append(val)
		div = n // (val + 1)
	print(len(ans))
	print(*ans)


from math import sqrt
t = int(input())
for kek in range(t):
	n = int(input())
	ans = list()
	j = 0
	while j < sqrt(n):
		ans.append(j)
		j += 1
	j = int(sqrt(n))
	while j > 0:
		k = n // j
		if ans[-1] != k:
			ans.append(k)
		j -= 1
	print(len(ans))
	print(*ans)


import math
n = int(input())
for i in range(0, n):
	L = [0, 1]
	o = int(input())
	L.append(o)
	A = math.floor(math.sqrt(o))
	for j in range(2, A + 1):
		L.append(j)
		L.append(o // j)
	L = list(set(L))
	L.sort(key=int)
	print(len(L))
	print(*L)


t = int(input())
for _ in range(t):
	n = int(input())
	L = [i for i in range(int(n ** (1 / 2) + 1))] + [int(n / i) for i in range(1, int(n ** (1 / 2) + 1))]
	L = list(map(str, sorted(list(set(L)))))
	print(len(L))
	print(' '.join(L))


import math
t = int(input())
for i in range(t):
	n = int(input())
	val = math.floor(math.sqrt(n))
	fin_list = list()
	sec_list = list()
	for i in range(val, 0, -1):
		curr_val = n // i
		fin_list.append(curr_val)
		if curr_val != i:
			sec_list.append(i)
	sec_list.append(0)
	sec_list.reverse()
	f = sec_list + fin_list
	print(len(f))
	print(*f)


from math import ceil
for n in range(int(input())):
	x = int(input())
	st = set()
	n = 1
	while n <= x:
		st.add(x // n)
		n = x // (x // n)
		n += 1
	st.add(0)
	print(len(list(st)))
	print(*sorted(list(st)))


from sys import stdin, stdout
import math
I = stdin.readline
print = stdout.write
for _ in range(int(I())):
	n = int(I())
	r = n
	l1 = [0]
	while r > 0:
		l = 1
		t = math.floor(n / r)
		l1.append(t)
		r = math.floor(n / (t + 1))
	print(str(len(l1)) + '\n')
	for i in l1:
		print(str(i) + ' ')
	print('\n')


t = int(input())
for i in range(t):
	n = int(input())
	ans = set()
	(a, b) = (1, n)
	while a <= b:
		ans.add(a)
		ans.add(b)
		a += 1
		b = n // a
	ans.add(0)
	print(len(ans))
	print(*sorted(ans))


t = int(input())
for _ in range(t):
	n = int(input())
	b = [0]
	for i in range(1, int(n ** 0.5) + 1):
		b.append(i)
		b.append(n // i)
		if i == n // i:
			del b[len(b) - 1]
	print(len(b))
	print(*sorted(b))


q = int(input())
for _ in range(q):
	n = int(input())
	a = [0]
	b = []
	if n == 1:
		print(2)
		print(0, 1)
	else:
		t = 1
		for i in range(1, int(n ** 0.5) + 1):
			if i * i <= n:
				a.append(i)
				l = i
				b.append(n // i)
		b = b[::-1]
		if b[0] == l:
			print(len(a) + len(b) - 1)
		else:
			print(len(a) + len(b))
		for t in a:
			print(t, end=' ')
		if l != b[0]:
			print(b[0], end=' ')
		for t in b[1:]:
			print(t, end=' ')
		print()


for _ in range(int(input())):
	n = int(input())
	lis = []
	i = n + 1
	while i > 0:
		a = n // i
		lis.append(a)
		i = n // (a + 1)
	print(len(lis))
	print(*lis)


import os, sys, math

def solve(n):
	solved = [n]
	for k in range(2, int(n ** 0.5 + 2), 1):
		v = int(math.floor(n / k))
		if v != solved[-1]:
			solved.append(v)
	v = solved[-1]
	solved.extend(range(v - 1, -1, -1))
	return reversed(solved)
num = int(input().strip())
for x in range(num):
	n = int(input().strip())
	res = list(solve(n))
	print(len(res))
	print(' '.join(map(str, res)))


from math import sqrt
from itertools import groupby
t = int(input())
for i in range(t):
	n = int(input())
	if n != 3 and n != 2:
		s = []
		n1 = int(sqrt(n))
		for i in range(1, n1 + 1):
			a = n // i
			s.append(a)
		s_new = [el for (el, _) in groupby(s)]
		if n1 not in s_new:
			s_new.append(n1)
		L = len(s_new)
		print(L + n1)
		for i in range(0, n1):
			print(i, end=' ')
		for i in range(L - 1, -1, -1):
			print(s_new[i], end=' ')
		print()
	elif n == 3:
		print(3)
		print(0, 1, 3)
	else:
		print(3)
		print(0, 1, 2)


from sys import stdin, stdout
casos = int(stdin.readline().strip())
for case in range(casos):
	n = int(stdin.readline().strip())
	x = int(pow(n, 0.5))
	ans = [i for i in range(x + 1)]
	for i in range(x, 0, -1):
		y = n // i
		if y != ans[-1]:
			ans.append(y)
	stdout.write('%d\n' % len(ans))
	print(*ans)


n = int(input())
for _ in range(n):
	x = int(input())
	t = int(x ** 0.5)
	ans = set([0])
	for i in range(1, t + 1):
		ans.add(i)
		ans.add(x // i)
	print(len(ans))
	print(*sorted(ans))


for _ in range(int(input())):
	(n, s) = (int(input()), {0})
	for d in range(1, n + 1):
		if n // d in s:
			break
		s.update((d, n // d))
	print(len(s))
	print(' '.join((str(i) for i in sorted(s))))


import os
import sys
from io import BytesIO, IOBase
from math import sqrt

def solution(n):
	res = set()
	res.add(0)
	for i in range(1, int(sqrt(n)) + 1):
		res.add(i)
		res.add(n // i)
	write(len(res))
	write(*sorted((x for x in res)))

def main():
	for _ in range(r_int()):
		n = r_int()
		solution(n)
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')

def write(*args, end='\n'):
	for x in args[:-1]:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(str(args[-1]))
	sys.stdout.write(end)

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

def r_int():
	return int(input())
main()


T = int(input())
for t in range(T):
	N = int(input())
	V = {0}
	A = [0]
	for i in range(1, int(N ** 0.5) + 1):
		if i not in V:
			A.append(i)
			V.add(i)
		if N // i not in V:
			A.append(N // i)
			V.add(N // i)
	print(len(A))
	print(*sorted(A))


ans = ''
for _ in range(int(input())):
	n = int(input())
	s = {0}
	for i in range(1, int(n ** 0.5) + 1):
		s.add(i)
		s.add(n // i)
	print(len(s))
	print(*sorted(s))


t = int(input())
for _ in range(t):
	n = int(input())
	k = 1
	ans = {0}
	while k <= n:
		ys = n // k
		t = n // ys
		ans.add(t)
		k = t + 1
	print(len(ans))
	print(*ans)


from math import *
t = int(input())
for i in range(t):
	w = int(input())
	l = set()
	l.add(0)
	r = w
	for i in range(1, int(pow(w, 0.5)) + 1):
		yu = floor(w // i)
		l.add(i)
		l.add(yu)
	l = list(l)
	l.sort()
	print(len(l))
	print(*l)


for _ in range(int(input())):
	n = int(input())
	rts = [0]
	for i in range(1, int(n ** 0.5) + 1):
		rts.append(n // i)
		rts.append(i)
	rts = set(rts)
	print(len(rts))
	print(' '.join([str(x) for x in sorted(rts)]))


for i in range(int(input())):
	n = int(input())
	m = int(n ** 0.5)
	print(2 * m + (m != n // m))
	l = [i for i in range(m)]
	s = ' ' + str(m) + ' ' + ('' if m == n // m else str(n // m) + ' ')
	li = [str(n // i) for i in l[:0:-1]]
	print(' '.join([str(i) for i in l]) + s + ' '.join(li))


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		N = int(input())
		ans = []
		ans.append(0)
		p = 0
		pn = 0
		for i in range(1, int(N ** 0.5) + 1):
			x = N // i
			if x != p and x != pn:
				ans.append(x)
				p = x
			if i != pn and i != p:
				ans.append(i)
				pn = i
		print(len(ans))
		ans.sort()
		print(*ans)
main()


import math
for x in range(int(input())):
	n = int(input())
	a = set()
	a.add(0)
	for i in range(1, int(math.sqrt(n)) + 1):
		a.add(i)
		a.add(n // i)
	a = sorted(a)
	print(len(a))
	print(*a)


for i in range(int(input())):
	n = int(input())
	l = [0]
	l2 = []
	x = int(n ** 0.5)
	for i in range(1, x + 1):
		l.append(i)
		l.append(n // i)
	l.sort()
	print(len(set(l)))
	s1 = set([])
	for i in l:
		if i not in s1:
			l2.append(i)
			s1.add(i)
		else:
			s1.add(i)
	print(*l2)


t = int(input())
for _ in range(t):
	n = int(input())
	s = set([])
	for i in range(1, int(n ** 0.5) + 1):
		if n // i != 0:
			s.add(int(n / i))
			s.add(i)
	s.add(0)
	l = list(s)
	l.sort()
	print(len(l))
	print(*l)


t = int(input())
for __ in range(t):
	n = int(input())
	ms = {n}
	prev_m = n
	rem = 0
	k = 2
	while prev_m != 0:
		if rem < prev_m:
			prev_m = n // k
			rem = n - prev_m * k
			ms.add(prev_m)
			k += 1
		else:
			k += rem // prev_m
			rem %= prev_m
	ms = list(ms)
	ms.sort()
	print(len(ms))
	print(' '.join(map(str, ms)))


import sys, math, itertools
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
mod = 10 ** 9 + 7
INF = float('inf')

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

def inpl():
	return list(map(int, sys.stdin.readline().split()))
for _ in range(inp()):
	n = inp()
	s = set()
	s.add(0)
	for i in range(1, int(math.sqrt(n)) + 2):
		s.add(n // i)
	for i in range(1, int(math.sqrt(n)) + 1):
		s.add(i)
	res = list(s)
	res.sort()
	print(len(res))
	print(*res)


3
import os
import sys

def main():
	T = read_int()
	for _ in range(T):
		ans = solve(read_int())
		print(len(ans))
		print(*ans)

def solve(N):
	ans = [N]
	i = 2
	while i * (i - 1) <= N:
		v = N // i
		if ans[-1] != v:
			ans.append(v)
		i += 1
	v = ans[-1]
	for i in range(v - 1, -1, -1):
		ans.append(i)
	ans.reverse()
	return ans
DEBUG = 'DEBUG' in os.environ

def inp():
	return sys.stdin.readline().rstrip()

def read_int():
	return int(inp())

def read_ints():
	return [int(e) for e in inp().split()]

def dprint(*value, sep=' ', end='\n'):
	if DEBUG:
		print(*value, sep=sep, end=end)

def __starting_point():
	main()
__starting_point()


for t in range(int(input())):
	n = int(input())
	i = 1
	a = set()
	while i * i <= n:
		a.add(n // i)
		i += 1
	for j in range(i):
		if j not in a:
			a.add(j)
	a = list(a)
	a.sort()
	print(len(a))
	print(*a)


for _ in range(int(input())):
	n = int(input())
	if n <= 1000005:
		l = [0, 1]
		for k in range(n - 1, 0, -1):
			a = n // k
			if a > l[-1]:
				l.append(a)
		print(len(l))
		print(*l)
	else:
		l = [x for x in range(1001)]
		for k in range(1000000, 0, -1):
			a = n // k
			if a > l[-1]:
				l.append(a)
		print(len(l))
		print(*l)


nn = int(input())
for i in range(nn):
	n = int(input())
	c = 0
	m = set()
	m.add(c)
	for i in range(1, int(n ** 0.5) + 1):
		m.add(n // i)
		m.add(i)
	l = sorted(m)
	print(len(l))
	for i in l:
		print(i, end=' ')
	print()


import sys

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(INT()):
	N = INT()
	A = []
	prev = -1
	for i in range(1, N + 1):
		a = N // i
		if a == prev:
			for j in range(a - 1, 0, -1):
				A.append(j)
			break
		A.append(a)
		prev = a
	A.append(0)
	print(len(A))
	print(*A[::-1])


import sys
input = lambda : sys.stdin.readline().rstrip()
t = int(input())
for _ in range(t):
	n = int(input())
	ans = [0]
	while ans[-1] < n:
		ok = 0
		ng = n + 1
		while abs(ok - ng) > 1:
			mid = (ok + ng) // 2
			if n // mid > ans[-1]:
				ok = mid
			else:
				ng = mid
		ans.append(n // ok)
	print(len(ans))
	print(*ans)


from math import floor
t = int(input())
for i in range(t):
	n = int(input())
	vals = [str(n)]
	for j in range(2, n + 1):
		next = floor(n / j)
		if next == int(vals[-1]):
			break
		vals.append(str(next))
	prefix = [str(k) for k in range(int(vals[-1]))]
	print(len(prefix) + len(vals))
	print(' '.join(prefix) + ' ' + ' '.join(vals[::-1]))


t = int(input())
for _ in range(t):
	n = int(input())
	s = {0, 1}
	for i in range(1, int(n ** 0.5) + 1):
		k = n // i
		b = n // k
		s.add(k)
		s.add(b)
	print(len(s))
	s2 = list(s)
	s2.sort()
	print(*s2)


import math
t = int(input())
for t1 in range(t):
	n = int(input())
	l1 = []
	for k in range(1, int(math.sqrt(n) + 1)):
		l1.append(n // k)
	for i in range(int(math.sqrt(n)) + 1):
		l1.append(i)
	l1 = list(set(l1))
	l1.sort()
	print(len(l1))
	print(*l1)


import math

def rightans(n):
	ans = set()
	for i in range(1, n + 2):
		ans.add(n // i)
	return list(sorted(ans))
for i in range(int(input())):
	ans = set()
	ans.add(0)
	n = int(input())
	for j in range(1, int(math.sqrt(n)) + 2):
		ans.add(n // j)
		if n // j > 0:
			ans.add(n // (n // j))
			ans.add(n // math.ceil(n // j))
	ans = list(ans)
	ans.sort()
	print(len(ans))
	print(*ans)


import math

def possible(n):
	a = math.ceil(n ** 0.5)
	l1 = [0]
	l2 = []
	for i in range(1, a):
		val = n // i
		if val != i:
			l1.append(i)
			l2.append(n // i)
		else:
			l1.append(i)
	if a ** 2 == n:
		l1.append(a)
	l1.extend(l2[::-1])
	return (len(l1), ' '.join(map(str, l1)))
for _ in range(int(input())):
	(x, y) = possible(int(input()))
	print(x)
	print(y)


for _ in range(int(input())):
	z = int(input())
	l = set()
	for i in range(1, int(z ** 0.5) + 1):
		l.add(z // i)
		l.add(i)
	l.add(0)
	a = sorted(l)
	print(len(a))
	print(*a)


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	ret = set()
	n = int(input())
	ret.add(0)
	i = 1
	while i * i <= n:
		tmp = n // i
		if n // tmp == i:
			ret.add(i)
		ret.add(n // i)
		i += 1
	ans = list(ret)
	ans.sort()
	print(len(ans))
	print(' '.join([str(item) for item in ans]))


from math import *
t = int(input())
for zz in range(t):
	n = int(input())
	res = []
	k = n + 1
	cv = 0
	while k >= 1:
		res.append(str(n // k))
		if k == n + 1:
			k = (n + 2) // 2
		else:
			cv = n // k
			cv += 1
			k = floor(n / cv)
	print(len(res))
	print(' '.join(res))


from math import sqrt
from collections import deque
for tt in range(int(input())):
	n = int(input())
	v = deque()
	v.appendleft(0)
	for i in range(1, int(sqrt(n)) + 1):
		v.append(i)
		v.append(n // i)
	v = set(v)
	v = list(sorted(v))
	print(len(v))
	print(*v)


from sys import stdin
from math import sqrt
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	arr = set([0])
	s = int(sqrt(n)) + 1
	for i in range(1, s):
		if n // i not in arr:
			arr.add(n // i)
			arr.add(i)
	print(len(arr))
	arr = list(arr)
	arr.sort()
	print(*arr)


tst = int(input())
for i in range(0, tst):
	n = int(input())
	ans = 1
	l = 1
	p = []
	while l <= n:
		ans += 1
		l = n // (n // l)
		p.append(n // l)
		l += 1
	p.append(0)
	p.reverse()
	print(len(p))
	print(' '.join((str(x) for x in p)))


from math import sqrt

def solve(n):
	i = 1
	ans = set()
	while i <= sqrt(n):
		if int(n / i) not in ans:
			ans.add(int(n / i))
		i += 1
	p = [int(x) for x in range(int(sqrt(n)) + 1)] + list(ans)
	return p
for _ in range(int(input())):
	n = int(input())
	p = set(solve(n))
	print(len(p))
	print(*sorted(p))


for _ in range(int(input())):
	n = int(input())
	s = {0}
	for i in range(1, int(n ** 0.5) + 1):
		s.add(i)
		s.add(n // i)
	l = sorted(list(s))
	print(len(s))
	print(*l)


for _ in range(int(input())):
	n = int(input())
	(s, l) = ([0], [])
	for d in range(1, n // 2 + 2):
		if n // d <= s[-1]:
			break
		l.append(n // d)
		if d >= l[-1]:
			break
		s.append(d)
	s += l[::-1]
	print(len(s))
	print(' '.join((str(i) for i in s)))


for _ in range(int(input())):
	n = int(input())
	k = set()
	a = 1
	b = n // a
	listrating = set([0])
	while a < b:
		listrating.add(n // a)
		listrating.add(n // b)
		a += 1
		b = n // a
	listrating.add(n // a)
	listrating.add(n // b)
	listrating = list(listrating)
	listrating.sort()
	print(len(listrating))
	print(' '.join([str(x) for x in listrating]))


for i in range(int(input())):
	n = int(input())
	a = []
	i = n + 1
	while i != 0:
		az = n // i
		i = n // (az + 1)
		a.append(az)
	print(len(a))
	print(*a)


t = int(input())
for _ in range(t):
	n = int(input())
	aa = []
	ind = 1
	while True:
		aa.append(n // ind)
		if len(aa) >= 2:
			if aa[-1] == aa[-2]:
				for i in range(aa[-1], -1, -1):
					aa.append(i)
				break
		ind += 1
	print(len(set(aa)))
	print(*sorted(list(set(aa))))


import sys
input = sys.stdin.readline
t = int(input())
for testcases in range(t):
	n = int(input())
	ANS = [n // 1]
	for i in range(2, n):
		ANS.append(n // i)
		if n / (i - 1) - n / i < 1:
			break
	A = list(range(0, ANS[-1])) + sorted(set(ANS))
	print(len(A))
	print(*A)


import sys
input = sys.stdin.readline

def divisors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		res.append(i)
		res.append(n // i)
	return res
for _ in range(int(input())):
	n = int(input())
	s = set()
	for i in divisors(n):
		s.add(i)
	s.add(0)
	print(len(s))
	print(*sorted(s))


for _ in range(int(input())):
	n = int(input())
	arr = [0]
	for i in range(1, int(n ** 0.5) + 1):
		arr.append(i)
		arr.append(n // i)
	arr.sort()
	print(len(set(arr)))
	vis = set([])
	temp = []
	for i in arr:
		if i not in vis:
			temp.append(i)
			vis.add(i)
		else:
			vis.add(i)
	print(*temp)


t = int(input())
for i in range(t):
	n = int(input())
	answers = set()
	answers.add(n)
	x = 1
	while x <= n // 2 + 1:
		target = n // x
		left = x
		right = (n + 1) // target + 1
		ans = x
		while left <= right:
			mid = (left + right) // 2
			if n // mid == target:
				ans = mid
				left = mid + 1
			else:
				right = mid - 1
		x = ans + 1
		answers.add(n // x)
	answers.add(1)
	answers.add(0)
	print(len(answers))
	print(' '.join([str(a) for a in sorted(answers)]))


def solve():
	n = int(input())
	i = 1
	l = [0]
	m = []
	sqrt = n ** 0.5
	while i <= sqrt:
		k = n // i
		m.append(k)
		l.append(i)
		i += 1
	if l[-1] == m[-1]:
		l.pop()
	print(len(l) + len(m))
	for i in l:
		print(i, end=' ')
	for i in range(len(m) - 1, -1, -1):
		print(m[i], end=' ')
	print()
t = int(input())
for _ in range(t):
	solve()


import math
t = int(input())
for i in range(t):
	n = int(input())
	x = 1
	s = set()
	s.add(0)
	s.add(1)
	while x < n // 2 + 1:
		(r, d) = (n % x, n // x)
		x += max(1, r // d)
		s.add(d)
	print(len(s))
	print(' '.join(map(str, sorted(list(s)))))


t = int(input())
for i in range(t):
	n = int(input())
	s = set()
	f = []
	for j in range(1, int(n ** 0.5) + 1):
		d = n // j
		e = n // (n // j)
		if d not in s:
			s.add(d)
			f.append(d)
		if e not in s:
			s.add(e)
			f.append(e)
	f.append(0)
	f.sort()
	print(len(f))
	print(*f, sep=' ')


import sys
import math
import itertools
import collections

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)

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

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

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

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

def wr(arr):
	return ' '.join(map(str, arr))

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
t = ii()
for _ in range(t):
	n = ii()
	t = list(range(int(math.sqrt(n) + 1)))
	ans = t.copy()
	if int(n / t[-1]) == t[-1]:
		for i in range(len(t) - 2, 0, -1):
			ans.append(int(n / t[i]))
	else:
		for i in range(len(t) - 1, 0, -1):
			ans.append(int(n / t[i]))
	print(len(ans))
	print(wr(ans))


from sys import stdin
import math
t = int(stdin.readline())
while t:
	n = int(stdin.readline())
	l = set()
	l.add(0)
	for i in range(1, int(math.sqrt(n)) + 1):
		l.add(n // i)
		l.add(n // (n // i))
	print(len(l))
	print(*sorted(l))
	t -= 1


for _ in range(int(input())):
	n = int(input())
	ar1 = []
	ar2 = [0]
	count = 1
	for k in range(1, int(n ** (1 / 2)) + 1):
		p = n // k
		if p != k and n % k <= p:
			count += 2
			ar1.append(p)
			ar2.append(k)
		elif p == k and n % k <= p:
			count += 1
			ar1.append(p)
	print(count)
	print(*ar2 + ar1[::-1])


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
from math import sqrt
for _ in range(int(input())):
	n = int(input())
	sq = int(sqrt(n))
	a = []
	b = []
	for i in range(sq - 1, 0, -1):
		a.append(i)
		b.append(n // i)
	if sq == n // sq:
		c = 1
	else:
		c = 2
	print(1 + len(a) + len(b) + c)
	print(0, end=' ')
	for i in range(len(a) - 1, -1, -1):
		print(a[i], end=' ')
	if sq == n // sq:
		print(sq, end=' ')
	else:
		print(sq, n // sq, end=' ')
	print(*b)


from math import sqrt

def main():
	for _ in range(int(input())):
		n = int(input())
		q = int(sqrt(n))
		if n // q == q:
			print(q * 2)
			print(' '.join(map(str, range(q))), ' '.join(map(str, (n // p for p in range(q, 0, -1)))))
		else:
			print(q * 2 + 1)
			print(' '.join(map(str, range(q + 1))), ' '.join(map(str, (n // p for p in range(q, 0, -1)))))
main()


from collections import deque
for _ in range(int(input())):
	n = int(input())
	ans = deque()
	ans.appendleft(n)
	for i in range(2, n):
		x = n // i
		if ans[0] != x:
			ans.appendleft(x)
		else:
			break
	print(ans[0] + len(ans))
	print(*range(0, ans[0]), end=' ')
	print(*ans)


t = int(input())
while t:
	n = int(input())
	ans1 = [0]
	ans2 = []
	i = 1
	while i * i <= n:
		if n // i != i:
			ans1.append(i)
			ans2.append(n // i)
		else:
			ans1.append(i)
		i += 1
	ans = ans1 + ans2[::-1]
	print(len(ans))
	print(*ans)
	t -= 1


di = {}
for _ in range(int(input())):
	n = int(input())
	if n in di:
		print(di[n][0])
		print(di[n][1])
		continue
	s1 = set()
	s1.add(1)
	s1.add(n)
	s1.add(0)
	min = n
	i = 2
	while i <= min:
		next = n // i
		min = next
		s1.add(next)
		if n // next == i:
			s1.add(i)
		i += 1
	s = ''
	ans = ' '.join((str(k) for k in sorted(list(s1))))
	print(len(s1))
	print(ans)
	di[n] = [len(s1), ans]


import math
t = int(input())
for _ in range(t):
	n = int(input())
	divisors = set((n // i for i in range(1, int(math.sqrt(n)) + 1)))
	for d in divisors.copy():
		divisors.add(n // d)
	divisors.add(0)
	print(len(divisors))
	print(*sorted(divisors))


t = int(input())
for _ in range(t):
	n = int(input())
	s = set.union({0}, *({i, n // i} for i in range(1, int(n ** 0.5) + 1)))
	print(len(s))
	for v in sorted(s):
		print(v, end=' ')
	print()


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from collections import defaultdict as dd
(t,) = I()
while t:
	t -= 1
	(n,) = I()
	ans = set()
	ans.add(0)
	for i in range(1, int(n ** 0.5 + 1)):
		k = n // i
		if k * i <= n:
			ans.add(i)
			ans.add(k)
		k += 1
		if k * i <= n:
			ans.add(k)
	print(len(ans))
	ans = sorted(ans)
	print(*ans)


from sys import stdin

def iin():
	return int(stdin.readline())

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

def check(a):
	sa = set()
	for i in range(a + 1, 0, -1):
		sa.add(a // i)
	return sa

def main():
	t = iin()
	while t:
		t -= 1
		n = iin()
		ans = {0}
		ch = 1
		while 1:
			x = n // ch
			if x == 0:
				break
			ch = n // x
			ans.add(ch)
			ch += 1
		ans.add(n)
		ans = list(ans)
		ans.sort()
		print(len(ans))
		print(*ans)
main()


import math
for _ in range(int(input())):
	n = int(input())
	s = set()
	for i in range(1, int(math.sqrt(n) + 1)):
		d = n // i
		s.add(i)
		s.add(d)
	s.add(0)
	l = list(s)
	l.sort()
	print(len(l))
	print(*l)


from math import *
tc = int(input())
for i in range(tc):
	ans = set()
	n = int(input())
	if n == 1:
		print(2)
		print('0 1')
		continue
	for i in range(1, n):
		div = n // i
		if div in ans:
			break
		ans.add(i)
		ans.add(div)
	ans.add(0)
	print(len(ans))
	for i in sorted(ans):
		print(i, end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	l = [x for x in range(int(n ** (1 / 2)) + 1)] + [int(n / i) for i in range(1, int(n ** (1 / 2)) + 1)]
	s = set(l)
	k = list(s)
	k.sort()
	m = [str(x) for x in k]
	print(len(k))
	print(' '.join(m))


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	v = [n]
	if n == 1:
		print(2)
		print(0, 1)
	else:
		l = 2
		p = r = n // 2 + 1
		v += (n // 2,)
		ans = n // 2
		ans1 = ans
		while ans != 1:
			r = p
			while l <= r:
				m = (l + r) // 2
				s = n // m
				if s < ans:
					ans1 = s
					r = m - 1
				else:
					l = m + 1
			v += (ans1,)
			ans = ans1
		v += (0,)
		print(len(v))
		print(*v[::-1])


t = int(input())
out = []
for i in range(t):
	n = int(input())
	out = ['0']
	start = n + 1
	end = n
	while start > 0 and end > 0 and (int(n / start) != int(n / end)):
		out.append(str(int(n / end)))
		start = int(n / int(n / end))
		end = min(start - 1, int(n / (int(n / end) + 1)))
	print(len(out))
	print(' '.join(out))


import math
for _ in range(int(input())):
	n = int(input())
	x = int(math.sqrt(n))
	if int(n) == x:
		ans = [0]
		for i in range(1, x + 1):
			j = n // i
			if j == i:
				ans.append(i)
				break
			ans.append(i)
			ans.append(j)
		ans.sort()
		print(len(ans))
		print(*ans)
	else:
		ans = [0]
		for i in range(1, x + 1):
			j = n // i
			if j == i:
				ans.append(i)
				break
			ans.append(i)
			ans.append(j)
		ans.sort()
		print(len(ans))
		print(*ans)


def rating(n):
	ans = []
	p = 0
	for i in range(0, int(n ** 0.5) + 1):
		ans.append(i)
	if n // int(n ** 0.5) == int(n ** 0.5):
		p = 1
	for i in range(p, int(n ** 0.5)):
		ans.append(n // (int(n ** 0.5) - i))
	if ans[len(ans) - 1] != n:
		ans.append(n)
	return ans
n = int(input())
res = []
for i in range(n):
	a = int(input())
	res.append(rating(a))
for j in res:
	tmp = len(j)
	tmp3 = str(j).strip('[]').replace(',', '')
	print(tmp)
	print(tmp3)


t = int(input())
for _ in range(t):
	n = int(input())
	b = set([])
	for i in range(1, n + 2):
		if n // i not in b:
			b.add(n // i)
		else:
			b = sorted(list(b), reverse=True)
			for i in range(b[-1] - 1, -1, -1):
				b.append(i)
			break
	print(len(b))
	b = sorted(list(b))
	print(*b)


for _ in range(int(input())):
	n = int(input())
	aaa = set()
	aaa.add(0)
	for i in range(1, int(n ** 0.5) + 1):
		aaa.add(n // i)
		aaa.add(i)
	print(len(aaa))
	print(*sorted(aaa))


import math
t = int(input())
for i in range(t):
	n = int(input())
	m = math.floor(math.sqrt(n))
	ans = [j for j in range(m + 1)]
	left = m
	while m > 0:
		k = n // m
		if left == k:
			m -= 1
			continue
		ans.append(k)
		left = k
		m -= 1
	print(len(ans))
	print(*ans, sep=' ')


import math
n = int(input())
for i in range(n):
	k = int(input())
	if k == 1:
		print(2)
		print('0', '1')
	else:
		res = 0
		t = []
		h = []
		for i in range(1, math.floor(math.sqrt(k) + 1)):
			h.append(i)
			if i != k // i:
				t.append(k // i)
		res += len(h) + len(t)
		print(res + 1)
		print(0, end=' ')
		t.reverse()
		for i in range(len(h)):
			print(h[i], end=' ')
		for i in range(len(t)):
			print(t[i], end=' ')
		print()


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
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))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

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

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

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

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

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

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve(case):
	n = int(inp())
	ans = [0]
	have = {}
	for i in range(1, floor(n ** 0.5) + 1):
		temp = n // i
		if temp not in have:
			have[temp] = 1
			ans.append(temp)
		new = n // temp
		if new not in have:
			have[new] = 1
			ans.append(new)
	ans = sorted(ans)
	print(len(ans))
	print(' '.join((str(ans[i]) for i in range(len(ans)))))
testcase(int(inp()))


from sys import stdin, stdout
t = int(input())
for _ in range(t):
	n = int(input())
	a = []
	L = [i for i in range(int(n ** (1 / 2) + 1))] + [int(n / i) for i in range(1, int(n ** (1 / 2) + 1))]
	a = list(map(str, sorted(list(set(L)))))
	print(len(a))
	print(*a)


for _ in [0] * int(input()):
	n = int(input())
	a = [i for i in range(int(n ** (1 / 2) + 1))] + [int(n / i) for i in range(1, int(n ** (1 / 2) + 1))]
	a = sorted(list(set(a)))
	print(len(a))
	print(' '.join([str(x) for x in a]))


sp = lambda : list(map(int, input().split()))
si = lambda : int(input())
TESTCASES = int(input())
for tc in range(TESTCASES):
	n = si()
	ints = set(range(int(n ** 0.5) + 1))
	for i in range(int(n ** 0.5) + 1, 0, -1):
		ints.add(n // i)
	ints = sorted(list(ints))
	print(len(ints))
	print(' '.join(map(str, ints)))


import os, sys, heapq
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')
from math import ceil, remainder
mod = 10 ** 9 + 7
for _ in range(int(input())):
	n = int(input())
	if n == 1:
		print(2)
		print(0, 1)
	elif n == 3:
		print(3)
		print(0, 1, 3)
	else:
		answer = [0]
		end = int(pow(n, 0.5))
		for i in range(1, end + 1):
			if i == end:
				answer.append(i)
				if n // i not in answer:
					answer.append(n // i)
			else:
				answer.append(i)
				answer.append(n // i)
		answer.sort()
		print(len(answer))
		print(*answer)


from math import floor, sqrt

def solve(n):
	ans = set()
	for i in range(1, floor(sqrt(n)) + 1):
		ans.add(i)
		ans.add(floor(n / i))
	ans.add(0)
	return (len(ans), list(map(str, sorted(ans))))
t = int(input())
for _ in range(t):
	n = int(input())
	(nums, ratings) = solve(n)
	print(nums)
	print(' '.join(ratings))


for i in range(int(input())):
	n = int(input())
	st = set()
	ans = [0]
	st.add(0)
	num = n
	while num >= 1:
		if n // num not in st:
			st.add(n // num)
			ans.append(n // num)
			num -= 1
		else:
			num = (n + ans[-1]) // (ans[-1] + 1)
			if n // num not in st:
				st.add(n // num)
				ans.append(n // num)
				num -= 1
			else:
				num -= 1
	print(len(ans))
	print(' '.join(map(str, ans)))


t = int(input())
for query in range(t):
	n = int(input())
	mylist = [0]
	mylist2 = []
	counter = 1
	total = 1
	mystring = ''
	while True:
		if counter + 1 > int(n / counter + 1):
			break
		mylist.append(counter)
		total = total + 1
		if counter == int(n / counter):
			break
		mylist2.append(int(n / counter))
		total = total + 1
		counter = counter + 1
	print(total)
	for num in mylist:
		print(num, end=' ')
	for num in mylist2[::-1]:
		print(num, end=' ')


import sys, math
input = sys.stdin.readline

def inp():
	n = int(input())
	return n

def inlt():
	a = list(map(int, input().split()))
	return a

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	(a, b) = map(int, input().split())
	return (a, b)
t = 1
t = inp()
for tt in range(t):
	n = inp()
	q = {0}
	for i in range(1, int(n ** 0.5 + 1)):
		q.add(n // i)
		q.add(n // (n // i))
	q = list(q)
	q.sort()
	print(len(q))
	print(*q)


from math import sqrt
t = int(input())
for _ in range(t):
	n = int(input())
	m = (sqrt(4 * n + 1) - 1) / 2
	a = list(range(1, int(m) + 1))
	for k in range(1, int(n / m) + 1):
		a.append(n // k)
	a.append(0)
	a = sorted(list(set(a)))
	print(len(a))
	print(*a, sep=' ')


import math
for _ in range(int(input())):
	s = set()
	s.add(0)
	n = int(input())
	for i in range(1, math.ceil(math.sqrt(n)) + 1):
		s.add(n // i)
		s.add(n // (n // i))
	print(len(s))
	print(*sorted(s))


def bsearch(st, en, n, x):
	k = (st + en) // 2
	if n // k < x:
		if st == en:
			return k
		return bsearch(st, k, n, x)
	return bsearch(k + 1, en, n, x)

def solve():
	n = int(input())
	x = n
	ans = [str(x)]
	while x > 1:
		k = bsearch(0, n, n, x)
		x = n // k
		ans.append(str(x))
	ans.append('0')
	print(len(ans))
	print(' '.join(ans[::-1]))
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	n = int(input())
	mid = int(n ** 0.5)
	if n // mid > mid:
		print(2 * mid + 1)
	else:
		print(2 * mid)
	i = 0
	while i <= mid:
		print(i, end=' ')
		i += 1
	i = mid
	while i > 0:
		if n // i > mid:
			print(n // i, end=' ')
		i -= 1
	print()


for _ in range(int(input())):
	n = int(input())
	c = set()
	c.add(0)
	for i in range(1, int(n ** 0.5) + 1):
		c.add(i)
		c.add(n // i)
	c = sorted(c)
	print(len(c))
	print(' '.join(map(str, c)))


for _ in range(int(input())):
	n = int(input())
	ans = []
	i = 1
	while i < n:
		if len(ans) != 0:
			if ans[-1] == n // i:
				break
		ans.append(n // i)
		i += 1
	if len(ans) == 0:
		print(2)
		print('0 1')
		continue
	for i in range(ans[-1] - 1, -1, -1):
		ans.append(i)
	print(len(ans))
	print(' '.join(map(str, ans[::-1])))


from sys import stdin, stdout
LI = lambda : list(map(int, input().split()))
MAP = lambda : map(int, input().split())
IN = lambda : int(input())
S = lambda : input()
import math
from collections import Counter, defaultdict

def solve():
	n = IN()
	d = {}
	for i in range(1, int(n ** 0.5) + 1):
		d[n // i] = 0
		d[i] = 0
	a = list(d.keys()) + [0]
	a.sort()
	print(len(a))
	print(*a)
for i in range(IN()):
	solve()


from math import ceil, sqrt
for _ in range(int(input())):
	n = int(input())
	if n == 1:
		print(2)
		print(0, 1)
		continue
	d = set()
	for x in range(1, ceil(sqrt(n)) + 1):
		d.add(n // x)
	tmp = set()
	for x in d:
		tmp.add(n // x)
	d |= tmp
	d.add(0)
	print(len(d))
	print(*sorted(d))


import math
t = int(input())
for i in range(t):
	n = int(input())
	x = math.ceil(math.sqrt(n))
	res = [0]
	for i in range(1, x):
		res.append(n // i)
		res.append(i)
	if x * x == n:
		res.append(x)
	res = list(set(res))
	res.sort()
	print(len(res))
	print(*res)


t = int(input())
for _ in range(t):
	n = int(input())
	ans = set()
	for i in range(1, n + 2):
		if n // i not in ans:
			ans.add(n // i)
		else:
			ans = ans.union(set(list(range(0, n // i))))
			break
	print(len(ans))
	print(' '.join(map(str, sorted(ans))))


t = int(input())
for _ in range(t):
	n = int(input())
	ans = []
	ans.append(0)
	ans.append(1)
	ans.append(n)
	for i in range(2, int(n ** 0.5) + 1):
		ans.append(n // i)
		ans.append(n // (n // i))
	ans = set(ans)
	ans = list(ans)
	ans.sort()
	print(len(ans))
	for i in ans:
		print(i, end=' ')
	print()


import math
t = int(input())
for i in range(t):
	n = int(input())
	p = int(math.sqrt(n))
	a = [0]
	j = 1
	while j <= p:
		a.append(j)
		j += 1
	h = int(n // p)
	if a[-1] != h:
		a.append(h)
	j = p - 1
	while j >= 1:
		a.append(int(n / j))
		j += -1
	print(len(a))
	print(*a)


for _ in range(int(input())):
	n = int(input())
	if n == 1:
		print(2)
		print(0, 1)
	else:
		k = int(n ** 0.5)
		b = set(range(0, k + 1))
		for i in range(k, 1, -1):
			b.add(n // i)
		b.add(n)
		b = sorted(list(b))
		print(len(b))
		print(' '.join(map(str, b)))


from math import *
t = int(input())
for o in range(t):
	n = int(input())
	ans = [n]
	j = 0
	for i in range(2, n + 1):
		if n // i < ans[j]:
			ans.append(n // i)
			j += 1
		if n // i <= int(sqrt(n)):
			break
	for i in range(int(sqrt(n)) - 1, -1, -1):
		ans.append(i)
	ans = ans[::-1]
	print(len(ans))
	print(*ans, sep=' ')


from collections import deque
for _ in range(int(input())):
	num = int(input())
	left = [0]
	right = deque()
	n = 1
	dig = num
	while dig >= n:
		left.append(n)
		if n < dig:
			right.appendleft(dig)
		n += 1
		dig = num // n
	len_arr = len(left) + len(right)
	print(len_arr)
	print(*left, *right, end=' ')


for _ in range(int(input())):
	n = int(input())
	a = []
	d = {}
	for i in range(1, int(n ** 0.5 + 1)):
		if i not in d.keys():
			a.append(i)
			d[i] = 1
		if n // i not in d.keys():
			a.append(n // i)
			d[n // i] = 1
	a.sort()
	print(len(a) + 1)
	print(0, end=' ')
	for i in a:
		print(i, end=' ')
	print('')


from math import sqrt

def solve(n):
	ans = set([0])
	for i in range(1, int(sqrt(n)) + 1):
		ans.add(i)
		ans.add(n // i)
	ans = sorted(list(ans))
	ans = list(map(str, ans))
	print(len(ans))
	print(' '.join(ans))
t = int(input())
for tc in range(t):
	solve(int(input()))


import sys
import collections
from collections import Counter
import itertools
import math
import timeit

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

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

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

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

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

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
t = ii()
for _ in range(t):
	n = ii()
	res = {0}
	for i in range(1, int(math.sqrt(n) + 1)):
		res.add(i)
		res.add(n // i)
	print(len(res))
	prr(sorted(list(res)))


q = int(input())
for _ in range(q):
	w = int(input())
	e = [1]
	for i in range(2, int(w ** 0.5) + 1):
		if w // e[-1] != w // i:
			e.append(i)
	r = []
	for i in range(len(e)):
		r.append(w // e[i])
	e = set(e + r + [0])
	print(len(e))
	print(*sorted(e))


def solve():
	n = int(input().strip())
	sqrt = int(n ** 0.5)
	ar = []
	for i in range(sqrt + 1):
		ar.append(i)
	if n // sqrt != sqrt:
		ar.append(n // sqrt)
	for i in range(sqrt - 1, 0, -1):
		ar.append(n // i)
	print(len(ar))
	print(' '.join(list(map(str, ar))))
t = int(input().strip())
for _ in range(t):
	solve()


for t in range(int(input())):
	n = int(input())
	arr = [0]
	div = n
	next = 1
	while div > 0:
		div = n // next
		if div != 0:
			no = n // div
			next = no + 1
			arr.append(no)
	print(len(arr))
	print(*arr)


import math
from collections import Counter, defaultdict
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
for _ in range(I()):
	n = I()
	a = [0, n]
	for i in range(1, int(math.sqrt(n)) + 1):
		a += [n // i, n // (n // i)]
	a = list(set(a))
	a.sort()
	print(len(a))
	print(*a)


import sys
input = sys.stdin.buffer.readline

def solution():
	n = int(input())
	x = int(n ** 0.5)
	l = [0]
	i = 1
	while i <= x:
		a = n // i
		l.append(i)
		l.append(a)
		i += 1
	l = list(set(l))
	l.sort()
	print(len(l))
	print(*l)
for _ in range(int(input())):
	solution()


from math import sqrt
t = int(input())
for tt in range(t):
	n = int(input())
	x = set([0, 1, n])
	for i in range(1, int(sqrt(n)) + 1):
		x.add(n // i)
		x.add(i % n)
	print(len(x))
	print(*sorted(x))


for _ in range(int(input())):
	n = int(input())
	i = 1
	also = []
	sqrN = int(n ** 0.5)
	while n // i > sqrN:
		also.append(n // i)
		i += 1
	also.reverse()
	print(int(n ** 0.5) + len(also) + 1)
	for i in range(sqrN + 1):
		print(i, end=' ')
	for d in also:
		print(d, end=' ')
	print()


q = int(input())
for ifwfwe in range(q):
	n = int(input())
	i = 1
	odp = [0]
	while i * i <= n:
		odp.append(i)
		i += 1
	while i > 0:
		if n // i > odp[-1]:
			odp.append(n // i)
		i -= 1
	print(len(odp))
	print(*odp)


t = int(input())
for T in range(t):
	n = int(input())
	l = [0, n]
	st = set(l)
	for i in range(1, int(n ** 0.5) + 1):
		st.add(i)
		st.add(n // i)
	print(len(st))
	print(*sorted(st))


for _ in range(int(input())):
	n = int(input())
	k = int(n ** 0.5)
	b = [0]
	for i in range(1, k + 1):
		b.append(i)
		b.append(n // i)
	b = list(set(b))
	print(len(b))
	print(*sorted(b))


from math import floor, sqrt

def solve(n):
	ans = [0, 1]
	root = floor(sqrt(n))
	for i in range(2, root + 1):
		ans.append(i)
	ans += [n // i for i in range(root, 0, -1) if n // i != ans[-1]]
	return (len(ans), ans)
for _ in range(int(input())):
	n = int(input())
	(k, res) = solve(n)
	print(k)
	print(' '.join(map(str, res)))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

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

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		n = I()
		r = [n]
		i = 2
		while 1:
			t = n // i
			i += 1
			if t == r[-1]:
				i = max(i, n // max(1, t - 1))
				continue
			r.append(t)
			if t == 0:
				break
		rr.append(len(r))
		rr.append(JA(sorted(r), ' '))
	return JA(rr, '\n')
print(main())


import math
t = int(input())
ls_in = []
ls_temp = []
ls_temp2 = []
ls_ans = []
tempa = 0
[ls_in.append(int(input())) for i in range(t)]
for i in ls_in:
	ls_temp = []
	ls_temp2 = []
	tempa = int(math.sqrt(i))
	ls_temp = list(range(tempa + 1))
	ls_temp2 = ls_temp
	for j in ls_temp[1:len(ls_temp) - 1]:
		ls_temp2.append(i // j)
	if i // tempa not in ls_temp2:
		ls_temp2.append(i // tempa)
	ls_temp2.sort()
	ls_ans.append(ls_temp2)
for i in ls_ans:
	print(len(i))
	print(' '.join(map(str, i)))


def kek(n):
	l = [0]
	l2 = []
	i = 1
	while i * i < n:
		l.append(i)
		if n // i != i:
			l2.append(n // i)
		i += 1
	if i * i == n:
		l.append(i)
	l2.reverse()
	l += l2
	return l

def main():
	for _ in range(int(input())):
		n = int(input())
		l = kek(n)
		print(len(l))
		for i in l:
			print(i, end=' ')
		print()
main()


import sys
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	n = int(input())
	s = set([0])
	for i in range(1, int(n ** 0.5) + 1):
		v = n // i
		s.add(v)
		s.add(i)
	print(len(s))
	print(*sorted(s))


from sys import stdin, stdout
import math
input = stdin.readline

def print(x='', end='\n'):
	stdout.write(str(x) + end)

def solve():
	n = int(input())
	ans = [0, 1]
	for i in range(2, int(n ** 0.5) + 1):
		ans.append(i)
		ans.append(n // i)
	ans.append(n)
	ans = list(set(ans))
	ans.sort()
	print(len(ans))
	for i in ans:
		print(i, end=' ')
	print()
test = 1
test = int(input())
for __ in range(test):
	solve()


import sys
import math
import bisect
import heapq
from bisect import bisect_right
from sys import stdin, stdout

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

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

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

def get_list_of_list(n):
	return [list(map(int, sys.stdin.readline().strip().split())) for _ in range(n)]

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

def myceil(x, y):
	return (x + y - 1) // y

def Solution(n):
	res = set()
	res.add(0)
	res.add(1)
	res.add(n)
	for i in range(2, int(math.sqrt(n)) + 1):
		el = n // i
		res.add(el)
		res.add(i)
	print(len(res))
	print(*sorted([c for c in res]))

def main():
	for _ in range(get_int()):
		Solution(get_int())
main()


import math
t = int(input())
for i in range(t):
	n = int(input())
	sq = int(math.sqrt(n))
	ar = [0]
	for j in range(1, sq + 1):
		a = j
		b = n // j
		if a == b:
			ar.append(a)
		else:
			ar.append(a)
			ar.append(b)
	ar.sort()
	print(len(ar))
	print(' '.join(map(str, ar)))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	ls = {0}
	for i in range(1, int(n ** 0.5) + 1):
		ls.add(n // i)
		ls.add(n // (n // i))
	print(len(ls))
	print(*sorted(ls))


import math
for _ in range(int(input())):
	n = int(input())
	l = set()
	l.add(0)
	i = 1
	while i <= math.sqrt(n):
		l.add(n // i)
		l.add(n // (n // i))
		i += 1
	print(len(l))
	l = list(l)
	l = sorted(l)
	for i in l:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = set()
	k = n ** 0.5
	for i in range(1, int(k) + 1):
		a.add(i)
		a.add(n // i)
	a.add(0)
	print(len(a))
	print(*sorted(list(a)))


import math
t = int(input())
ans = []
for _ in range(t):
	n = int(input())
	root = int(math.sqrt(n)) + 5
	vals = set([0])
	for i in range(1, min(root, n + 1)):
		(k, r) = divmod(n, i)
		if (k + 1) * i > n:
			vals.add(k)
		if k * (i + 1) > n:
			vals.add(i)
	ans.append(sorted(vals))
for a in ans:
	print(len(a))
	print(' '.join(map(str, a)))


import math
t = int(input())
for i in range(t):
	n = int(input())
	k = math.floor(math.sqrt(n))
	a = []
	for j in range(1, k + 1):
		a.append(n // j)
	for y in range(k + 1):
		a.append(y)
	a = sorted(list(set(a)))
	print(len(a))
	for k in range(len(a) - 1):
		print(a[k], end=' ')
	print(a[len(a) - 1])


from __future__ import print_function
T = int(input())
for _ in range(T):
	n = int(input())
	s = set()
	last = int(3 * n ** 0.6)
	for i in range(1, last + 1):
		s.add(n // i)
	last_val = n // last
	for i in range(0, last_val):
		s.add(i)
	print(len(s))
	for i in sorted(s):
		print(i, end=' ')
	print()


import os
import sys
from io import BytesIO, IOBase
from collections import Counter, defaultdict
from collections import deque
from functools import cmp_to_key
import math

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

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

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(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
	s = set()
	for p in range(2, n + 1):
		if prime[p]:
			s.add(p)
	return s

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def solve(l, suma, k, n):
	c = 0
	xs = sum(l[0:k])
	if xs == k:
		c += 1
	for j in range(k, n):
		xs -= l[j - k]
		xs += l[j]
		if xs == k:
			c += 1
	return c

def main():
	for _ in range(iin()):
		n = iin()
		d = deque([])
		i = 1
		while i <= n:
			x = n // i
			r = n % i
			d.appendleft(x)
			i += r // x + 1
		d.appendleft(0)
		print(len(d))
		print(*d)
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')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def main():
	ans = []
	n = int(input())
	k = 1
	ans.append(n)
	while k <= 10 ** 6:
		k += 1
		if ans[-1] > n // k:
			ans.append(n // k)
	k = 1
	if n >= 10 ** 6:
		for i in range(1000, -1, -1):
			if ans[-1] > i:
				ans.append(i)
	print(len(ans))
	for i in range(len(ans) - 1, -1, -1):
		print(ans[i], end=' ')
	print()
a = int(input())
for i in range(a):
	main()


import math

def solve():
	n = int(input())
	p = [n]
	i = 2
	while n / i < n / (i - 1) - 1:
		p.append(n // i)
		i += 1
	for j in range(p[-1] - 1, -1, -1):
		p.append(j)
	return p
t = int(input())
for case in range(t):
	x = solve()
	print(len(x))
	print(*x[::-1])


for _ in range(int(input())):
	n = int(input())
	d = 1
	res = [0]
	while d <= n:
		e = n // d
		res.append(e)
		d = n // e + 1
	print(len(res))
	print(*sorted(res))


import math
z = int(input())
for x in range(z):
	n = int(input())
	a = []
	a.append(0)
	b = n ** 0.5
	b = int(b)
	a.append(b)
	if b != n // b:
		a.append(n // b)
	for i in range(1, b):
		a.append(i)
		a.append(n // i)
	print(len(a))
	a.sort()
	ans = ''
	for k in a:
		ans += str(k) + ' '
	print(ans)


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')
for _ in range(int(input())):
	n = int(input())
	ans = [0]
	div = n
	while div >= 1:
		val = n // div
		if ans[-1] != val:
			ans.append(val)
		div = n // (val + 1)
	print(len(ans))
	print(*ans)


from math import *

def arr_inp():
	return [int(x) for x in input().split()]
for i in range(int(input())):
	n = int(input())
	(ans, sz, sqr) = ([0], 1, floor(sqrt(n)) + 1)
	for i in range(1, sqr):
		ans.append(i)
		sz += 1
	for i in range(1, sqr):
		num = floor(n / i)
		if num > i:
			ans.append(num)
			sz += 1
	ans.sort()
	print(sz)
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	lst = [i for i in range(1, int(n ** (1 / 2) + 1))]
	r = [str(elem) for elem in sorted(list(set(lst + [n // i for i in lst])))]
	print(len(r) + 1)
	print(0, ' '.join([str(elem) for elem in sorted(list(set(lst + [n // i for i in lst])))]))


import sys, math

def input():
	return sys.stdin.readline()[:-1]

def main():
	q = int(input())
	for _ in range(q):
		n = int(input())
		ans = set()
		ans.add(0)
		for k in range(1, math.floor(math.sqrt(n)) + 1):
			ans.add(k)
			ans.add(n // k)
		print(len(ans))
		print(*sorted(list(ans)))
main()


import math
for T in range(int(input())):
	n = int(input())
	arr = [0]
	for i in range(1, int(math.sqrt(n)) + 1):
		arr.append(i)
		if n // i != i:
			arr.append(n // i)
	arr.sort()
	print(len(arr))
	print(' '.join(map(str, arr)))


import math
for w in range(int(input())):
	n = int(input())
	l = [0, 1, n]
	for i in range(1, math.floor(math.sqrt(n)) + 1):
		x1 = n // i
		l.append(x1)
		x2 = n // x1
		l.append(x2)
	l = sorted(list(set(l)))
	print(len(l))
	for i in range(len(l)):
		print(l[i], end=' ')
	print()


import heapq
import math
from collections import defaultdict

def get(n):
	a = math.ceil(math.sqrt(n))
	ans = [0]
	vis = defaultdict(int)
	for i in range(1, a + 1):
		b = n // i
		c = n // b
		if b not in vis:
			vis[b] = 1
			ans.append(b)
		if c not in vis:
			vis[c] = 1
			ans.append(c)
	ans.sort()
	return ans
t = int(input())
for _ in range(t):
	n = int(input())
	ans = get(n)
	print(len(ans))
	print(' '.join((str(x) for x in ans)))


import math
n = int(input())
for kk in range(n):
	t = int(input())
	ans = []
	for i in range(1, int(math.sqrt(t)) + 1):
		q = t // i
		ost = t % i
		if ost < q:
			ans.append(i)
			ans.append(q)
	ans.append(0)
	print(len(set(ans)))
	print(' '.join(map(str, sorted(list(set(ans))))))


import sys

def I():
	return sys.stdin.readline().rstrip()
for _ in range(int(I())):
	n = int(I())
	a = [0, 1]
	i = n
	while i > 0:
		if n // i > a[-1]:
			a.append(n // i)
		i = n // (a[-1] + 1)
	print(len(a))
	print(*a)


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		prev = -1
		ans = []
		for i in range(1, 40000):
			v = n // i
			if v == prev:
				break
			ans.append(v)
			prev = v
		for i in range(v - 1, -1, -1):
			ans.append(i)
		print(len(ans))
		print(*ans[::-1])

def __starting_point():
	main()
__starting_point()


from math import *
for _ in range(int(input())):
	n = int(input())
	ans = set()
	ans.add(0)
	ans.add(1)
	for i in range(2, int(sqrt(n)) + 1):
		ans.add(i)
		ans.add(n // i)
	ans.add(n)
	print(len(ans))
	for i in sorted(ans):
		print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	f = set()
	f.add(0)
	for i in range(1, int(n ** 0.5) + 1):
		f.add(n // i)
		f.add(i)
	print(len(f))
	print(*sorted(list(f)))


t = int(input())
for _ in range(t):
	n = int(input())
	sols = set()
	sols.add(n)
	sols.add(0)
	import math
	for k in range(1, int(math.sqrt(n) // 1) + 1):
		sols.add(k)
		sols.add(n // k)
	print(len(sols))
	print(' '.join(map(str, sorted(sols))))


import math
t = int(input())
for i in range(t):
	n = int(input())
	sq = int(math.sqrt(n))
	l = {0}
	for i in range(1, sq + 1):
		l.add(i)
		l.add(n // i)
	s = list(l)
	s.sort()
	lis = ' '.join(map(str, s))
	print(len(l))
	print(lis)


import math
t = int(input())
for i in range(t):
	n = int(input())
	l = [0]
	val = int(math.sqrt(n)) + 1
	for j in range(1, val):
		x = n // j
		y = n // x
		l.append(x)
		l.append(y)
	x = list(set(l))
	x.sort()
	print(len(x))
	print(*x)


def print_seq(n):
	t = n + 1
	pi = n - 1
	ls = []
	ls.append('0')
	ls.append('1')
	i = n // 2
	while i > 1:
		t = n // i
		ls.append(str(t))
		i = n // (n // i + 1)
	if n != 1:
		ls.append(str(n))
	print(len(ls))
	print(' '.join(ls))
	return

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		print_seq(n)
main()


from sys import stdin, stdout
import math
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	s = {0}
	for i in range(1, int(math.sqrt(n)) + 1):
		s.add(i)
		s.add(n // i)
	stdout.write(str(len(s)) + '\n')
	for val in sorted(s):
		stdout.write(str(val) + ' ')
	stdout.write('\n')


import math
t = int(input())
for _ in range(t):
	n = int(input())
	q = math.ceil(n ** 0.5)
	w = n // q
	print(q + w)
	out_one = []
	out_two = []
	for i in range(q):
		out_one.append(i)
	for j in range(w, 0, -1):
		out_two.append(n // j)
	for u in out_one:
		print(u, end=' ')
	for z in out_two:
		print(z, end=' ')
	print()


from sys import stdin, stdout
from io import BytesIO, IOBase
LI = lambda : list(map(int, input().split()))
MAP = lambda : map(int, input().split())
IN = lambda : int(input())
S = lambda : input()
import math
from collections import Counter, defaultdict

def solve():
	n = IN()
	d = {}
	for i in range(1, int(n ** 0.5) + 1):
		d[n // i] = 0
		d[i] = 0
	a = list(d.keys()) + [0]
	a.sort()
	print(len(a))
	print(*a)
for i in range(IN()):
	solve()
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 input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args[:-1]:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(str(args[-1]))
	sys.stdout.write(end)

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

def r_int():
	return int(input())


def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def solve(n):
	i = 1
	ans = [n]
	while i < n + 2:
		b = n
		while b > 0:
			while i + b < n + 2 and n // (i + b) == ans[-1]:
				i += b
			b //= 2
		i += 1
		ans.append(n // i)
	ans = sorted(list(set(ans)))
	return ans
t = int(input())
for _ in range(t):
	n = int(input())
	ans = solve(n)
	print(len(ans))
	oneLineArrayPrint(ans)


tc = int(input())
for _ in range(tc):
	x = int(input())
	ans = set()
	ans.add(0)
	for i in range(1, x + 1):
		tee = x // i
		if tee not in ans:
			ans.add(tee)
			ans.add(x // tee)
		else:
			break
	ans = list(sorted(list(ans)))
	print(len(ans))
	print(*ans)


n = input()
n = int(n)
import collections
for _ in range(n):
	k = int(input())
	a = [0]
	b = []
	x = 1
	while x < k // x:
		a.append(x)
		b.append(k // x)
		x += 1
	if x == k // x:
		a.append(x)
	a.extend(b[::-1])
	print(len(a))
	for x in a:
		print(x, end=' ')
	print()


t = int(input())
for _ in range(t):
	x = 1
	res = []
	n = int(input())
	while n // x != 0:
		res.append(n // x)
		x = 1 + n // (n // x)
	res.append(0)
	print(len(res))
	print(*res[::-1], sep=' ', end='\n')


import math
t = int(input())
for i in range(t):
	n = int(input())
	answers = set()
	answers.add(0)
	for i in range(1, int(math.sqrt(n)) + 1):
		answers.add(i)
		answers.add(n // i)
	print(len(answers))
	print(' '.join([str(a) for a in sorted(answers)]))


for _ in range(int(input())):
	n = int(input())
	ans = []
	ind = n + 1
	while ind > 0:
		a = n // ind
		ind = n // (a + 1)
		ans.append(a)
	print(len(ans))
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	l = set()
	l.add(0)
	for i in range(1, int(pow(n, 0.5)) + 10):
		t = n // i
		l.add(t)
		if t != 0:
			l.add(n // t)
	l = sorted(list(l))
	print(len(l))
	print(*l)


for i in range(int(input())):
	n = int(input())
	b = [i for i in range(1, int(n ** (1 / 2) + 1))]
	r = [str(m) for m in sorted(list(set(b + [n // i for i in b])))]
	print(len(r) + 1)
	print(0, ' '.join([str(m) for m in sorted(list(set(b + [n // i for i in b])))]))


t = int(input())
for _ in range(t):
	n = int(input())
	set_ = set()
	for i in range(1, int(n ** 0.5) + 10):
		set_.add(n // i)
	li = sorted(list(set_))
	num = li[0]
	li2 = [i for i in range(num)]
	print(len(li2) + len(li))
	print(*li2 + li)


from sys import stdin, stdout
from collections import defaultdict, deque
t = int(stdin.readline().strip())
for _ in range(t):
	n = int(stdin.readline().strip())
	ans = set()
	for i in range(1, int(n ** 0.5) + 1):
		ans.add(i)
		ans.add(n // i)
	ans.add(0)
	ans.add(1)
	ans.add(n)
	ans = list(ans)
	ans.sort()
	print(len(ans))
	print(*ans)


import math

def sum(n):
	root = int(math.sqrt(n))
	ans = []
	for i in range(1, root + 1):
		ans.append(n // i)
		ans.append(i)
	return ans
t = int(input())
for i in range(t):
	n = int(input())
	ans = sum(n)
	ans.append(0)
	ans.sort()
	ans = set(ans)
	ans = list(ans)
	print(len(ans))
	print(*ans)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	s = set()
	s.add(0)
	limit = math.ceil(math.sqrt(n))
	for i in range(1, limit + 10):
		tmp = len(s)
		s.add(n // i)
		if len(s) > tmp:
			s.add(i)
	s = sorted(list(s))
	print(len(s))
	print(*s)


t = int(input())
for you in range(t):
	n = int(input())
	l = []
	i = 1
	while i * i <= n:
		if i == n // i:
			l.append(i)
		else:
			l.append(i)
			l.append(n // i)
		i += 1
	l.sort()
	print(len(l) + 1)
	print(0, end=' ')
	for i in l:
		print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	l = [n]
	test = 2
	while n // test != l[-1]:
		l.append(n // test)
		test += 1
	while l[-1] != 0:
		l.append(l[-1] - 1)
	print(len(l))
	print(' '.join(map(str, l[::-1])))


import math
T = int(input())
for t in range(T):
	n = int(input())
	a = math.floor(math.sqrt(n))
	b = n // a
	if a == b:
		print(2 * a)
	else:
		print(2 * a + 1)
	for i in range(a + 1):
		print(i, end=' ')
	if a != b:
		print(b, end=' ')
	for i in range(a - 1, 0, -1):
		print(n // i, end=' ')


def solve(n):
	ls = [n]
	cur = n
	for _ in range(100000):
		low = 1
		high = n + 1
		while low + 1 < high:
			mid = (low + high) // 2
			if n // mid < cur:
				high = mid
			else:
				low = mid
		cur = n // high
		ls.append(cur)
	blah = sorted(set(ls))
	print(len(blah))
	print(' '.join(map(str, blah)))
for _ in range(int(input())):
	solve(int(input()))


from math import *
for _ in range(int(input())):
	n = int(input())
	a = list([0])
	s = int(sqrt(n))
	for i in range(1, s + 1):
		a.append(i)
		a.append(n // i)
	a = list(set(a))
	a.sort()
	print(len(a))
	print(*a)


for _ in range(int(input())):
	n = int(input())
	ans1 = []
	ans2 = []
	i = 1
	while i <= n ** 0.5:
		k = n // i
		ans1.append(k)
		ans2.append(i)
		i += 1
	if ans1[-1] == ans2[-1]:
		ans1.pop()
	print(len(ans1) + len(ans2) + 1)
	print(0, end=' ')
	for i in ans2:
		print(i, end=' ')
	for i in ans1[::-1]:
		print(i, end=' ')
	print()


def solve():
	n = int(input())
	s = set()
	s.add(0)
	for i in range(1, int(n ** 0.5) + 1):
		k = n // i
		s.add(k)
		s.add(i)
	ans = sorted(s)
	print(len(ans))
	print(*ans)
t = int(input())
for i in range(t):
	solve()


for tc in range(int(input())):
	n = int(input())
	i = 1
	S = {0}
	while i * i <= n:
		S.add(n // i)
		if i > n % i:
			S.add(i)
		i += 1
	print(len(S))
	for x in sorted(S):
		print(x)


from math import sqrt
from sys import stdin, stdout
for i in range(int(input())):
	n = int(input())
	(s, j, l) = (set([0, 1]), 2, sqrt(n))
	while j <= l:
		s.add(j)
		s.add(int(n // j))
		j += 1
	s.add(n)
	(a, l) = (sorted(s), len(s))
	stdout.write('%d\n' % l)
	for j in range(l):
		stdout.write('%d ' % a[j])
	stdout.write('\n')


import collections

def f():
	n = int(input())
	a = int(n ** 0.5)
	poss = list(range(a + 1))
	if n // a != a:
		poss.append(n // a)
	for i in range(a - 1, 0, -1):
		poss.append(n // i)
	print(len(poss))
	print(' '.join((str(num) for num in poss)))
t = int(input())
for i in range(t):
	f()


from math import *
for u in range(int(input())):
	n = int(input())
	l = [0, 1, n]
	for i in range(2, int(sqrt(n)) + 1):
		l.append(i)
		l.append(n // i)
	l = list(set(l))
	l.sort()
	print(len(l))
	print(*l)


T = int(input())
for _ in range(T):
	n = int(input())
	ans = []
	if n == 1:
		print(2)
		print(0, 1)
		continue
	elif n == 2:
		print(3)
		print(0, 1, 2)
		continue
	elif n == 3:
		print(3)
		print(0, 1, 3)
		continue
	k = n // 2
	a = 2
	l = 1
	r = n // 2
	ans = [0, 1]
	while True:
		ans.append(a)
		if r == 1:
			break
		while l <= r:
			mid = (l + r) // 2
			if n // mid > a:
				a1 = n // mid
				a2 = mid
				l = mid + 1
			else:
				r = mid - 1
		a = a1
		r = a2
		l = 1
	print(len(ans))
	print(*ans)


t = int(input())
while t:
	t -= 1
	n = int(input())
	ans = []
	i = 0
	while i * i <= n:
		ans.append(i)
		if i:
			ans.append(n // i)
		i += 1
	ans = list(set(ans))
	ans.sort()
	print(len(ans))
	print(*ans)


t = int(input())
while t != 0:
	n = int(input())
	p = int(pow(n, 0.5)) + 1
	list1 = list()
	for i in range(1, p):
		if n % i == 0:
			list1.append(i)
			list1.append(n // i)
		else:
			list1.append(n // i)
			list1.append(i)
	list1.append(0)
	list1 = list(set(list1))
	print(len(list1))
	list1.sort()
	for j in range(len(list1)):
		print(list1[j], end=' ')
	print()
	t -= 1


import math
for j in range(int(input())):
	a = int(input())
	A = [0]
	B = []
	b = a ** 0.5
	if a % b == 0:
		b = int(b + 1)
	else:
		b = int(math.ceil(b))
	for i in range(1, b):
		B.append(a // i)
		if a // i != i:
			A.append(i)
	for i in range(len(B) - 1, -1, -1):
		A.append(B[i])
	print(len(A))
	print(' '.join(list(map(str, A))))


from math import sqrt
t = int(input())
for _ in range(t):
	n = int(input())
	ans = set()
	ans.add(0)
	root = int(sqrt(n))
	for x in range(1, root + 1):
		ans.add(x)
		ans.add(n // x)
	print(len(ans))
	ans = sorted(ans)
	for x in ans:
		print(x, end=' ')
	print()


import math
t = int(input())
for i in range(t):
	n = int(input())
	nums = []
	s = int(math.sqrt(n))
	for c in range(1, s + 1):
		if c != n // c:
			nums.append(n // c)
	if s == n // s:
		print(2 * s)
	else:
		print(1 + 2 * s)
	print(*range(s + 1), *reversed(nums))


import sys
FOR_SUBMIT = True
readline = sys.stdin.readline
old_print = print

def print(i):
	if not FOR_SUBMIT:
		old_print(i)
import math

def divisorGenerator(n):
	large_divisors = []
	last = 0
	for i in range(1, int(math.sqrt(n) + 1)):
		if i != last:
			last = i
			yield last
			if n // i != i:
				large_divisors.append(n // i)
	for divisor in reversed(large_divisors):
		yield divisor

def solve(N):
	ANS = 0
	divisors = list(divisorGenerator(N))
	old_print(len(divisors) + 1)
	old_print(' '.join(['0'] + [str(i) for i in divisors]))
T = int(readline())
for _ in range(T):
	N = int(readline())
	solve(N)


t = int(input())
for I in range(t):
	n = int(input())
	ans = [0] * 10 ** 5
	d = 1
	count = 0
	while d * d - 1 <= n:
		ans[count] = n // d
		d += 1
		count += 1
	d = ans[count - 1]
	for i in range(d - 1, -1, -1):
		ans[count] = i
		count += 1
	print(count)
	print(' '.join([str(i) for i in list(reversed(ans[:count]))]))


from collections import *
from functools import reduce
import sys
input = sys.stdin.readline

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def li():
	return [int(i) for i in input().rstrip('\n').split(' ')]

def st():
	return input().rstrip('\n')

def val():
	return int(input())
l = [i for i in range(1, 10 ** 5 + 50)]
for i in range(val()):
	n = val()
	s = set()
	for i in l:
		if i <= n:
			s.add(n // i)
		else:
			break
	for i in list(s):
		s.add(n // i)
	s.add(0)
	print(len(s))
	print(*sorted(list(s)))


import sys
reader = (int(s.rstrip()) for s in sys.stdin)

def rating(n):
	m = n
	ans = [0, 1]
	ndiv = 2
	while True:
		brick = n // ndiv
		if not brick:
			break
		ndiv = n // brick
		ans.append(ndiv)
		ndiv += 1
	return ans
t = next(reader)
for _ in range(t):
	n = next(reader)
	ans = rating(n)
	sys.stdout.write(str(len(ans)) + '\n')
	sys.stdout.write(' '.join(map(str, ans)) + '\n')


import math
t = int(input())
for _ in range(t):
	n = int(input())
	m = int(math.sqrt(n))
	l = []
	for i in range(1, m + 1):
		l.append(n // i)
	if l[-1] == m:
		m -= 1
	for i in range(m + 1):
		l.append(m - i)
	print(len(l))
	l.sort()
	print(*l)


for _ in range(int(input())):
	l = {0}
	a = int(input())
	for j in range(1, 1 + int(a ** 0.5)):
		l.add(j)
		l.add(a // j)
	print(len(l))
	l = sorted(list(l))
	for i in l:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	ret = {0}
	d = 1
	while d * d <= n:
		ret.update((n // d, d))
		d += 1
	print('%d\n%s' % (len(ret), ' '.join(map(str, sorted(ret)))))


import sys
import math
from collections import defaultdict, Counter, deque
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')
t = int(input())
for i in range(t):
	n = int(input())
	l = [0]
	for j in range(1, n + 1):
		d = n // j
		if d == l[-1]:
			l.extend(range(d - 1, 0, -1))
			break
		l.append(d)
	l.sort()
	print(len(l))
	print(*l)


t = int(input())
for i in range(t):
	n = int(input())
	c = set()
	c.add(0)
	for i in range(1, int(n ** 0.5) + 1):
		c.add(n // i)
		c.add(i)
	print(len(c))
	print(*sorted(c))


t = int(input())
for i in range(0, t):
	n = int(input())
	L = [0, 1]
	if n == 1:
		print(2)
		print(*L)
	else:
		y = int(n ** 0.5)
		L = [i for i in range(y + 1)]
		for i in range(y + 1, 0, -1):
			x = n // i
			if L[-1] < x:
				L.append(x)
		print(len(L))
		print(*L)


def main():
	n = int(input())
	num = n // 2
	ans = [0, 1]
	prev = 1
	l = 2
	while num > 0:
		temp = n // num
		if temp != prev:
			l += 1
			prev = temp
			ans.append(temp)
			num = n // (temp + 1)
		else:
			num -= 1
	print(l)
	print(*ans)
t = int(input())
for _ in range(t):
	main()


t = int(input())
for _ in range(t):
	ratings = int(input())
	increments = [0]
	i = ratings
	while i > 0:
		poss = ratings // i
		if poss != increments[-1]:
			increments.append(poss)
			i = ratings // (poss + 1)
	print(len(increments))
	print(*increments)


from sys import stdin
from math import sqrt

def input():
	return stdin.readline()[:-1]

def intput():
	return int(input())

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

def intsput():
	return map(int, sinput())
t = intput()
for _ in range(t):
	n = intput()
	k = int(sqrt(n))
	ans = [0]
	for i in range(1, k + 1):
		quotient = n // i
		remainder = n % i
		q2 = n // quotient
		q2 += remainder // quotient
		r2 = remainder % quotient
		ans.append(quotient)
		ans.append(q2)
	ans.sort()
	s = 0
	os = []
	for i in range(len(ans)):
		if i == 0:
			os.append(str(ans[i]))
			s += 1
		elif ans[i] != ans[i - 1]:
			os.append(str(ans[i]))
			s += 1
	print(s)
	print(' '.join(os))


for i in range(int(input())):
	n = int(input())
	ans = [0]
	num = n
	while num >= 1:
		a = n // num
		ans.append(a)
		num = n // (a + 1)
	print(len(ans))
	print(' '.join(map(str, ans)))


t = int(input())
for i in ' ' * t:
	n = int(input())
	r = {0, 1, n}
	d = 2
	while d * d <= n:
		r.add(n // d)
		r.add(n // (n // d))
		d += 1
	print(len(r))
	print(*sorted(r))


import math
t = int(input())
for i in range(t):
	n = int(input())
	ansList = [int(i) for i in range(int(math.sqrt(n)))]
	ansCount = len(ansList)
	prevAns = ansList[-1]
	for j in range(math.ceil(math.sqrt(n)), 0, -1):
		ans = math.floor(n / j)
		if ans != prevAns:
			ansList.append(ans)
			ansCount += 1
		prevAns = ans
	print(ansCount)
	print(' '.join((str(i) for i in ansList)))


for i in range(int(input())):
	n = int(input())
	m = n + 1
	l = {0}
	while m >= 1:
		x = n // m
		m = n // (x + 1)
		l.add(x)
	l = sorted(l)
	print(len(l))
	print(*l)


def main():

	def solve():
		n = int(input())
		res = [n]
		v = n
		i = 1
		while v > 1:
			v = n // (i + 1)
			res.append(v)
			i = n // v
		res.append(0)
		print(len(res))
		print(' '.join(map(str, reversed(res))))
	q = int(input())
	for _ in range(q):
		solve()
main()


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		k = n
		a = [0]
		while True:
			if k == 0:
				break
			p = n // k
			a.append(p)
			l = 1
			r = k
			ans = -1
			while l <= r:
				m = (l + r) // 2
				if n // m == p:
					ans = m
					r = m - 1
				else:
					l = m + 1
			k = ans - 1
		print(len(a))
		print(*a)
	return
main()


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		k = 1
		a = []
		while True:
			p = n // k
			a.append(p)
			if p == 0:
				break
			k = n // p
			k += 1
		a.sort()
		print(len(a))
		print(*a)
	return
main()


t = int(input())
for _ in range(t):
	n = int(input())
	L = [i for i in range(int(n ** (1 / 2) + 1))] + [int(n / i) for i in range(1, int(n ** (1 / 2) + 1))]
	L = sorted(set(L))
	print(len(L))
	print(*L)


t = int(input())
for i in range(t):
	n = int(input())
	lst = [0]
	for j in range(1, n + 1):
		tmp = int(n // j)
		lst.append(tmp)
		if tmp * tmp <= n:
			for k in range(tmp + 2):
				if k * k <= n:
					lst.append(k)
			break
	lst = list(set(lst))
	lst.sort()
	lst = [str(i) for i in lst]
	print(len(lst))
	print(' '.join(lst))


import sys
input = sys.stdin.readline
from math import ceil, floor, factorial

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

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

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(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
MAXN = int(10000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

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

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	n = int(input())
	ans = {0}
	for i in range(1, int(n ** 0.5) + 1):
		ans.add(i)
		ans.add(n // i)
	ans = sorted(list(ans))
	print(len(ans))
	print(*ans)


for i in range(int(input())):
	n = int(input())
	s = set([0, n])
	for j in range(int(n ** 0.5)):
		s.add(n // (j + 1))
		s.add(j + 1)
	print(len(s))
	print(*sorted(s))


import math
t = int(input())
for _ in range(t):
	n = int(input())
	middle = math.floor(math.sqrt(n))
	res = [i for i in range(middle + 1)]
	for i in range(middle, 0, -1):
		if n // i > middle:
			res.append(n // i)
	print(len(res))
	print(' '.join(map(str, res)))


import math

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		c = int(math.sqrt(n)) + 10
		result = set()
		for i in range(1, c):
			result.add(n // i)
		c = n // (c - 1)
		for i in range(c):
			result.add(i)
		result = list(result)
		result.sort()
		print(len(result))
		print(' '.join([str(x) for x in result]))
main()


for qwertyuiop in range(int(input())):
	n = int(input())
	q = set()
	for i in range(1, 2 * int(n ** 0.5) + 7):
		q.add(n // i)
		q.add(n // (n // i + 1))
	q.add(0)
	print(len(q))
	print(*sorted(list(q)))


for i in range(int(input())):
	n = int(input())
	ans = set()
	ans.add(0)
	for i in range(1, int(n ** 0.5) + 1):
		ans.add(n // i)
		ans.add(i)
	print(len(ans))
	print(*sorted(ans))


t = int(input().strip())
for i in range(t):
	n = int(input().strip())
	result = ['0', '1']
	it = 1
	while it != n:
		it += 1
		m = n // it
		it = n // m
		result.append(str(it))
	print(len(result))
	print(' '.join(result))


from math import *
for tt in range(int(input())):
	n = int(input())
	v = [0]
	for i in range(1, int(sqrt(n)) + 1):
		v.append(i)
		v.append(n // i)
	st = set(v)
	ans = list(sorted(st))
	print(len(ans))
	print(*ans)


import sys
import math
t = int(input())
Ans = []
for _ in range(t):
	q = int(input())
	i = 1
	mySet = set()
	while i * i <= q:
		mySet.add(int(q / i))
		mySet.add(int(i))
		i += 1
	mySet.add(0)
	mySet = sorted(list(mySet))
	print(len(mySet))
	print(' '.join(map(str, mySet)))


for _ in range(int(input())):
	n = int(input())
	if n == 1:
		print(2)
		print(0, 1)
		continue
	d = [0, 1, n]
	from math import sqrt as S
	for i in range(2, int(S(n)) + 1):
		d.append(n // i)
	d1 = d[:]
	for x in d1:
		if x:
			d.append(n // x)
	d = list(set(d))
	print(len(d))
	print(*sorted(d))


for _ in range(0, int(input())):
	n = int(input())
	answers = [0]
	i = 1
	j = int(n ** (1 / 2))
	while i < j:
		answers.append(i)
		answers.append(n // i)
		i += 1
	answers.append(j)
	if n // j != j:
		answers.append(n // j)
	answers.sort()
	print(len(answers))
	print(*answers)


from functools import reduce
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

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

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

def sarr():
	return [i for i in input().split()]
t = int(input())
while t:
	t -= 1
	n = int(input())
	l = 1
	h = n - 1
	ans = [0, 1]
	res = int(sqrt(n))
	for i in range(1, res + 1):
		ans += [i]
		ans += [n // i]
	ans = list(set(ans))
	ans.sort()
	print(len(ans))
	print(*ans)


import math
t = int(input())
for i in range(t):
	n = int(input())
	l = []
	j = int(math.sqrt(n))
	count = 2 + 2 * (j - 1)
	if int(n / j) != j:
		count += 1
	print(count)
	print(0, end=' ')
	for i in range(1, j):
		print(i, end=' ')
	print(j, end=' ')
	if int(n / j) != j:
		print(int(n / j), end=' ')
	j = j - 1
	while j > 0:
		print(int(n / j), end=' ')
		j -= 1
	print()


import math

def solve(n):
	ans = set()
	ans.add(0)
	for i in range(1, int(math.sqrt(n) + 1)):
		ans.add(i)
		ans.add(n // i)
	return sorted(list(ans))
for _ in range(int(input())):
	n = int(input())
	ans = solve(n)
	print(len(ans))
	print(*ans)


t = int(input())
for i in range(0, t):
	n = int(input())
	ln = [0]
	oned = False
	sqt = n // int(n ** 0.5)
	on = -1
	for j in range(1, max(2, int(n ** 0.5) + 1)):
		if n // j != on:
			ln.append(n // j)
			if n // j == 1:
				oned = True
		on = n // j
	for j in range(len(ln) - 1, 0, -1):
		if n // ln[j] == sqt:
			continue
		ln.append(n // ln[j])
		if n // ln[j] == 1:
			oned = True
	if not oned:
		ln.append(1)
	print(len(ln))
	print(' '.join([str(j) for j in sorted(ln)]))


from math import *
t = int(input())
for _ in range(t):
	n = int(input())
	p = 1
	l = [0]
	c = 0
	if n == 1:
		print(2)
		print('%d %d' % (0, 1))
		continue
	s = int(sqrt(n)) + 1
	for i in range(1, s):
		l.append(i)
		l.append(n // i)
	l = list(set(l))
	l.sort()
	print(len(l))
	print(*l)


import math
t = int(input())
while t:
	t += -1
	n = int(input())
	ans = [0]
	for i in range(1, int(math.sqrt(n)) + 1):
		ans.append(i)
		ans.append(n // i)
	ans = list(set(ans))
	ans.sort()
	print(len(ans))
	print(*ans)


from math import sqrt
n = int(input())
for x in range(n):
	m = int(input())
	t_wyn = set([0, 1])
	for y in range(2, int(sqrt(m)) + 1, +1):
		t_wyn.add(y)
		t_wyn.add(int(m // y))
	t_wyn.add(m)
	l_t_wyn_1 = [y for y in t_wyn]
	l_t_wyn_1.sort()
	l_t_wyn = [str(y) for y in l_t_wyn_1]
	print(len(l_t_wyn))
	print(' '.join(l_t_wyn))


t = int(input())
for _ in range(t):
	n = int(input())
	a1 = [0]
	a2 = []
	for i in range(1, int(n ** 0.5) + 1):
		dd = n // i
		a1.append(i)
		a1.append(dd)
	a1 = list(set(a1))
	a1.sort()
	print(len(a1))
	print(*a1)


from sys import stdin

def input():
	return stdin.readline()[:-1]
for _ in range(int(input())):
	n = int(input())
	output = [n]
	while output[-1] != 1:
		(l, r) = (1, n)
		while l < r:
			mid = (l + r) // 2
			if n // mid < output[-1]:
				r = mid
			else:
				l = mid + 1
		output.append(n // l)
	output.append(0)
	print(len(output))
	print(' '.join(list(map(str, output[::-1]))))


t = int(input())
for I in range(t):
	n = int(input())
	a = set()
	for i in range(1, int(n ** 0.5) + 1):
		a.add(i)
		a.add(n // i)
	a.add(0)
	print(len(a))
	a = sorted(list(a))
	for i in a:
		print(i, end=' ')
	print()


from sys import stdin, stdout
input = stdin.readline
import math
t = int(input())
for _ in range(t):
	n = int(input())
	ans = set()
	for i in range(1, int(math.sqrt(n)) + 10):
		ans.add(n // i)
		ans.add(n // max(1, n // i))
		ans.add(n // (n // i + 1))
		ans.add(n // max(1, n // i - 1))
	print(len(ans))
	print(*sorted(ans))


for step in range(int(input())):
	n = int(input())
	left = [1]
	right = [n]
	i = 2
	while abs(left[-1] - right[-1]) > 1 and i <= n // 2 and (i <= n // i):
		left.append(i)
		right.append(n // i)
		i += 1
	Ans = '0 '
	if left[-1] - right[-1] == 0:
		print(1 + len(left) + len(right) - 1)
		for i in left:
			Ans += str(i) + ' '
		for i in reversed(range(len(right) - 1)):
			Ans += str(right[i]) + ' '
	else:
		print(1 + len(left) + len(right))
		for i in left:
			Ans += str(i) + ' '
		for i in reversed(right):
			Ans += str(i) + ' '
	print(Ans)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	x = int(math.sqrt(n))
	if n == 1:
		print(2)
		print(0, 1)
		continue
	ans = [0]
	i = 1
	m = 0
	while i <= x:
		p = n // i
		if p != m:
			m = p
			if i == m:
				ans.append(i)
			else:
				ans.append(m)
				ans.append(i)
		i += 1
	print(len(ans))
	ans.sort()
	print(*ans)


import math
t = int(input())
for j in range(t):
	n = int(input())
	s = math.sqrt(n)
	s = int(s) + 1
	ans = set()
	for i in range(1, s):
		ans.add(n // i)
		ans.add(i)
	if 1 not in ans:
		ans.add(1)
	if 0 not in ans:
		ans.add(0)
	ans = list(ans)
	ans.sort()
	print(len(ans))
	print(*ans)


import math
t = int(input())
for i in range(t):
	n = int(input())
	sq = math.sqrt(n)
	m = math.floor(sq)
	a = [0] * m
	for i in range(1, m + 1):
		a[-i] = n // i
	cnst = int(n // a[0] == a[0])
	b = [0] * (m - cnst)
	for i in range(len(b)):
		t = n // a[i + cnst]
		if t != a[i + cnst]:
			b[i] = t
	b.reverse()
	print(len(b) + len(a) + 1)
	print(*[0] + b + a)


t = int(input())
for _ in range(t):
	n = int(input())
	l = [0, n]
	k = 1
	ans = 1
	last = n
	while k < n:
		k += 1
		if n // k == last:
			k = n // last
		else:
			ans += 1
			last = n // k
			l.append(last)
	l.sort()
	print(len(l))
	print(*l)


for _ in range(int(input())):
	m = int(input())
	l = []
	l.append(0)
	for i in range(1, int(m ** 0.5) + 1):
		l.append(m // i)
		if m // i != i:
			l.append(i)
	l.sort()
	print(len(set(l)))
	print(*set(l))


from math import sqrt
for _ in range(int(input())):
	N = int(input())
	ans = set()
	ans.add(0)
	for i in range(1, int(sqrt(N)) + 3):
		p = N // i
		if p:
			ans.add(p)
			ans.add(N // p)
	print(len(ans))
	print(*sorted(ans))


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

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

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

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

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

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect
from collections import deque, defaultdict, OrderedDict
import collections

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		n = ri()
		a = [0]
		z = 1
		while True:
			if z * z > n:
				break
			a.append(z)
			a.append(n // z)
			z += 1
		a = set(a)
		print(len(a))
		print(*sorted(a))
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			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, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			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()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

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

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


for _ in range(int(input())):
	n = int(input())
	a = set()
	i = 1
	while i * i <= n:
		a.add(n // i)
		a.add(i)
		i += 1
	a.add(n)
	a.add(0)
	a = list(a)
	a.sort()
	print(len(a))
	print(*a)


import math
for _ in range(int(input())):
	n = int(input())
	s = set()
	if n == 1:
		print(2)
		print(0, 1)
	else:
		for i in range(1, int(math.sqrt(n)) + 1):
			s.add(n // i)
			s.add(i)
		s.add(0)
		s.add(1)
		print(len(s))
		s = sorted(list(s))
		print(*s)


from math import sqrt
t = int(input())
for _ in range(t):
	a = int(input())
	res = set([0, 1, a])
	k = 0
	for i in range(1, int(sqrt(a)) + 1):
		h = a // i
		res.add(i)
		res.add(h)
	print(len(res))
	print(*sorted(res))


for _ in range(int(input())):
	n = int(input())
	l1 = []
	a = n
	for i in range(1, int(n ** 0.5) + 1):
		a = n // i
		l1.append(a)
	if n == (int(n ** 0.5) + 1) ** 2 - 1:
		a -= 1
	while a:
		a -= 1
		l1.append(a)
	print(len(l1))
	l1.reverse()
	for i in l1:
		print(i, end=' ')
	print('')


from collections import defaultdict as dd
t = int(input())
for _ in range(t):
	n = int(input())
	l = [0]
	x = []
	for i in range(1, int(n ** 0.5) + 1):
		l += [i]
		if i != n // i:
			x += [n // i]
	x.reverse()
	l += x
	print(len(l))
	print(*l)


def solve():
	n = int(input())
	s = int(n ** 0.5)
	ans = {0}
	for i in range(1, s + 1):
		ans.add(i)
		ans.add(n // i)
	ans.add(n)
	print(len(ans))
	print(' '.join([str(el) for el in sorted(ans)]))
for _ in range(int(input())):
	solve()


from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import sys
t = int(input())
for _ in range(t):
	n = int(input())
	ans = [1, 0]
	for i in range(1, int(sqrt(n) + 1)):
		ans.append(n // i)
		ans.append(n // (n // i))
	ans = list(set(ans))
	print(len(ans))
	ans.sort()
	print(*ans)


import math
import time
t = int(input())
t1 = time.time()
for i in range(t):
	m = int(input())
	last = 0
	mods = [0]
	c = 1
	for j in range(1, math.ceil(math.sqrt(m))):
		v = m // j
		if last != v:
			mods.append(v)
			if v != m // v:
				mods.append(m // v)
	if math.sqrt(m).is_integer():
		mods.append(int(math.sqrt(m)))
	print(len(mods))
	mods.sort()
	print(*mods)