Let's denote a m-free matrix as a binary (that is, consisting of only 1's and 0's) matrix such that every square submatrix of size m × m of this matrix contains at least one zero. 

Consider the following problem:

You are given two integers n and m. You have to construct an m-free square matrix of size n × n such that the number of 1's in this matrix is maximum possible. Print the maximum possible number of 1's in such matrix.

You don't have to solve this problem. Instead, you have to construct a few tests for it.

You will be given t numbers x_1, x_2, ..., x_{t}. For every $i \in [ 1, t ]$, find two integers n_{i} and m_{i} (n_{i} ≥ m_{i}) such that the answer for the aforementioned problem is exactly x_{i} if we set n = n_{i} and m = m_{i}.


-----Input-----

The first line contains one integer t (1 ≤ t ≤ 100) — the number of tests you have to construct.

Then t lines follow, i-th line containing one integer x_{i} (0 ≤ x_{i} ≤ 10^9).

Note that in hacks you have to set t = 1.


-----Output-----

For each test you have to construct, output two positive numbers n_{i} and m_{i} (1 ≤ m_{i} ≤ n_{i} ≤ 10^9) such that the maximum number of 1's in a m_{i}-free n_{i} × n_{i} matrix is exactly x_{i}. If there are multiple solutions, you may output any of them; and if this is impossible to construct a test, output a single integer  - 1. 


-----Example-----
Input
3
21
0
1

Output
5 2
1 1
-1

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Complete search

Sorting

Constructive algorithms


Solutions:
import atexit
import io
import math
import sys
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

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

def main():
	t = int(input())
	for _ in range(t):
		x = int(input())
		if x == 0:
			print(1, 1)
			continue
		n = math.ceil(x ** 0.5)
		while True:
			if n * n - (n // 2) ** 2 > x:
				print(-1)
				break
			t = math.floor((n * n - x) ** 0.5)
			if t > 0 and t * t == n * n - x:
				m = n // t
				if t == n // m:
					print(n, m)
					break
			n += 1
main()


import math
t = int(input())
for rr in range(t):
	oc = int(input())
	fl = False
	if oc != 0:
		for i in range(2, 40000):
			sq1 = i
			v1 = sq1 * sq1 - oc
			if v1 > 0 and int(math.sqrt(v1)) ** 2 == v1:
				sv1 = int(math.sqrt(v1))
				l = 2
				r = sq1
				while r - l > 1:
					mid = int((l + r) / 2)
					vc = int(sq1 / mid)
					if sq1 * sq1 - vc * vc > oc:
						r = mid - 1
					else:
						l = mid
				cr = int(sq1 / r)
				cl = int(sq1 / l)
				if sq1 * sq1 - cr * cr == oc and r <= sq1:
					fl = True
					st = str(sq1) + ' ' + str(r)
					print(st)
					break
				elif sq1 * sq1 - cl * cl == oc and l <= sq1:
					fl = True
					st = str(sq1) + ' ' + str(l)
					print(st)
					break
	if not fl:
		if oc == 0:
			print('1 1')
		else:
			print(-1)


import sys
import math
lines = sys.stdin.read().splitlines()
lincnt = -1

def input():
	global lincnt
	lincnt += 1
	return lines[lincnt]

def solve():
	x = int(input())
	for n in range(max(1, int(math.sqrt(x) - 5)), int(10 ** 4.7)):
		if n ** 2 <= x:
			continue
		m = math.sqrt(n ** 2 / (n ** 2 - x))
		for k in range(int(m) - 3, int(m) + 3):
			if k < 1:
				continue
			if n ** 2 - (n // k) ** 2 == x:
				print(n, k)
				return
	print(-1)
for _ in range(int(input())):
	solve()


from math import *

def get(x):
	if x == 0:
		print(1, 1)
		return
	i = 1
	while i * i <= x:
		if not x % i:
			(a, b) = (int(x / i), i)
			if not (a + b) % 2:
				n = int((a + b) / 2)
				n_m = int((a - b) / 2)
				if n_m:
					m = int(n / n_m)
					if int(n / m) == n_m and m <= n:
						print(n, m)
						return
		i += 1
	print(-1)
	return
n = int(input())
for i in range(n):
	get(int(input()))


from math import sqrt

def check(ans, a):
	b = ans // a
	if (a + b) % 2:
		return False
	n = (a + b) // 2
	d = b - n
	if 1 <= d and d <= n:
		m = max(1, n // d - 1)
		for i in range(3):
			if n // m == d:
				print(n, m)
				return True
			m += 1
	else:
		return False

def main():
	T = int(input())
	while T:
		T -= 1
		ans = int(input())
		if ans == 0:
			print(1, 1)
			continue
		for i in range(1, int(sqrt(ans)) + 1):
			if ans % i == 0 and check(ans, i):
				break
		else:
			print(-1)
main()


n = int(input())
for x in range(n):
	x = int(input())
	if x == 0:
		print(1, 1)
	else:
		flag = True
		for d in range(1, int(x ** 0.5) + 1):
			if x % d == 0:
				s = x // d
				n = (s + d) // 2
				if int(n) != n:
					continue
				nm = s - n
				if nm <= 0:
					continue
				m = n // nm
				if m > 0 and n ** 2 - (n // m) ** 2 == x:
					print(n, m)
					flag = False
					break
		if flag:
			print(-1)


from math import *

def calcul(xi):
	n = int(sqrt(xi)) + 1
	n2 = n ** 2
	while n2 <= 2 * xi and n <= 1000000000:
		nsm2 = n2 - xi
		nsm = sqrt(nsm2)
		if nsm == int(nsm):
			m = n // nsm
			if n2 - (n // m) ** 2 == xi:
				return (n, int(m))
		n += 1
		n2 = n ** 2
	return (-1, -1)
t = int(input())
for _ in range(t):
	xi = int(input())
	if xi == 0:
		print('1 1')
		continue
	(n, m) = calcul(xi)
	if m == -1:
		print(-1)
	else:
		print(n, m)


from math import ceil
t = int(input())
for _ in range(t):
	x = int(input())
	if x == 1 or x % 4 == 2:
		print(-1)
	elif x == 0:
		print(1, 1)
	else:
		z = 0
		for i in range(ceil((x / 3) ** 0.5), ceil(x ** 0.5)):
			if x % i == 0 and (x // i - i) % 2 == 0:
				n = (i + x // i) // 2
				k = (x // i - i) // 2
				m = n // k
				if n // m == k:
					print(n, m)
					z = 1
					break
		if z == 0:
			print(-1)


import math
t = int(input())
for _ in range(t):
	x = int(input())
	found = False
	for n in range(int(math.sqrt(x)) + 1, int(10 ** 4.6)):
		m = n / math.sqrt(n ** 2 - x)
		m1 = math.ceil(m)
		m2 = math.floor(m)
		for m in [m1, m2]:
			if n ** 2 - (n // m) ** 2 == x:
				print(n, m)
				found = True
				break
		if found:
			break
	if not found:
		print(-1)


from math import sqrt, ceil

def func(x):
	a = int(ceil(sqrt(x)))
	b = int(ceil(sqrt(2 * x)))
	for n in range(a, b + 1):
		if n == 0:
			return (1, 1)
		temp = sqrt(n ** 2 - x)
		if temp % 1 != 0 or temp == 0:
			pass
		else:
			m = int(n / temp)
			if int(n / m) == int(temp):
				return (n, m)
	return (-1, -1)
t = int(input())
for i in range(t):
	x = int(input())
	(n, m) = func(x)
	if n == -1:
		print(-1)
	else:
		print(n, m)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
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 _ in range(t):
	suc = False
	x = int(input())
	for n in range(int(x ** 0.5) + 1, int((4 * x / 3) ** 0.5) + 2):
		if int((n ** 2 - x) ** 0.5) ** 2 == n ** 2 - x:
			mm = int((n ** 2 - x) ** 0.5)
			m = math.floor(n / mm)
			if n ** 2 - (n // m) ** 2 == x:
				print(n, m)
				suc = True
				break
	if not suc:
		print(-1)


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
from collections import defaultdict
threading.stack_size(10 ** 8)
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
sys.setrecursionlimit(300000)
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')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=2 ** 51, func=lambda a, b: a & b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] < key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] >= k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater
for ik in range(int(input())):
	n = int(input())
	f = 0
	for i in range(int(math.sqrt(n)), 100000):
		w = i * i - n
		if w < 0:
			continue
		sq = int(math.sqrt(w))
		if sq * sq == w:
			tr = sq
			j = -1
			st = 1
			end = i
			while st <= end:
				mid = (st + end) // 2
				if i // mid == tr:
					j = mid
					break
				elif i // mid < tr:
					end = mid - 1
				else:
					st = mid + 1
			if j != -1:
				print(i, j)
				f = 1
				break
	if f == 0:
		print(-1)


import math
import sys

def main():
	t = int(input())
	for i in range(t):
		ones = int(input())
		if ones == 0:
			print('1 1')
			continue
		gotem = False
		for j in range(1, ones):
			if j * j > ones:
				break
			if ones % j == 0:
				big = ones // j
				if (j + big) % 2 != 0:
					continue
				else:
					a = (j + big) // 2
					b = big - a
					if b <= 0:
						continue
					n = a
					m = n // b
					if n // m != b or n < 1 or m < 1:
						continue
					print('%d %d' % (n, m))
					gotem = True
					break
		if not gotem:
			print(-1)
main()


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

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

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

def inpl_1():
	return list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))

def inps():
	return sys.stdin.readline()

def inpsl(x):
	tmp = sys.stdin.readline()
	return list(tmp[:x])

def err(x):
	print(x)
	exit()
for _ in range(inp()):
	X = inp()
	if X == 0:
		print(1, 1)
		continue
	elif X == 1:
		print(-1)
		continue
	res = -1
	for n in range(2, 5 * 10 ** 4):
		k2 = n ** 2 - X
		if k2 <= 0:
			continue
		k = math.sqrt(k2)
		if k >= 1 and k.is_integer():
			k = int(k)
			M = n // k
			for m in range(M - 3, M + 3):
				if m >= 1 and n // m == k:
					res = [n, m]
					break
		if res != -1:
			break
	if res == -1:
		print(-1)
	else:
		print(*res)


def test(x):
	i = 1
	flag = False
	while i ** 2 < x:
		if x % i == 0:
			(a, b) = (i, x // i)
			if (a + b) % 2 == 0:
				z = (a + b) // 2
				y = b - z
				u = z // y
				if z // u == y:
					y = u
					flag = True
					break
		i += 1
	if flag:
		print(str(z) + ' ' + str(y))
	elif x == 0:
		print('1 1')
	else:
		print('-1')
n = int(input())
for j in range(n):
	test(int(input()))


import sys
square = dict()
max_n = 45000
for i in range(1, max_n):
	square[i * i] = i
t = int(sys.stdin.buffer.readline().decode('utf-8'))
ans = ['-1'] * t
for i in range(t):
	x = int(sys.stdin.buffer.readline().decode('utf-8'))
	if x == 1:
		continue
	for ni in range(1, max_n):
		y = ni ** 2 - x
		if y in square and ni ** 2 - (ni // (ni // square[y])) ** 2 == x:
			ans[i] = f'{ni} {ni // square[y]}'
			break
sys.stdout.buffer.write('\n'.join(ans).encode('utf-8'))


t = int(input())
for k in range(t):
	x = int(input())
	if x == 0:
		print(1, 1)
		continue
	for i in range(1, int(x ** 0.5) + 2):
		if x % i == 0 and (x // i - i) % 2 == 0 and ((x // i - (x // i - i) // 2) ** 2 >= x):
			(a, b) = (x // i, i)
			y = (a - b) // 2
			n = a - y
			if y == 0:
				continue
			m = n // y
			if n // m != y:
				continue
			print(n, m)
			break
	else:
		print(-1)


import time
import itertools
import math
x = 10 ** 9 + 2

def find_factor(x):
	k = int(math.ceil(math.sqrt(x)))
	if x // k == k:
		k -= 1
	for i in range(k, 2, -1):
		if not x % i:
			yield i
	yield 1

def find_factor_div2(x):
	k = int(math.ceil(math.sqrt(x)) // 2 * 2)
	if x // k == k:
		k -= 2
	for i in range(k, 1, -2):
		if not x % i and (not x // i % 2):
			yield i
	return 0

def _sol_kMn_kPn_for_x(x):
	if x % 4 == 0:
		f = find_factor_div2(x)
		if f:
			for k in f:
				yield (k, x / k)
		return 0
	if x % 2 == 0:
		return 0
	f = find_factor(x)
	if f:
		for k in f:
			yield (k, x / k)
	return 0

def sol_k_n_for_x(x):
	if x < 4:
		if x == 3:
			yield (1, 2)
		elif x == 0:
			yield (1, 1)
		else:
			return 0
		return
	k_n = _sol_kMn_kPn_for_x(x)
	if not k_n:
		return 0
	for (_k, _n) in k_n:
		(n, k) = ((_n - _k) // 2, (_k + _n) // 2)
		yield (n, k)

def sol_m_n(x):
	if x == 0:
		return (1, 1)
	kn = sol_k_n_for_x(x)
	if not kn:
		return (-1, -1)
	for (k, n) in kn:
		l = math.ceil((n + 1) / (k + 1))
		r = math.floor(n / k)
		if l <= r:
			return (r, n)
	return (-1, -1)

def __starting_point():
	n = int(input())
	for i in range(n):
		q = int(input())
		(m, n) = sol_m_n(q)
		if m == -1:
			print(-1)
		else:
			print(int(n), int(m))
__starting_point()


import sys, math, queue, bisect
MOD = 10 ** 9 + 7
sys.setrecursionlimit(1000000)
N = 50000
for _ in range(int(input())):
	x = int(input())
	found = None
	for i in range(1, N):
		if i * i - x <= 0:
			continue
		(low, high) = (1, N - 1)
		while low <= high:
			mid = low + high >> 1
			lhs = i * i - i // mid * (i // mid)
			if lhs == x:
				found = (i, mid)
				break
			elif lhs < x:
				low = mid + 1
			else:
				high = mid - 1
		if found is not None:
			break
	if found is None:
		print(-1)
	else:
		print(*found)


import math

def div(k):
	res = []
	for i in range(1, int(math.sqrt(k)) + 2):
		if k % i == 0:
			res.append(i)
	return res
t = int(input())
for i in range(t):
	x = int(input())
	if x == 0:
		print('1 1')
	elif x == 1:
		print(-1)
	else:
		flag = False
		di = div(x)
		for d in di:
			a = x // d
			if (a + d) % 2 == 0 and a > d:
				n = (a + d) // 2
				lower = (a + d) / (a - d + 2)
				upper = (a + d) / (a - d)
				if int(lower) < int(upper):
					m = int(upper)
					res = [n, m]
					flag = True
					break
		if flag == True:
			print(' '.join(map(str, res)))
		else:
			print(-1)


def main():
	t = int(input())
	for _ in range(t):
		num = int(input())
		if num == 0:
			print(1, 1)
		else:
			ok = False
			div = 1
			while div * div <= num:
				if num % div == 0:
					add = max(num // div, div)
					sub = min(num // div, div)
					if (add + sub) % 2 == 0:
						n = (add + sub) // 2
						num_zeros = (add - sub) // 2
						if num_zeros != 0:
							k = n // num_zeros
							if n ** 2 - (n // k) ** 2 == num:
								ok = True
								break
				div += 1
			if ok:
				print(n, k)
			else:
				print(-1)

def __starting_point():
	main()
__starting_point()


import math

def nextsquare(x):
	y = int(math.sqrt(x))
	return (y + 1) * (y + 1)
a = input()
for i in range(int(a)):
	k = int(input())
	j = nextsquare(k)
	answer1 = -1
	answer2 = 0
	while j <= 4 * k / 3 + 1:
		l = j - k
		if not l == 0:
			if int(math.sqrt(l)) * int(math.sqrt(l)) == l:
				n = int(math.sqrt(j))
				m = int(math.sqrt(l))
				r = n % m
				m1 = (n - r) / m
				if r < m1:
					answer1 = n
					answer2 = int(m1)
		j = nextsquare(j)
	if answer1 == -1:
		print(answer1)
	else:
		print(answer1, answer2)


from math import sqrt
t = int(input())
for _ in range(t):
	n = int(input())
	if n == 0:
		print(1, 1)
		continue
	sq = int(sqrt(n)) + 1
	while sq * sq <= 2 * n:
		zs = sqrt(sq * sq - n)
		if zs.is_integer():
			m = sq // zs
			if sq * sq - (sq // m) ** 2 == n:
				print(sq, int(m))
				break
		sq += 1
	else:
		print(-1)


import math
t = int(input())
for _ in range(t):
	suc = False
	x = int(input())
	for n in range(int(x ** 0.5) + 1, int((4 * x / 3) ** 0.5) + 2):
		if int((n ** 2 - x) ** 0.5) ** 2 == n ** 2 - x:
			mm = int((n ** 2 - x) ** 0.5)
			m = math.floor(n / mm)
			if n ** 2 - (n // m) ** 2 == x:
				print(n, m)
				suc = True
				break
	if not suc:
		print(-1)