You are given two integers $n$ and $k$. Your task is to find if $n$ can be represented as a sum of $k$ distinct positive odd (not divisible by $2$) integers or not.

You have to answer $t$ independent test cases.


-----Input-----

The first line of the input contains one integer $t$ ($1 \le t \le 10^5$) — the number of test cases.

The next $t$ lines describe test cases. The only line of the test case contains two integers $n$ and $k$ ($1 \le n, k \le 10^7$).


-----Output-----

For each test case, print the answer — "YES" (without quotes) if $n$ can be represented as a sum of $k$ distinct positive odd (not divisible by $2$) integers and "NO" otherwise.


-----Example-----
Input
6
3 1
4 2
10 3
10 2
16 4
16 5

Output
YES
YES
NO
YES
YES
NO



-----Note-----

In the first test case, you can represent $3$ as $3$.

In the second test case, the only way to represent $4$ is $1+3$.

In the third test case, you cannot represent $10$ as the sum of three distinct positive odd integers.

In the fourth test case, you can represent $10$ as $3+7$, for example.

In the fifth test case, you can represent $16$ as $1+3+5+7$.

In the sixth test case, you cannot represent $16$ as the sum of five distinct positive odd integers.

Difficulty: EASY

Solutions:
import os
import sys
from io import BytesIO, IOBase

def main():
	pass
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')
main()
from math import *
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	if k > sqrt(n):
		print('NO')
	elif n % 2 == 0 and k % 2 == 0:
		print('YES')
	elif n % 2 == 1 and k % 2 == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	if n % 2 != k % 2:
		print('NO')
	elif k * k > n:
		print('NO')
	else:
		print('YES')


def calc(n, k):
	if n % 2 == 0 and k % 2 != 0:
		return 'NO'
	elif n % 2 != 0 and k % 2 == 0:
		return 'NO'
	elif n % 2 == 0:
		if k ** 2 <= n:
			return 'YES'
		else:
			return 'NO'
	elif n % 2 != 0:
		if k ** 2 <= n:
			return 'YES'
		else:
			return 'NO'
for _ in range(int(input())):
	(n, k) = list((int(i) for i in input().split()))
	print(calc(n, k))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	if k ** 2 > n:
		print('NO')
	elif n % 2 == 0:
		if k % 2 == 0 and k <= n:
			print('YES')
		else:
			print('NO')
	elif k % 2 == 0 or k > n:
		print('NO')
	else:
		print('YES')


t = int(input())
for case in range(t):
	(n, k) = (int(i) for i in input().split())
	if k ** 2 > n or k % 2 != n % 2:
		print('NO')
	else:
		print('YES')


def solve():
	(n, k) = map(int, input().split())
	if n - k * k >= 0 and (n - k * k) % 2 == 0:
		print('YES')
	else:
		print('NO')
t = int(input())
for i in range(t):
	solve()


from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
from collections import defaultdict as dd, deque

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

def mdata():
	return map(int, data().split())
for i in range(int(data())):
	(n, k) = mdata()
	if k ** 2 > n:
		print('NO')
	elif (n + k) % 2 != 0:
		print('NO')
	else:
		print('YES')


x = int(input())
for i in range(x):
	(n, k) = map(int, input().split(' '))
	if n % 2 != k % 2:
		print('NO')
	elif k * k > n:
		print('NO')
	else:
		print('YES')


import sys

def fastio():
	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()
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(t,) = I()
while t:
	t -= 1
	(n, k) = I()
	ans = 'YES'
	ok = k ** 2
	if n - ok < 0 or (n - ok) % 2:
		ans = 'NO'
	print(ans)


import math
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if n % 2 == 0 and k % 2 == 1:
		print('NO')
	elif n % 2 == 1 and k % 2 == 0:
		print('NO')
	elif n % 2 == 0 and k % 2 == 0 and (k <= math.sqrt(n)):
		print('YES')
	elif n % 2 == 1 and k % 2 == 1 and (k <= math.sqrt(n)):
		print('YES')
	else:
		print('NO')


t = int(input())
for case in range(t):
	(n, k) = list(map(int, input().split()))
	sum_k = k * k
	if n % 2 == sum_k % 2 and n >= sum_k:
		print('YES')
	else:
		print('NO')


t = int(input())
l = []
for i in range(t):
	(n, k) = map(int, input().split())
	if n % 2 == k % 2:
		c = k * 2 // 2 * (k * 2 + 1)
		s = (c - k) // 2
		if n >= s:
			if (n - s) % 2 == 0:
				l.append('YES')
			else:
				l.append('NO')
		else:
			l.append('NO')
	else:
		l.append('NO')
for i in l:
	print(i)


t = int(input())
for testcases in range(t):
	(n, k) = map(int, input().split())
	if n % 2 != k % 2 or k * k > n:
		print('NO')
	else:
		print('YES')


import sys
t = int(input())
for i in range(t):
	(n, k) = tuple(map(int, input().split()))
	if n % 2 == 0 and k % 2 == 0:
		if n >= k ** 2:
			print('YES')
			continue
		else:
			print('NO')
			continue
	if n % 2 == 0 and k % 2 != 0:
		print('NO')
		continue
	if n % 2 != 0 and k % 2 == 0:
		print('NO')
		continue
	if n % 2 != 0 and k % 2 != 0:
		if n >= k ** 2:
			print('YES')
			continue
		else:
			print('NO')
			continue
sys.exit(0)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if n % 2 == 0 and k % 2 == 0 and (k ** 2 <= n):
		print('YES')
	elif n % 2 != 0 and k % 2 != 0 and (k ** 2 <= n):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(1, t + 1):
	(n, k) = list(map(int, input().split()))
	if (n + k) % 2 != 0:
		print('NO')
	else:
		if k ** 2 <= n:
			print('YES')
		if k ** 2 > n:
			print('NO')


n = int(input())
x = 0
while x < n:
	(a, b) = map(int, input().split())
	a1 = a % 2
	b1 = b % 2
	if a1 == b1 and a >= b * b:
		print('YES')
	else:
		print('NO')
	x += 1


def main():
	t = int(input())
	while t:
		(n, k) = map(int, input().split())
		if k ** 2 > n or k % 2 != n % 2:
			print('NO')
		else:
			print('YES')
		t -= 1
main()


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	if m * m <= n and n % 2 == m % 2:
		print('YES')
	else:
		print('NO')


from math import log2
for _ in int(input()) * [0]:
	(n, k) = map(int, input().split())
	if n - k < 0 or (n - k) % 2 == 1:
		print('NO')
	elif (n - k) // 2 >= k * (k - 1) // 2:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	print('NO' if n < k * k or (n - k) % 2 else 'YES')


for i in range(int(input())):
	(n, k) = map(int, input().rstrip().split())
	print('YES' if k * k <= n and n % 2 == k % 2 else 'NO')


for i in range(int(input())):
	(n, k) = map(int, input().split())
	value = n - (k - 1) ** 2
	p = 2 * k - 1
	if value >= p and value % 2 == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b) = input().strip().split(' ')
	(a, b) = [int(a), int(b)]
	if a % 2 == 0:
		if b % 2:
			print('NO')
		elif a >= b * b:
			print('YES')
		else:
			print('NO')
	elif a % 2:
		if b % 2 == 0:
			print('NO')
		elif a >= b * b:
			print('YES')
		else:
			print('NO')


def main():
	t = int(input().strip())
	for i in range(t):
		(n, k) = input().strip().split(' ')
		(n, k) = (int(n), int(k))
		print('YES') if n >= k * k and n % 2 == k % 2 else print('NO')
main()


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	if n % 2 == 0 and k % 2 != 0:
		print('NO')
	elif n % 2 != 0 and k % 2 == 0:
		print('NO')
	else:
		sum1 = k * (2 + (k - 1) * 2) // 2
		if sum1 > n:
			print('NO')
		else:
			print('YES')


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if k == 1:
		if n % 2 == 0:
			print('NO')
		else:
			print('YES')
	else:
		a = n - k
		if a % 2 != 0:
			print('NO')
		else:
			v = a // 2
			s = (k - 1) * k // 2
			if s > v:
				print('NO')
			else:
				print('YES')


t = int(input())
for _ in range(t):
	nk = input().split(' ')
	n = int(nk[0])
	k = int(nk[1])
	if n % 2 != k % 2:
		print('NO')
	elif k ** 2 > n:
		print('NO')
	else:
		print('YES')


import sys
r = sys.stdin.readlines()
n = int(r[0])
s = []
for i in range(1, 1 + n):
	(a, b) = r[i].split()
	a = int(a)
	b = int(b)
	if (a + b) % 2 == 0 and b * b <= a:
		s.append('YES')
	else:
		s.append('NO')
sys.stdout.write('\n'.join(s))


for i in range(int(input())):
	(a, n) = map(int, input().split())
	if a % 2 != 0:
		if n % 2 != 0:
			if n * (1 + (n - 1)) > a:
				print('NO')
			else:
				print('YES')
		else:
			print('NO')
	elif n % 2 == 0:
		if n * (1 + (n - 1)) > a:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if b <= a // b and a % 2 == b % 2:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(n, k) = map(int, input().split())
	if n % 2 == 0 and k % 2 == 0 or (n % 2 != 0 and k % 2 != 0):
		x = n - k ** 2
		a = 1 + (k - 2) * 2
		if x >= 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


n = int(input())
for i in range(n):
	arr = list(map(int, input().split()))
	n = arr[0]
	k = arr[1]
	x = n - k * k
	if x % 2 == 0 and x / 2 >= 0:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	if n % 2 != k % 2 or k * k > n:
		print('NO')
	else:
		print('YES')


t = int(input())
while t > 0:
	inp = list(map(int, input().split()))
	n = inp[0]
	k = inp[1]
	if n % 2 == k % 2 and n >= k * k:
		print('YES')
	else:
		print('NO')
	t -= 1


import math
t = int(input())
while t:
	t -= 1
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	if n % 2 == 0 and k % 2 == 0 or (n % 2 != 0 and k % 2 != 0):
		end = (k - 1) * 2 - 1
		odd = end * (end + 1) / 2
		even = (k - 1) * (k - 2)
		if even > 0:
			odd -= even
		x = n - odd
		if x > 0 and x % 2 != 0 and (x > end):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import math, collections, sys
input = sys.stdin.readline

def solve():
	(n, k) = map(int, input().split())
	if n % 2 != k % 2:
		print('NO')
		return
	if k <= n ** 0.5:
		print('YES')
	else:
		print('NO')
for _ in range(int(input())):
	solve()


n = int(input())
for i in range(n):
	linie = input()
	n = int(linie.split()[0])
	k = int(linie.split()[1])
	if k ** 2 <= n and n % 2 == k % 2:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if k & 1 == n & 1 and n >= k * k:
		print('YES')
	else:
		print('NO')


d = int(input())
for i in range(d):
	(a, b) = map(int, input().split())
	if a % 2 == 0 and b % 2 != 0:
		print('NO')
	elif a % 2 == 0 and b % 2 == 0:
		if b * b <= a:
			print('YES')
		else:
			print('NO')
	elif a % 2 != 0 and b % 2 == 0:
		print('NO')
	elif b * b <= a:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	a = input().split()
	c = int(a[0])
	b = int(a[1])
	flag = True
	if c % 2 + b % 2 == 1:
		flag = False
	d = pow(b, 2)
	if c < d:
		flag = False
	if flag:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(num, n) = map(int, input().split())
	if num < n * n:
		print('NO')
	elif num % 2 != n % 2:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	l = (k - 1) * (k - 1)
	p = n - l
	if p > 0 and p % 2 == 1 and (p > 2 * k - 3):
		print('YES')
	else:
		print('NO')


def summ(n):
	return n * n
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n < summ(k):
		print('NO')
	elif (n - summ(k)) % 2 == 0:
		print('YES')
	else:
		print('NO')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
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 main():
	t = I()
	rr = []
	for _ in range(t):
		(n, k) = LI()
		nk = n - k * 2 * k // 2
		if nk % 2 == 0 and nk >= 0:
			rr.append('YES')
		else:
			rr.append('NO')
	return JA(rr, '\n')
print(main())


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 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))
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 p in range(t):
		solve()

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

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

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

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():
	(n, k) = sep()
	if k % 2 != n % 2:
		print('NO')
		return
	n -= (k - 1) ** 2
	if n >= 2 * k - 1:
		print('YES')
	else:
		print('NO')
testcase(int(inp()))


import sys

def read_strings():
	return list(sys.stdin.readline().split())

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

def read_multiline_ints():
	return list(map(int, ' '.join(sys.stdin.readlines()).split()))

def convert_2d(L, cols):
	return [L[k:k + cols] for k in range(0, len(L), 2)]
(yes, no) = ('YES', 'NO')
(t,) = read_inline_ints()
tests = read_multiline_ints()
tests = convert_2d(tests, 2)

def representable(n, k):
	if not n % 2 == k % 2:
		return no
	if n < k * k:
		return no
	return yes
for (n, k) in tests:
	print(representable(n, k))


c = int(input())
res = ''
for _ in range(c):
	(n, k) = [int(x) for x in input().split()]
	if (n + k) % 2 == 0:
		if n / k >= k:
			res += 'YES\n'
		else:
			res += 'NO\n'
	else:
		res += 'NO\n'
print('\n' + res)


n = int(input())
while n:
	(m, q) = input().split()
	m = int(m)
	q = int(q)
	if q * q <= m:
		if m % 2 == 0 and q % 2 == 0:
			print('YES')
		elif m % 2 != 0 and q % 2 != 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
	n -= 1


for _ in ' ' * int(input()):
	(a, b) = map(int, input().split())
	if a & 1 == b & 1 and a >= b ** 2:
		print('YES')
	else:
		print('NO')


T = int(input())
while T:
	(n, k) = map(int, input().split())
	if (n + k) % 2 == 0 and k <= n ** 0.5:
		print('YES')
	else:
		print('NO')
	T = T - 1


from sys import stdin, stdout
import math
import heapq
t = 1

def aint():
	return int(input().strip())

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

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

def main():
	(n, k) = lint()
	if k % 2 == n % 2 and n >= k * k:
		print('YES')
	else:
		print('NO')
t = int(input())
for i in range(t):
	main()


def solve():
	(n, k) = (int(i) for i in input().split())
	if not (n - k * k >= 0 and (n - k * k) % 2 == 0):
		print('NO')
		return
	if n % 2 == 0:
		if k % 2 == 0:
			print('YES')
		else:
			print('NO')
	elif k % 2 != 0:
		print('YES')
	else:
		print('NO')
t = int(input())
for _ in range(t):
	solve()


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a % 2 != b % 2:
		print('NO')
		continue
	print('YES' if a >= b * (b + 1) - b else 'NO')


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
import random
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
from collections import defaultdict
from heapq import heappop, heappush, heapify
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	z = b * (2 * 1 + (b - 1) * 2)
	z //= 2
	if b % 2 == a % 2:
		if z <= a:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
list_ = []
for i in range(t):
	a = input().split(' ')
	a = list(map(int, a))
	list_.append(a)
for l in list_:
	if l[0] == 0:
		print('NO')
		continue
	if l[0] < l[1]:
		print('NO')
		continue
	if (l[0] - l[1]) % 2 == 0 and (l[0] - l[1]) / 2 >= l[1] * (l[1] - 1) / 2:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, k) = [int(n) for n in input().split()]
	if n % 2 == 0 and k % 2 == 1 or (n % 2 == 1 and k % 2 == 0):
		print('NO')
	elif n >= k * k:
		print('YES')
	else:
		print('NO')


line = int(input())
for i in range(line):
	(astr, bstr) = input().split()
	a = int(astr)
	b = int(bstr)
	minimum = b * b
	if a < minimum:
		print('NO')
		continue
	elif a % 2 != b % 2:
		print('NO')
	else:
		print('YES')


T = int(input())
for xx in range(T):
	(n, k) = map(int, input().split())
	if k == 1:
		if n % 2 == 1:
			print('YES')
		else:
			print('NO')
		continue
	if n < k ** 2:
		print('NO')
		continue
	if n % 2 == 0:
		if k % 2 == 1:
			print('NO')
		else:
			print('YES')
	elif k % 2 == 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	if n % 2 == m % 2 and n >= m * m:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if n % 2 != k % 2:
		print('NO')
	elif k ** 2 > n:
		print('NO')
	else:
		print('YES')


def solve(n, k):
	if k * k <= n and (n + k) % 2 == 0:
		print('YES')
	else:
		print('NO')
t = int(input())
for i in range(0, t):
	inp = [int(x) for x in input().split()]
	solve(inp[0], inp[1])


n = int(input())
for i in range(n):
	s = input().split(' ')
	a = int(s[0])
	b = int(s[1])
	if a % 2 == b % 2 and b ** 2 <= a:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	(k, n) = (int(x) for x in input().split())
	if n & 1 != k & 1:
		print('NO')
		t = t - 1
		continue
	n = n * n
	if n > k:
		print('NO')
	elif k - n & 1:
		print('NO')
	else:
		print('YES')
	t = t - 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	temp = n
	tw = int(n ** (1 / 2))
	if n % 2 == 1 and k % 2 == 1 and (k < tw + 1):
		print('YES')
	elif n % 2 == 0 and k % 2 == 0 and (k < tw + 1):
		print('YES')
	else:
		print('NO')


s = int(input())
for i in range(0, s):
	a = input().split()
	if int(a[0]) % 2 != 0 and int(a[1]) % 2 == 0 or (int(a[0]) % 2 == 0 and int(a[1]) % 2 != 0):
		print('NO')
	else:
		su = int(a[1]) ** 2
		if su > int(a[0]):
			print('NO')
		else:
			print('YES')


import os
import sys
debug = True
if debug and os.path.exists('input.in'):
	input = open('input.in', 'r').readline
else:
	debug = False
	input = sys.stdin.readline

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

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

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

def invr():
	return map(int, input().split())
test_count = int(input())
for t in range(test_count):
	if debug:
		print('Test Case #', t + 1)
	(n, k) = invr()
	if n >= k * k and n % 2 == k % 2:
		print('YES')
	else:
		print('NO')


import sys, math
input = sys.stdin.readline

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

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

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

def invr():
	return map(int, input().split())
t = 1
t = inp()
for tt in range(t):
	(n, k) = invr()
	if n % 2 ^ k % 2 or k * k > n or n == k == 2:
		print('NO')
	else:
		print('YES')


kl = int(input())
for l in range(kl):
	(n, k) = map(int, input().split())
	if n >= k * k and (n - k) % 2 == 0:
		print('YES')
	else:
		print('NO')


k = int(input())
for i in range(k):
	(A, B) = input().split()
	A = int(A)
	B = int(B)
	if A % 2 != B % 2:
		print('NO')
		continue
	if A >= B ** 2:
		print('YES')
	else:
		print('NO')


T = int(input())
for _ in range(T):
	(N, K) = map(int, input().split())
	if N >= K * K and (N - K) % 2 == 0:
		print('YES')
	else:
		print('NO')


def solve(n, k):
	if n % 2 == k % 2 and n >= k ** 2:
		return True
t = int(input())
while t:
	(n, k) = map(int, input().split())
	if solve(n, k):
		print('YES')
	else:
		print('NO')
	t = t - 1


import math
for t in range(int(input())):
	(n, k) = map(int, input().split())
	ans = 'NO'
	if n >= k * k:
		if n % 2 == 0 and k % 2 == 0:
			ans = 'YES'
		elif n % 2 == 1 and k % 2 == 1:
			ans = 'YES'
	print(ans)


import math
t = int(input())
for i in range(t):
	(m, n) = input().split()
	m = int(m)
	n = int(n)
	s = math.sqrt(m)
	if m % 2 == 0:
		if n % 2 == 0:
			if n <= s:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
	elif n % 2 != 0:
		if n <= s:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
from sys import stdout
print = stdout.write
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n < k ** 2:
		print('NO\n')
	elif n % 2 == k % 2:
		print('YES\n')
	else:
		print('NO\n')


t = int(input())
while t:
	t -= 1
	(n, k) = [int(x) for x in input().split(' ')]
	if k ** 2 > n or n % 2 != k % 2:
		print('NO')
	else:
		print('YES')


def oddsum(n, k):
	m = k * k
	if n >= m and (n + k) % 2 == 0:
		return 'YES'
	else:
		return 'NO'
x = int(input())
newlist = []
for m in range(x):
	(n, k) = map(int, input().split())
	t = oddsum(n, k)
	newlist.append(t)
for s in newlist:
	print(s)


from sys import *
from math import *
from collections import deque
input = stdin.readline
lmi = lambda : list(map(float, input().split()))
mi = lambda : map(int, input().split())
si = lambda : input().strip('\n')
ssi = lambda : input().strip('\n').split()
for _ in range(int(input())):
	(a, b) = mi()
	if a // b < b:
		print('NO')
		continue
	if a % 2 == 0:
		print('YES' if b % 2 == 0 else 'NO')
	else:
		print('YES' if b % 2 == 1 else 'NO')


def solve(n, k):
	ap_sum = k * (2 + (k - 1) * 2)
	ap_sum /= 2
	if ap_sum <= n:
		if n % 2 != 0:
			if k % 2 != 0:
				return 'YES'
			else:
				return 'NO'
		if k % 2 == 0:
			return 'YES'
	return 'NO'
t = int(input())
for i in range(t):
	(n, k) = input().split(' ')
	n = int(n)
	k = int(k)
	string = solve(n, k)
	print(string)


def main():
	t = int(input())
	for __ in range(t):
		(n, k) = map(int, input().split())
		if n % 2 == k % 2 and k * k <= n:
			print('YES')
		else:
			print('NO')
main()


import sys
inp = sys.stdin.readline

def input():
	return inp().strip()
flush = sys.stdout.flush

def iin():
	return int(input())

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

def main():
	T = iin()
	while T:
		T -= 1
		(n, k) = lin()
		ch = 0
		if k % 2:
			ch = 1
		if n % 2 == ch and (k - 1) * (k + 1) <= n:
			print('YES')
		else:
			print('NO')
main()


import sys

def input():
	return sys.stdin.readline()[:-1]
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if n % 2 == k % 2 and n >= k * k:
		print('YES')
	else:
		print('NO')


import sys

def IOE():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	for _ in range(int(input())):
		(a, b) = map(int, input().split())
		if a & 1 and b & 1:
			if a >= b * b:
				print('YES')
			else:
				print('NO')
		elif a % 2 == 0 and b % 2 == 0:
			if a >= b * b:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
try:
	IOE()
except:
	pass
main()


t = int(input())
for _ in range(t):
	(n, k) = [int(i) for i in input().split()]
	if n % 2 == k % 2 and n >= k * k:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	x = input().split(' ')
	n = int(x[0])
	k = int(x[1])
	if n & 1 ^ k & 1 == 0 and n >= k * k:
		print('YES')
	else:
		print('NO')
	t = t - 1


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

def gift():
	for _ in range(t):
		(n, k) = list(map(int, input().split()))
		kap = n ** 0.5
		if kap < k:
			yield 'NO'
		elif (k + n) % 2 == 0:
			yield 'YES'
		else:
			yield 'NO'
t = int(input())
ans = gift()
print(*ans, sep='\n')


n = int(input())
for _ in range(n):
	(a, b) = map(int, input().split(' '))
	flag = a % 2 == b % 2 and b ** 2 <= a
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	first = (n - k) % 2 == 0
	second = (n - k) // 2 >= (k - 1) * k // 2
	result = 'YES' if first and second else 'NO'
	print(result)


for I in range(int(input())):
	(n, k) = map(int, input().split())
	if k * (2 + (k - 1) * 2) // 2 <= n and n % 2 == k % 2:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	nk = input().rstrip().split()
	n = int(nk[0])
	k = int(nk[1])
	if n >= k * k and n & 1 == k & 1:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	flag = 0
	if n % 2 == 1 and k % 2 == 0:
		print('NO')
		continue
	if n % 2 == 0 and k % 2 == 1:
		print('NO')
		continue
	if n % 2 == 0:
		if (1 + 2 * k - 1) * k // 2 > n:
			print('NO')
			flag = 1
			continue
	if flag:
		continue
	if n % 2 == 1:
		if (1 + 2 * k - 1) * k // 2 > n:
			print('NO')
			flag = 1
			continue
	if flag:
		continue
	print('YES')


def main():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		if k % 2 == n % 2:
			c = (k - 1) * (k - 1)
			if n >= c and n - c >= 2 * k - 1:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
	return
main()


def rec(x, c):
	s = c ** 2
	if s > x:
		return True
	if (x - s) % 2:
		return True
	return False
for _ in range(int(input())):
	(x, c) = map(int, input().split())
	print('YNEOS'[rec(x, c)::2])


from sys import stdin
from bisect import bisect_left as bl
from bisect import bisect_right as br

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

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

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

def intsput():
	return map(int, sinput())

class RangedList:

	def __init__(self, start, stop, val=0):
		self.shift = 0 - start
		self.start = start
		self.stop = stop
		self.list = [val] * (stop - start)

	def __setitem__(self, key, value):
		self.list[key + self.shift] = value

	def __getitem__(self, key):
		return self.list[key + self.shift]

	def __repr__(self):
		return str(self.list)

	def __iter__(self):
		return iter(self.list)

def dprint(*args, **kwargs):
	if debugging:
		print(*args, **kwargs)

def m(x):
	return x ** 2
debugging = 1
t = intput()
for _ in range(t):
	(n, k) = intsput()
	if k % 2 == n % 2 and n >= m(k):
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	(n, k) = list(map(int, input().split()))
	res = str('YES') if k * k <= n and (n + k) % 2 == 0 else str('NO')
	print(res)


a = int(input())
r = range(a)
d = []
e = []
for x in r:
	b = input()
	c = b.split()
	d.append(int(c[0]))
	e.append(int(c[1]))
yes = 'YES'
no = 'NO'
f = []
for x in r:
	if d[x] & 1 == 1 and e[x] & 1 == 0 or (d[x] & 1 == 0 and e[x] & 1 == 1):
		f.append(no)
	if d[x] & 1 == 0 and e[x] & 1 == 0:
		if d[x] >= e[x] * e[x]:
			f.append(yes)
		else:
			f.append(no)
	if d[x] & 1 == 1 and e[x] & 1 == 1:
		if d[x] >= e[x] * e[x]:
			f.append(yes)
		else:
			f.append(no)
for x in r:
	print(f[x])


T = int(input())
while T > 0:
	(n, k) = map(int, input().split())
	a = n % 2
	b = k % 2
	if a == b:
		if k ** 2 <= n:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
	T -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	flag = False
	if k % 2 == 0 and n % 2 == 0 or (k % 2 == 1 and n % 2 == 1):
		if n >= k ** 2:
			flag = True
	if flag:
		print('YES')
	else:
		print('NO')


even = lambda x: x % 2 == 0
n_test = int(input())
for test in range(n_test):
	(n, k) = tuple(map(int, input().split(' ')))
	if not even(n) ^ even(k):
		min_sum = k ** 2
		if n < min_sum:
			print('NO')
			continue
		diff = n - min_sum
		if not even(diff):
			print('NO')
			continue
		print('YES')
	else:
		print('NO')


from math import *
T = int(input())
while T:
	T -= 1
	(n, k) = map(int, input().split())
	print('YES' if n % 2 == k % 2 and n >= k * k else 'NO')


t = input()
n_parity = 0
K_parity = 0
flag = 0
op_list = []
for i in range(int(t)):
	n_k = input()
	n_k_list = n_k.split()
	n = int(n_k_list[0])
	k = int(n_k_list[1])
	n_parity = int(n) % 2
	K_parity = int(k) % 2
	if K_parity == n_parity and n >= pow(k, 2):
		op_list.append('YES')
	else:
		op_list.append('NO')
for i in range(len(op_list)):
	print(op_list[i])


import math
t = int(input())
while t:
	(n, k) = list(map(int, input().split()))
	d = math.sqrt(n)
	if k <= math.floor(d):
		if n % 2 == 0 and k % 2 == 0:
			print('YES')
		elif n % 2 == 1 and k % 2 == 1:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
	t = t - 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n % 2 == k % 2:
		s = k * (2 + (k - 1) * 2)
		s //= 2
		if n >= s:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	f = 1
	l = 2 * k - 1
	s = k * (f + l) / 2
	if n >= s and n % 2 == s % 2:
		print('YES')
	else:
		print('NO')


for nt in range(int(input())):
	(n, k) = map(int, input().split())
	if k == 1 and n % 2:
		print('YES')
		continue
	if n < k ** 2 or n % 2 != k % 2:
		print('NO')
		continue
	print('YES')


queries = int(input())
for _ in range(queries):
	(n, k) = map(int, input().split())
	matches = False
	if n % 2 == 0 and k % 2 == 0:
		matches = True
	if n % 2 != 0 and k % 2 != 0:
		matches = True
	if matches and k ** 2 <= n:
		print('YES')
	else:
		print('NO')


def solve(n, k):
	if n < k * k:
		return 'NO'
	if n % 2 != k % 2:
		return 'NO'
	return 'YES'

def main():
	t = int(input())
	for i in range(t):
		(n, k) = map(int, input().split())
		print(solve(n, k))
main()


def read_array():
	x = []
	x1 = []
	x = input()
	x = x.split(' ')
	for r in range(len(x)):
		x1.append(int(x[r]))
	return x1

def is_possible(x):
	if x[1] > x[0]:
		return 'NO'
	if x[1] ** 2 > x[0]:
		return 'NO'
	if x[0] % 2 == 0 and x[1] % 2 == 0:
		return 'YES'
	elif x[0] % 2 != 0 and x[1] % 2 != 0:
		return 'YES'
	else:
		return 'NO'
m = int(input())
res = []
for i in range(m):
	x = read_array()
	res.append(is_possible(x))
for v in res:
	print(v)


t = int(input())

def solve(n, k):
	if k % 2 != 0 and n % 2 == 0 or (k % 2 == 0 and n % 2 != 0):
		return False
	kk = 2 * k
	sumv = (kk * (kk + 1) // 2 - k) // 2
	if sumv > n:
		return False
	return True
for _ in range(t):
	(n, k) = map(int, input().split())
	if solve(n, k):
		print('YES')
	else:
		print('NO')


import sys, math
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if k > n:
		print('NO')
	elif n % 2 != k % 2:
		print('NO')
	elif n < k ** 2:
		print('NO')
	else:
		print('YES')


def odd_sum(n, k):
	if k * k <= n and (n + k) % 2 == 0:
		return 'YES'
	else:
		return 'NO'
t = int(input())
n_k_lst = []
for i in range(0, t):
	(x, y) = map(int, input().split())
	z = odd_sum(x, y)
	n_k_lst.append(z)
for i in n_k_lst:
	print(i)


t = int(input())
for i in range(t):
	l = [int(i) for i in input().split()]
	n = l[0]
	k = l[1]
	if k * k > n:
		print('NO')
	elif n % 2 != 0:
		if k % 2 == 0:
			print('NO')
		else:
			print('YES')
	elif k % 2 != 0:
		print('NO')
	else:
		print('YES')


from math import sqrt

def factor(n):
	if n % 2 == 0:
		yield 2
	d = int(sqrt(n)) + 3
	for i in range(3, d, 2):
		if n % i == 0:
			yield i

def main():
	d = int(input())
	for i in range(d):
		(a, b) = [int(v) for v in input().split()]
		r = a - b
		v = b * b - b
		print('YES' if r % 2 == 0 and r >= 0 and (r >= v) else 'NO')
main()


import math
for i in range(int(input())):
	(n, k) = list(map(int, input().split()))
	if n % 2 != k % 2:
		print('NO')
	elif k > n:
		print('NO')
	elif k == 1:
		print('YES')
	else:
		preS = (1 + (1 + (k - 1) * 2)) * k / 2
		if preS <= n:
			print('YES')
		else:
			print('NO')


ilo = int(input())
for i in range(ilo):
	tmp = list(map(int, input().split()))
	if tmp[0] % 2 == tmp[1] % 2 and tmp[1] ** 2 <= tmp[0]:
		print('YES')
	else:
		print('NO')


def main():
	(N, K) = list(map(int, input().split()))
	if N % 2 != K % 2:
		return 'NO'
	return 'YES' if K * K <= N else 'NO'

def main_():
	for i in range(int(input())):
		print(main())
main_()


t = intt = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	if l[1] ** 2 > l[0]:
		print('NO')
	elif (l[1] - l[0]) % 2 == 0:
		print('YES')
	else:
		print('NO')


import math
t = int(input())
while t != 0:
	t -= 1
	(n, k) = map(int, input().split())
	if k == 1:
		if n % 2 == 0:
			print('NO')
		else:
			print('YES')
		continue
	if k > n ** 0.5:
		print('NO')
		continue
	if n % 2 == 0:
		if k % 2 == 0:
			print('YES')
		else:
			print('NO')
		continue
	if n % 2 == 1:
		if k % 2 == 1:
			print('YES')
		else:
			print('NO')
		continue


def checker(n, k):
	s = k ** 2
	if s > n:
		return 'NO'
	d = n - s
	return 'YES' if d % 2 == 0 else 'NO'
for _ in range(int(input())):
	(N, K) = [int(i) for i in input().split()]
	print(checker(N, K))


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

def read_ints():
	ints = [int(x) for x in input().split(' ')]
	return ints

def solve(n, k):
	if k > n:
		return 'NO'
	if n % 2 == 0:
		if k % 2 != 0:
			return 'NO'
	elif k % 2 != 1:
		return 'NO'
	if pow(k, 2) > n:
		return 'NO'
	return 'YES'
t = read_int()
for i in range(t):
	data = read_ints()
	n = data[0]
	k = data[1]
	print(solve(n, k))


from sys import stdin

def func():
	return
for _ in range(int(stdin.readline())):
	(n, k) = map(int, stdin.readline().split())
	if n % 2 == k % 2:
		if k ** 2 <= n:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


def fun(n, k):
	if (n - k) % 2 == 1:
		return 0
	elif n >= k * k:
		return 1
	else:
		return 0
m = int(input())
n = 0
k = 0
for i in range(0, m):
	(n, k) = map(int, input().split())
	if fun(n, k):
		print('YES')
	else:
		print('NO')


import math

def oddsum(n, k):
	flag = 0
	if n == 1 and k == 1:
		flag = 1
	elif n % 2 == 0 and k % 2 == 0 and (k <= int(math.sqrt(n))):
		flag = 1
	elif n % 2 == 1 and k % 2 == 1 and (k <= int(math.sqrt(n))):
		flag = 1
	else:
		flag = 0
	if flag == 1:
		print('YES')
	else:
		print('NO')
t = int(input())
for cases in range(t):
	(n, k) = map(int, input().split())
	oddsum(n, k)


import math
q = int(input())
for p in range(q):
	entrada = list(map(int, input().split(' ')))
	n = entrada[0]
	k = entrada[1]
	if n % 2 == 0 and k % 2 == 0 or (n % 2 != 0 and k % 2 != 0):
		if k ** 2 <= n:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import math
t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	if (n % 2 == 0 and k % 2 == 0 or (n % 2 != 0 and k % 2 != 0)) and k ** 2 <= n:
		print('YES')
	else:
		print('NO')


def ma(n, k):
	c = 0
	odd = 1
	m = 1
	c = int(n ** 0.5)
	if n % 2 != 0:
		if k % 2 != 0 and k <= c:
			return 'YES'
	if n % 2 == 0:
		if k % 2 == 0 and k <= c:
			return 'YES'
	return 'NO'
	return result
a = int(input())
for r in range(a):
	x = list(map(int, input().rstrip().split()))
	m = ma(x[0], x[1])
	print(m)


t = int(input())

def odd_sum(n):
	return n * n
for _ in range(t):
	(n, k) = map(int, input().split())
	sm = odd_sum(k)
	if n % 2 == 0:
		if k % 2 != 0 or sm > n:
			print('NO')
		else:
			print('YES')
	elif k % 2 == 0 or sm > n:
		print('NO')
	else:
		print('YES')


I = lambda : map(int, input().split())
for _ in range(int(input())):
	(n, k) = I()
	if n % 2 != k % 2:
		print('NO')
	elif k <= n ** 0.5:
		print('YES')
	else:
		print('NO')


from math import sqrt
for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a % 2 == 0 and b % 2 == 0 and (b <= sqrt(a)):
		print('YES')
	elif a % 2 == 1 and b % 2 == 1 and (b <= sqrt(a)):
		print('YES')
	else:
		print('NO')


t = int(input())
if 1 <= t <= 10 ** 5:
	for i in range(t):
		a = input().split()
		a[0] = int(a[0])
		a[1] = int(a[1])
		if a[1] % 2 == 0 and a[0] % 2 == 0 or (a[1] % 2 != 0 and a[0] % 2 != 0):
			if a[0] >= a[1] ** 2:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	if k == 0:
		print('NO')
		continue
	if k > n:
		print('NO')
		continue
	ns = n % 2
	ks = k % 2
	if ns == ks:
		if k ** 2 > n:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


t = input()
for j in range(int(t)):
	st = input()
	nk = st.split(' ')
	n = int(nk[0])
	k = int(nk[1])
	if n % 2 == k % 2 and k * k <= n:
		print('YES')
	else:
		print('NO')


a = int(input())
for _ in range(a):
	z = list(map(int, input().split()))
	n = z[1] - 1
	sum1 = (2 + (n - 1) * 2) / 2 * n
	if z[0] - sum1 > 1 + 2 * (n - 1) and (z[0] - sum1) % 2 == 1:
		print('YES')
	else:
		print('NO')


fast = lambda : stdin.readline().strip()
zzz = lambda : [int(i) for i in fast().split()]
(z, zz) = (input, lambda : list(map(int, z().split())))
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from re import *
from sys import *
from math import *
from heapq import *
from queue import *
from bisect import *
from string import *
from itertools import *
from collections import *
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from collections import Counter as cc
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def output(answer):
	stdout.write(str(answer))
num = int(z())
for _ in range(num):
	(n, k) = zzz()
	if n % 2 == k % 2 and k * k <= n:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	b = list((int(x) for x in input().split()))
	if b[0] % 2 != b[1] % 2:
		print('NO')
	elif b[0] < b[1] ** 2:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	p = input().split()
	n = int(p[0])
	k = int(p[1])
	if n < k:
		print('NO')
	elif n % 2 == 0 and k % 2 == 0 or (n % 2 != 0 and k % 2 != 0):
		if n - (k - 1) * (k - 1) > 2 * k - 3:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


res = []
t = int(input())
for t_curr in range(t):
	(n, k) = [int(x) for x in input().split()]
	if k ** 2 > n:
		res.append('NO')
	elif k % 2 == 1 and n % 2 == 0:
		res.append('NO')
	elif k % 2 == 0 and n % 2 == 1:
		res.append('NO')
	else:
		res.append('YES')
for item in res:
	print(item)


import sys

def main():
	next(sys.stdin)
	for line in sys.stdin:
		(n, k) = map(int, line.strip().split())
		print('YES' if n >= k * k and n % 2 == k % 2 else 'NO')
main()


T = int(input())
for kase in range(T):
	(n, k) = [int(x) for x in input().split()]
	if n % 2 == k % 2 and k * k <= n:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	c = 1
	flag = 0
	sum1 = pow(k, 2)
	if sum1 > n:
		print('NO')
	else:
		s1 = n - sum1
		if s1 % 2 == 0:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	if x % 2 == y % 2:
		if y * y > x:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	t = t - 1
	(n, k) = map(int, input().split(' '))
	if k == 1:
		print('YES' if n % 2 == 1 else 'NO')
	else:
		pk = 2 * (k - 1) - 1
		s = (pk + 1) * (k - 1)
		if s % 2 == 1:
			print('NO')
		else:
			s = s // 2
			if (n - s) % 2 == 1 and n - s > 0 and (n - s > pk):
				print('YES')
			else:
				print('NO')


def oddNumber(n, k):
	if n >= k ** 2:
		if n % 2 == 0 and k % 2 == 0:
			return True
		if n % 2 == 1 and k % 2 == 1:
			return True
		else:
			return False
	return False
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if oddNumber(n, k):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	print(['NO', 'YES'][n % 2 == k % 2 and k ** 2 <= n])


from math import *
import sys
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if k % 2 != n % 2:
		res = 'NO'
	elif n < k ** 2:
		res = 'NO'
	else:
		res = 'YES'
	print(res)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	if b * b <= a and a % 2 == b % 2:
		print('yes'.upper())
	else:
		print('no'.upper())


test_cases = int(input())

def handle():
	(n, k) = input().split(' ')
	n = int(n)
	k = int(k)
	if k == 1 and n % 2 == 0:
		return 'NO'
	if k ** 2 > n:
		return 'NO'
	if n % 2 == 1:
		if k % 2 == 1:
			return 'YES'
		return 'NO'
	if k % 2 == 0:
		return 'YES'
	return 'NO'
for _ in range(test_cases):
	print(handle())


import os
import io
from collections import Counter
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce
from collections import deque
import threading

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

def iinput():
	return int(input())

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

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

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)))
for _ in range(iinput()):
	(n, k) = rinput()
	if n >= k and (n - k) % 2 == 0 and (n - k >= k * (k - 1)):
		print('YES')
	else:
		print('NO')


import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda : readline().rstrip()
ni = lambda : int(readline().rstrip())
nm = lambda : map(int, readline().split())
nl = lambda : list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
	(n, k) = nm()
	if n % 2 == k % 2 and n >= k ** 2:
		print('YES')
	else:
		print('NO')
T = ni()
for _ in range(T):
	solve()


def check(n, k):
	tt = k ** 2
	if n >= tt:
		if n % 2 == 0 and k % 2 == 0:
			return True
		elif n % 2 != 0 and k % 2 != 0:
			return True
	return False
t = int(input())
while t:
	(n, k) = [int(p) for p in input().split()]
	if check(n, k):
		print('YES')
	else:
		print('NO')
	t -= 1


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if k ** 2 > n:
		print('NO')
	elif k % 2 == n % 2:
		print('YES')
	else:
		print('NO')


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

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

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

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

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

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

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

def ddl():
	return collections.defaultdict(list)

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=2):
	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):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

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

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True
for i in range(ii()):
	(n, k) = mi()
	if k * k > n:
		print('NO')
	elif n % 2 == 0 and k % 2 != 1:
		print('YES')
	elif n % 2 == 1 and k % 2 == 1:
		print('YES')
	else:
		print('NO')


R = lambda : map(int, input().split())
t = int(input())
for _ in range(t):
	(n, k) = R()
	if (n - k) % 2 or n < k ** 2:
		print('NO')
		continue
	print('YES')


from math import inf
t = int(input())
for q in range(t):
	(n, k) = [int(i) for i in input().split()]
	p = n - k * k
	if p % 2 == 0 and p >= 0:
		print('YES')
	else:
		print('NO')


n = int(input())
for _ in range(n):
	a = [int(i) for i in input().split()]
	if a[1] * a[1] > a[0] or a[0] % 2 != a[1] % 2:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	if k == 1:
		if n % 2 == 0:
			print('NO')
		else:
			print('YES')
	else:
		total = 1
		total = (k - 2 + 1) * (k - 2) + k - 1
		last = 2 * (k - 1) + 1
		n = n - total
		if n % 2 != 0 and n >= last:
			print('YES')
		else:
			print('NO')


import sys
from collections import Counter

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')
INF = 10 ** 18
MOD = 10 ** 9 + 7

def get_sum(a, b, c):
	return (a + b) * c // 2
for _ in range(INT()):
	(N, K) = MAP()
	if N >= get_sum(1, K * 2 - 1, K) and N % 2 == K % 2:
		YES()
	else:
		NO()


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = math.floor(math.sqrt(n))
	if n % 2 == 0 and k % 2 == 0 and (k <= a):
		print('YES')
	elif n % 2 != 0 and k % 2 != 0 and (k <= a):
		print('YES')
	else:
		print('NO')


from collections import defaultdict
from functools import lru_cache
from math import gcd, floor, ceil

def ilist():
	return [int(x) for x in input().strip().split(' ')]

def iint():
	return int(input())

def istr():
	return input()
for _ in range(iint()):
	(n, k) = ilist()
	if n < k:
		print('NO')
	elif k % 2 == 1 and n % 2 == 0:
		print('NO')
	elif k % 2 == 0 and n % 2 == 1:
		print('NO')
	elif n < k ** 2:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	(a, b) = list(map(int, input().split()))
	if a == 1 and b == 1:
		print('YES')
	elif a < b ** 2:
		print('NO')
	elif (a - b) % 2 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for y in range(t):
	(n, x) = map(int, input().split())
	if n >= x * x and n % 2 == x % 2:
		print('YES')
	else:
		print('NO')


t = int(input())
i = 0
list1 = []
while i < t:
	(n, k) = input().split(' ')
	n = int(n)
	k = int(k)
	if n % 2 != 0 and k % 2 != 0:
		if k ** 2 <= n:
			list1.append('YES')
		else:
			list1.append('NO')
	elif n % 2 == 0 and k % 2 == 0:
		if k ** 2 <= n:
			list1.append('YES')
		else:
			list1.append('NO')
	else:
		list1.append('NO')
	i = i + 1
while i > 0:
	print(list1[t - i])
	i = i - 1


from math import sqrt
T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	if n % 2 == 0 and k % 2 != 0:
		print('NO')
	elif n % 2 != 0 and k % 2 == 0:
		print('NO')
	elif n % 2 == 0 and k % 2 == 0 and (k > sqrt(n)):
		print('NO')
	elif n % 2 != 0 and k % 2 != 0 and (k > sqrt(n)):
		print('NO')
	else:
		print('YES')


import sys
t = int(input())
for i in range(1, t + 1):
	(n, k) = [int(s) for s in input().split(' ')]
	if n % 2 == 0 and k % 2 == 1:
		print('NO')
		continue
	if n % 2 == 1 and k % 2 == 0:
		print('NO')
		continue
	if n >= k ** 2:
		print('YES')
	else:
		print('NO')


from math import sqrt
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = n + k
	if s % 2 == 1 or k > sqrt(n):
		print('NO')
	else:
		print('YES')


import os
import heapq
import sys, threading
import math as mt
import operator
from copy import copy
from collections import defaultdict, deque
from io import BytesIO, IOBase
sys.setrecursionlimit(2 * 10 ** 5)

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

def inpt():
	return [int(k) for k in input().split()]

def main():
	for _ in range(int(input())):
		(n, k) = inpt()
		k = k * k
		if k > n:
			print('NO')
		elif (n - k) % 2 == 0:
			print('YES')
		else:
			print('NO')
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')
main()


from math import sqrt, fabs
t = int(input())
res = []
for i in range(t):
	(n, k) = map(int, input().split())
	if (n - k) % 2 == 0 and n >= k ** 2:
		if fabs(int(sqrt(n)) - sqrt(n)) < 10 ** (-8):
			if (int(sqrt(n)) - k) % 2 == 0:
				res.append('YES')
			else:
				res.append('NO')
		elif int((1 + int(sqrt(n))) ** 2 - n - (1 + int(sqrt(n)) - k)) % 2 == 0:
			res.append('YES')
		else:
			res.append('NO')
	else:
		res.append('NO')
for i in range(t):
	print(res[i])


times = input()
lst2 = []
for i in range(int(times)):
	b = input()
	a_1 = ''
	l_b = []
	for i in range(len(b)):
		if b[i] != ' ':
			a_1 = a_1 + b[i]
		else:
			l_b.append(int(a_1))
			a_1 = ''
	l_b.append(int(a_1))
	if l_b[1] > l_b[0]:
		lst2.append('NO')
	elif l_b[0] % 2 != l_b[1] % 2:
		lst2.append('NO')
	elif l_b[1] * l_b[1] > l_b[0]:
		lst2.append('NO')
	else:
		lst2.append('YES')
for i in range(len(lst2)):
	print(lst2[i])


import math
t = int(input())
for i in range(0, t):
	(n, k) = map(int, input().split())
	temp = n
	temp1 = math.sqrt(temp)
	temp1 = math.floor(temp1)
	if temp1 < k:
		print('NO')
	elif n % 2 == 0 and k % 2 == 0:
		print('YES')
	elif n % 2 != 0 and k % 2 != 0:
		print('YES')
	else:
		print('NO')


import sys
for q in range(int(sys.stdin.readline())):
	(n, k) = [int(i) for i in sys.stdin.readline().split()]
	sys.stdout.write(['NO\n', 'YES\n'][n >= k * k and (n - k) % 2 == 0])


for _ in range(int(input())):
	nk = list(map(int, input().split()))
	if nk[0] % 2 == nk[1] % 2 and nk[0] >= nk[1] ** 2:
		print('YES')
	else:
		print('NO')


def solve():
	(n, k) = map(int, input().split())
	can = True
	if k == 1:
		if n % 2 == 0:
			can = False
	else:
		s = (1 + k * 2 - 1) * k / 2
		if s > n:
			can = False
		if (n - s) % 2 == 1:
			can = False
	if can:
		print('YES')
	else:
		print('NO')

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


def main():
	for _ in range(int(input())):
		(n, k) = list(map(int, input().split()))
		print('YES' if n % 2 == k % 2 and n >= k * k else 'NO')
main()


t = int(input())
for test in range(t):
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	if k ** 2 > n:
		print('NO')
		continue
	elif k ** 2 == n:
		print('YES')
		continue
	if n % 2 != k % 2:
		print('NO')
	else:
		print('YES')


t = int(input())
list_ans = []
for i in range(t):
	(n, k) = map(int, input().split())
	list_ans.append(['NO', 'YES'][n >= k ** 2 and (n + k) % 2 == 0])
for item in list_ans:
	print(item)


t = int(input())
ans_list = []
for i in range(t):
	(n, k) = map(int, input().split())
	if n % 2 == k % 2 and n >= k ** 2:
		ans_list.append('YES')
	else:
		ans_list.append('NO')
for g in range(t):
	print(ans_list[g])


t = int(input())
for _ in range(t):
	dim = list(map(int, input().split()))
	num = dim[0]
	k = dim[1]
	if num < k * k:
		print('NO')
	elif k % 2 == 0 and num % 2 == 0:
		print('YES')
	elif k % 2 == 1 and num % 2 == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	s = input().strip(' ')
	l = list(map(int, s.split()))
	(n, k) = (l[0], l[1])
	k1 = k * k
	if n >= k1 and n & 1 == k & 1:
		print('YES')
	else:
		print('NO')
	t = t - 1


n = int(input())
for i in range(n):
	(n, k) = map(int, input().split())
	print(['YES', 'NO'][n % 2 != k % 2 or k * k > n])


import sys
input = sys.stdin.readline
for ti in range(int(input().strip())):
	(n, k) = [int(x) for x in input().strip().split()]
	if not n % 2 and k % 2:
		print('NO')
	else:
		n -= k ** 2
		if n >= 0 and (not n % 2):
			print('YES')
		else:
			print('NO')


import sys
input = sys.stdin.readline

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

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

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

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

def solve(n, k):
	if k * k <= n and n % 2 == k % 2:
		return 'YES'
	else:
		return 'NO'

def output():
	t = inp()
	for i in range(t):
		(n, k) = invr()
		print(solve(n, k))
output()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	sumt = k * k
	if n >= sumt and n % 2 == sumt % 2:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	x = (k - 1) * k + k
	if n < x:
		print('NO')
		continue
	if (n - x) % 2 == 0:
		print('YES')
	else:
		print('NO')


from sys import stdin
input = stdin.readline
for i in range(int(input())):
	(n, k) = map(int, input().split())
	if n & 1 == k & 1 and n >= k * k:
		print('YES')
	else:
		print('NO')


t = int(input())
for loop in range(t):
	(n, k) = map(int, input().split())
	ans = 'YES'
	if k % 2 != n % 2:
		ans = 'NO'
	if (1 + (2 * k - 1)) * k // 2 > n:
		ans = 'NO'
	print(ans)


x = int(input())
for i in range(0, x):
	(n, m) = [int(a) for a in input().split()]
	if m % 2 == 0 and n % 2 == 0 and (m ** 2 <= n):
		print('YES')
	elif m % 2 != 0 and n % 2 != 0 and (m ** 2 <= n):
		print('YES')
	else:
		print('NO')


cases = input()
for case in range(int(cases)):
	spl = input().split(' ')
	(x, y) = (int(spl[0]), int(spl[1]))
	if x >= y * y and x % 2 == y % 2:
		print('YES')
	else:
		print('NO')


def odd_sum(n, k):
	if k % 2 != n % 2 or k ** 2 > n:
		print('NO')
	else:
		print('YES')
for i in range(int(input())):
	inp = [int(k) for k in input().split(' ')]
	odd_sum(inp[0], inp[1])


from sys import stdin, stdout
input = stdin.readline
print = stdout.write
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n < k ** 2:
		print('NO\n')
	elif n % 2 == k % 2:
		print('YES\n')
	else:
		print('NO\n')


from math import ceil, sqrt, log, gcd

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

def si():
	return input()

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

def li():
	return list(mi())

def main():
	for _ in range(ii()):
		(n, k) = mi()
		p = 1
		q = 0
		p = 2 * k * (2 * k + 1) / 2
		q = p - k * (k + 1)
		if n < q:
			print('NO')
		elif n % 2 == k % 2:
			print('YES')
		else:
			print('NO')
main()


cases = int(input())
output = []
for i in range(0, cases):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	if n % 2 == 0 and k % 2 == 0 or (n % 2 == 1 and k % 2 == 1):
		if n / k >= k:
			output.append('YES')
		else:
			output.append('NO')
	else:
		output.append('NO')
for x in output:
	print(x)


from math import sqrt
t = int(input())
while t:
	t -= 1
	(n, k) = [int(i) for i in input().split()]
	if k == 1:
		if n % 2:
			print('YES')
		else:
			print('NO')
	else:
		if k % 2 == 0 and n % 2 == 1:
			print('NO')
		elif k % 2 == 1 and n % 2 == 0:
			print('NO')
		elif k > sqrt(n):
			print('NO')
		else:
			print('YES')
		continue


T = int(input())
for i in range(T):
	NK = input()
	[N, K] = NK.split()
	N = int(N)
	K = int(K)
	res = 'YES'
	if K * K > N:
		res = 'NO'
	if K % 2 != N % 2:
		res = 'NO'
	print(res)


t = [0]
for i in range(10000):
	t.append(t[-1] + i * 2 + 1)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n + k & 1 == 1:
		print('NO')
		continue
	if k > 10000:
		print('NO')
		continue
	if t[k] <= n:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	print('NO' if (n ^ k) & 1 or n < k * k else 'YES')


kt = int(input())
for t in range(kt):
	(n, k) = map(int, input().split())
	if k % 2 == 1 and n % 2 == 0:
		print('NO')
		continue
	if k % 2 == 0 and n % 2 == 1:
		print('NO')
		continue
	if n >= k * k:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	if k & 1 ^ n & 1:
		print('NO')
	elif k ** 2 <= n:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = k * k
	if s <= n:
		if s % 2 == n % 2:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


for T in [0] * int(input()):
	(n, k) = map(int, input().split())
	if n - k & 1 or k * k > n:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	args = [int(x) for x in input().split(' ')]
	n = args[0]
	k = args[1]
	if n % 2 == k % 2:
		if k ** 2 <= n:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


def f(l):
	(n, k) = l
	return n >= k * k and n % 2 == k % 2
q = int(input())
[print('YES' if f(list(map(int, input().split()))) else 'NO') for _ in range(q)]


t = int(input())
for _ in range(t):
	a = input().split()
	n = int(a[0])
	k = int(a[1])
	if n - (k - 1) ** 2 > 2 * k - 3 and (n - (k - 1) ** 2) % 2 == 1:
		print('YES')
	else:
		print('NO')


import sys
from math import *
from collections import defaultdict
from queue import deque
from heapq import heappush, heappop
lines = [line.strip() for line in sys.stdin.readlines()]
t = int(lines[0])
for tt in range(1, 1 + t):
	(n, k) = list(map(int, lines[tt].split()))
	mm = k * k
	ret = n >= mm and (n - mm) % 2 == 0
	print('YES' if ret else 'NO')


for t in range(int(input())):
	(n, k) = map(int, input().split())
	if n % 2 and (not k % 2) or (not n % 2 and k % 2):
		ans = 'NO'
	else:
		dk = 1 + 2 * (k - 1)
		if (1 + dk) * k // 2 <= n:
			ans = 'YES'
		else:
			ans = 'NO'
	print(ans)


ans = []
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if k * k > n or n % 2 != k % 2:
		ans.append('NO')
	else:
		ans.append('YES')
print('\n'.join(map(str, ans)))


tc = int(input())
for ii in range(tc):
	(n, k) = map(int, input().split())
	l = 1
	r = k * 2 - 1
	ans = (l + r) * k // 2
	y = 0
	if k % 2 == 0:
		if n % 2 == 0:
			if n >= ans:
				y = 1
	elif n % 2 != 0:
		if n >= ans:
			y = 1
	if y == 0:
		print('NO')
	else:
		print('YES')


t = int(input())
while t > 0:
	t -= 1
	(n, m) = map(int, input().split())
	flag = 1
	if n < m ** 2:
		flag = 0
	elif n % 2 == 0 and m % 2:
		flag = 0
	elif n % 2 and m % 2 == 0:
		flag = 0
	if flag == 1:
		print('YES')
	else:
		print('NO')


import sys
q = int(sys.stdin.readline())
for _ in range(q):
	(n, k) = map(int, sys.stdin.readline().split())
	if k <= n ** 0.5:
		if n % 2 != k % 2:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = n % 2
	b = m % 2
	if a != b:
		print('NO')
	elif m > n ** 0.5:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	l = [int(x) for x in input().split(' ')]
	n = l[0]
	k = l[1]
	a = n + k
	if a % 2 == 1:
		print('NO')
	elif n >= k ** 2:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
n = int(stdin.readline())
a = []
for i in range(n):
	a.append([int(x) for x in stdin.readline().split()])
for j in range(n):
	if a[j][0] >= a[j][1] * a[j][1]:
		if (a[j][0] - a[j][1]) % 2 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for i in range(1, t + 1):
	mass = input().split(' ')
	n = int(mass[0])
	k = int(mass[1])
	if n == 3 and k == 1:
		print('YES')
	else:
		ans = (2 + 2 * (k - 1)) / 2 * k
		if n < ans:
			print('NO')
		elif n % 2 == k % 2:
			print('YES')
		else:
			print('NO')


for _ in range(0, int(input())):
	(n, k) = map(int, input().split(' '))
	print(['NO', 'YES'][n % 2 == k % 2 and n >= k * k])


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a % 2 == 0:
		if b % 2 == 0:
			print('YES' if a ** 0.5 >= b else 'NO')
		else:
			print('NO')
	elif b % 2 == 0:
		print('NO')
	else:
		print('YES' if a >= b ** 2 else 'NO')


def solve():
	(n, k) = map(int, input().split())
	s = k ** 2
	if n < s:
		print('NO')
	elif k % 2 ^ n % 2 == 0:
		print('YES')
	else:
		print('NO')
for i in range(int(input())):
	solve()


t = int(input())
inputs = [1] * 2
mod = list()
for item in range(t):
	inputs = input().split()
	nk = [int(item) for item in inputs]
	sum = nk[1] ** 2
	if sum > nk[0]:
		mod.append(-1)
	else:
		mod.append((nk[0] - sum) % 2)
for i in mod:
	if i == 0:
		print('YES')
	else:
		print('NO')


def solve():
	(a, k) = map(int, input().split())
	if k * k > a:
		print('NO')
	elif a % 2 == 0 and k % 2 == 0:
		print('YES')
	elif a % 2 and k % 2:
		print('YES')
	else:
		print('NO')
for _ in range(int(input())):
	solve()


def solu(n, k):
	if n & 1 != 0 and k == 1:
		print('YES')
	elif n & 1 == 0 and k == 1:
		print('NO')
	elif n & 1 == 0 and k & 1 != 0:
		print('NO')
	elif n & 1 == 0 and k & 1 == 0:
		if k ** 2 > n:
			print('NO')
		else:
			print('YES')
	elif n & 1 != 0 and k & 1 == 0:
		print('NO')
	elif n & 1 != 0 and k & 1 != 0:
		if k ** 2 > n:
			print('NO')
		else:
			print('YES')
	return 0
a = eval(input())
for i in range(a):
	(n, k) = map(int, input().split())
	solu(n, k)


import sys
input = sys.stdin.readline
Q = int(input())
Query = [list(map(int, input().split())) for _ in range(Q)]
for (n, k) in Query:
	ok = k ** 2 <= n and (n - k) % 2 == 0
	print('YES' if ok else 'NO')


for f in [*open(0)][1:]:
	(n, k) = map(int, f.split())
	print('YNEOS'[(n < k * k) | (n % 2 != k % 2)::2])


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().rstrip().split())
	s = bool(n % 2)
	m = bool(k % 2)
	if (s and m or (not s and (not m))) and k * k <= n:
		print('YES')
	else:
		print('NO')


testcases = int(input())
for i in range(testcases):
	(x, y) = list(map(int, input().split()))
	first = 1
	last = 2 * y - 1
	sumof = y * (first + last) // 2
	if x % 2 == y % 2 and x >= sumof:
		print('YES')
	else:
		print('NO')


def solve_1327A():
	n = int(input())
	A = []
	for i in range(n):
		line = input()
		A += [[int(line.split(' ')[0]), int(line.split(' ')[1])]]
	for pair in A:
		sum = pair[1] * pair[1]
		if sum > pair[0]:
			print('NO')
		elif (pair[0] - sum) % 2 == 0:
			print('YES')
		else:
			print('NO')
solve_1327A()


q = int(input())
while q:
	(n, k) = [int(c) for c in input().split()]
	if not k % 2 == n % 2:
		print('NO')
	elif n < k * k:
		print('NO')
	else:
		print('YES')
	q = q - 1


def main():
	result = str()
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		if (n % 2 and k % 2 or (n % 2 == 0 and k % 2 == 0)) and n >= k * k:
			result += 'YES\n'
		else:
			result += 'NO\n'
	print(result.strip())
main()


from math import sqrt as l
t = int(input())
while t > 0:
	(n, m) = [int(i) for i in input().split()]
	if n & 1 == 0 and m & 1 != 0:
		print('NO')
	elif n & 1 == 1 and m & 1 == 0:
		print('NO')
	elif int(l(n)) >= m:
		print('YES')
	else:
		print('NO')
	t -= 1


T = int(input())
for t in range(T):
	[n, k] = [int(i) for i in input().split()]
	if k ** 2 > n:
		print('NO')
		continue
	if n % 2 == k % 2:
		print('YES')
	else:
		print('NO')


T = int(input())
for i in range(T):
	(n, k) = map(int, input().strip().split())
	if n % 2 == 0 and k % 2 == 0 and (k ** 2 <= n):
		print('YES')
	elif n % 2 == 1 and k == 1:
		print('YES')
	elif n % 2 == 1 and k % 2 == 1 and (k ** 2 <= n):
		print('YES')
	else:
		print('NO')


import math
t = int(input())

def SumofOdd(t):
	for i in range(1, t + 1):
		(n, k) = list(map(int, input().split()))
		if n < k:
			print('NO')
		elif math.sqrt(n) >= k and n % 2 != 0 and (k == 1):
			print('YES')
		elif math.sqrt(n) >= k and n % 2 == 0 and (k % 2 == 0):
			print('YES')
		elif math.sqrt(n) >= k and n % 2 != 0 and (k % 2 != 0):
			print('YES')
		else:
			print('NO')
SumofOdd(t)


def is_odd(num):
	if num % 2 == 0:
		return False
	return True
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	if n // k < k:
		print('NO')
	elif is_odd(n) and is_odd(k) or (not is_odd(n) and (not is_odd(k))):
		print('YES')
	else:
		print('NO')


def inp_n():
	return int(input())

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

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

def is_odd(n):
	if n & 1:
		return True
	return False

def is_prime(n):
	i = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += 1
	return True
from collections import defaultdict
import math
for _ in range(inp_n()):
	(a, b) = inp_mul_num()
	if a % 2 == b % 2 and b * b <= a:
		print('YES')
	else:
		print('NO')


n = int(input())
yes_no_vector = []
for i in range(n):
	(sum, odd_numbers) = [int(numero) for numero in input().split(' ')]
	if sum % 2 == odd_numbers % 2:
		if odd_numbers * odd_numbers > sum:
			yes_no_vector.append('NO')
		else:
			yes_no_vector.append('YES')
	else:
		yes_no_vector.append('NO')
for i in range(len(yes_no_vector)):
	print(yes_no_vector[i])


from math import *
from copy import *
from string import *
from random import *
from bisect import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
from collections import defaultdict

def solve(l):
	n = len(l)
T = int(input())
for _ in range(T):
	(N, K) = list(map(int, stdin.readline().rstrip().split()))
	if N < K ** 2:
		print('NO')
	elif N % 2 == 1 and K % 2 == 1:
		print('YES')
	elif N % 2 == 0 and K % 2 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for tc in range(t):
	(n, k) = [int(a) for a in input().split()]
	s = k * k
	if n >= s and (n - s) % 2 == 0:
		print('YES')
	else:
		print('NO')


def do(n, d=2, a=1):
	return int(n / 2 * (2 * a + (n - 1) * d))
from pprint import pprint
q = int(input())
for _ in range(q):
	(n, k) = map(int, input().split())
	f = True
	t = do(k)
	if n == t:
		pass
	elif n < t:
		f = False
	elif (n - t) % 2 == 0:
		pass
	else:
		f = False
	print('YES' if f else 'NO')


t = int(input())
for i in range(t):
	(x, n) = map(int, input().split())
	if n * n <= x:
		if (n + x) % 2 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for x in range(t):
	(n, k) = arr = [int(i) for i in input().split()]
	if n % 2 == 0 and k % 2 == 0:
		if n >= k ** 2:
			print('YES')
		else:
			print('NO')
	elif n % 2 == 1 and k % 2 == 1:
		if n >= k ** 2:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


from sys import stdin
input = stdin.readline

def getAns(n, k):
	if n % 2 != k % 2:
		print('NO')
	elif pow(k, 2) > n:
		print('NO')
	else:
		print('YES')
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	getAns(n, k)


def func(n):
	for i in range(n):
		l = list(map(int, input().split()))
		to_get = l[0]
		n_of_odd_positive_integers = l[1]
		if to_get % 2 != 0 and n_of_odd_positive_integers % 2 == 0:
			print('NO')
		elif to_get % 2 == 0 and n_of_odd_positive_integers % 2 != 0:
			print('NO')
		elif n_of_odd_positive_integers ** 2 > to_get:
			print('NO')
		else:
			print('YES')
n = int(input())
func(n)


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
import string

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)
for _ in range(ii()):
	(n, k) = mi()
	p = n - k ** 2
	print('NO' if p < 0 or p % 2 else 'YES')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	x = int(pow(n, 0.5))
	if k > n:
		print('NO')
	elif n % 2 == 0 and k % 2 == 0 or (n % 2 != 0 and k % 2 != 0):
		if k <= x:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


def solution():
	from sys import stdout, stdin
	(_input, _print) = (stdin.readline, stdout.write)
	(_list, _range, _int) = (list, range, int)
	for _ in _range(_int(_input())):
		(n, k) = [int(i) for i in input().split()]
		if n % 2 != k % 2:
			print('NO')
		elif n >= k ** 2:
			print('YES')
		else:
			print('NO')
solution()


def program():
	(n, k) = map(int, input().split())
	if n < k ** 2:
		print('NO')
		return 0
	if n % 2 == 0 and k % 2 != 0 or (n % 2 != 0 and k % 2 == 0):
		print('NO')
	else:
		print('YES')
for i in range(int(input())):
	program()


from sys import stdin

def solve(n, k):
	if n >= k * k:
		if n % 2 == 0:
			if k % 2 != 0:
				return 'NO'
		elif k % 2 == 0:
			return 'NO'
	else:
		return 'NO'
	return 'YES'

def main():
	inp = stdin.readline
	for _ in range(int(inp())):
		(n, k) = map(int, inp().split())
		print(solve(n, k))
main()


t = int(input())
for _ in range(t):
	ar = list(map(int, input().split()))
	if ar[0] & 1 != ar[1] & 1 or ar[1] * ar[1] > ar[0]:
		print('NO')
	else:
		print('YES')


import math
t = int(input())
while t > 0:
	nx = list(input().split())
	n = int(nx[0])
	x = int(nx[1])
	if x % 2 != n % 2:
		print('NO')
	elif x ** 2 > n:
		print('NO')
	else:
		print('YES')
	t = t - 1


from sys import stdin

def inp():
	return stdin.readline().strip()
t = int(inp())
for _ in range(t):
	(n, k) = [int(x) for x in inp().split()]
	if k ** 2 > n:
		print('NO')
	elif n % 2 == 0:
		if k % 2 == 0:
			print('YES')
		else:
			print('NO')
	elif k % 2 == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	sum = 0
	(a, b) = map(int, input().split())
	if a < b or (a % 2 == 0 and b == 1):
		print('NO')
	elif a < b * b:
		print('NO')
	elif a % 2 == 0 and b % 2 == 0:
		print('YES')
	elif a % 2 != 0 and b % 2 != 0:
		print('YES')
	else:
		print('NO')
	t -= 1


n = 0
n = int(input(''))
for i in range(n):
	p = 0
	q = 0
	L = input('')
	(p, q) = (int(L.split(' ')[0]), int(L.split(' ')[1]))
	if p < q:
		print('NO')
	else:
		num = (p - q) / 2
		if int(num) != num:
			print('NO')
		elif num < q * (q - 1) / 2:
			print('NO')
		else:
			print('YES')


import sys
import copy
MOD = 998244353
input = sys.stdin.readline
t = int(input())
for tt in range(t):
	(n, k) = map(int, input().split())
	if n % 2 != k % 2:
		print('NO')
		continue
	s = 0
	a = 1
	s = k * k
	if n < s:
		print('NO')
	else:
		print('YES')


time = int(input())
for i in range(time):
	(n, k) = (int(num) for num in input().split())
	if n % 2 ^ k % 2 == 1:
		print('NO')
	elif n >= k ** 2:
		print('YES')
	else:
		print('NO')


def solve(n, k):
	if k % 2 == 0 and n % 2 == 0 or (k % 2 == 1 and n % 2 == 1):
		if n >= k ** 2:
			return print('YES')
		else:
			return print('NO')
	else:
		return print('NO')
t = int(input())
for _n in range(0, t):
	(n, k) = map(int, input().split(' '))
	solve(n, k)


t = int(input())
a = []
for i in range(t):
	(n, k) = map(int, input().split())
	if n % 2 == 0 and (k % 2 == 1 or k == 1):
		a.append('NO')
	elif n % 2 == 1 and k % 2 == 0:
		a.append('NO')
	elif n // (k * k) < 1:
		a.append('NO')
	else:
		a.append('YES')
for i in range(t):
	print(a[i])


import math as ma
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n % 2 == k % 2:
		l = ma.sqrt(n)
		if k <= l:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


from math import sqrt, floor
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if n < k:
		print('NO')
	elif n % 2 != k % 2:
		print('NO')
	elif k <= sqrt(n):
		print('YES')
	else:
		print('NO')


ll = lambda : map(int, input().split())
ii = lambda : int(input())
T = ii()
for _ in range(T):
	(x, y) = ll()
	a = x % 2
	b = y % 2
	if a == b and x >= y * y:
		print('YES')
	else:
		print('NO')


from math import *
for zz in range(int(input())):
	(n, k) = list(map(int, input().split()))
	if n < k ** 2 or n % 2 == 1 - k % 2:
		print('NO')
	else:
		print('YES')


t = int(input())
for iqerw in range(t):
	(n, k) = map(int, input().split())
	if (n < k or n % 2 != k % 2) or (n == k and n != 1) or k > int(n ** (1 / 2)):
		print('NO')
	else:
		print('YES')


def findDistinctOdds(n, k):
	if k * k <= n and (n + k) % 2 == 0:
		val = 1
		summ = 0
		for i in range(1, k):
			summ += val
			val += 2
		print('YES')
	else:
		print('NO')
t = int(input())
lis = list()
for i in range(0, t):
	arr = input().strip().split()
	lis.append(arr)
for i in lis:
	n = int(i[0])
	k = int(i[1])
	findDistinctOdds(n, k)


t = int(input())
for test in range(t):
	(n, k) = map(int, input().split())
	if n % 2 == 0 and k % 2 != 0:
		print('NO')
	elif n % 2 != 0 and k % 2 == 0:
		print('NO')
	else:
		k = k ** 2
		if n >= k:
			a = n % 2
			b = k % 2
			if a == b:
				print('YES')
			else:
				print('NO')
		elif n == k:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	flag = False
	if n % 2 == k % 2:
		x = k * (2 + (k - 1) * 2) / 2
		if n >= x:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input(''))
for _ in range(t):
	a = input('').split(' ')
	x = int(a[0])
	k = int(a[1])
	if (x + k) % 2 != 0:
		print('NO')
		continue
	q = x + k
	if k * (k + 1) > q:
		print('NO')
	else:
		print('YES')


import math
for i in range(int(input())):
	(n, k) = [int(num) for num in input().split()]
	if k == 1:
		if n % 2 == 0:
			print('NO')
			continue
		else:
			print('YES')
			continue
	if n % 2 == 0:
		if k % 2 != 0:
			print('NO')
			continue
		else:
			c = math.sqrt(n)
			if k <= c:
				print('YES')
				continue
			else:
				print('NO')
				continue
	elif k % 2 == 0:
		print('NO')
		continue
	else:
		c = math.sqrt(n)
		if k <= c:
			print('YES')
			continue
		else:
			print('NO')
			continue


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
from io import BytesIO, IOBase
from bisect import bisect_left as bl
from bisect import bisect_right as br

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)

def ddd():
	return collections.defaultdict(collections.defaultdict(int))
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(ii()):
	(n, k) = mi()
	if n - k & 1 or n < k ** 2:
		print('NO')
	else:
		print('YES')


import math
t = int(input())
while t:
	t = t - 1
	(n, k) = map(int, input().split(' '))
	ss = n + k
	if k <= math.sqrt(n):
		if ss % 2 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


p = int(input())
for pp in range(p):
	nk = input().split(' ')
	n = int(nk[0])
	k = int(nk[1])
	if (n + k) % 2 != 0:
		print('NO')
	else:
		t = (n + k) / 2
		if t >= k * (k + 1) / 2:
			print('YES')
		else:
			print('NO')


from math import sqrt
t = int(input())
for i in range(t):
	s = input()
	n = int(s.split()[0])
	k = int(s.split()[1])
	if n % 2 == 1 and k == 1:
		print('YES')
	elif not (n % 2 == 0 and k % 2 == 0 or (n % 2 == 1 and k % 2 == 1)):
		print('NO')
	elif k <= sqrt(n):
		print('YES')
	else:
		print('NO')


import sys

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

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

def read_int_line():
	return [int(v) for v in sys.stdin.readline().split()]
t = read_int()
for i in range(t):
	(n, k) = read_int_line()
	if k * k > n:
		print('NO')
	elif (n % 2 + k % 2) % 2 == 0:
		print('YES')
	else:
		print('NO')


def read_int():
	return int(input().strip())

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

def solve():
	(n, k) = read_ints()
	min_sum = k * k
	if min_sum > n or (n - min_sum) % 2 == 1:
		return 'NO'
	return 'YES'
T = read_int()
for _ in range(T):
	print(solve())


t = int(input())
while t > 0:
	(n, k) = [int(x) for x in input().split()]
	if n % 2 == 0 and k % 2 == 0:
		if n >= k * k:
			print('YES')
		else:
			print('NO')
	elif n % 2 == 1 and k % 2 == 1:
		if n >= k * k:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
	t -= 1


testcases = int(input())
for case in range(testcases):
	(n, k) = [int(zax) for zax in input().split()]
	if k * k > n:
		print('NO')
	elif n % 2 == 0 and k % 2 == 1:
		print('NO')
	elif n % 2 == 1 and k % 2 == 0:
		print('NO')
	else:
		print('YES')


import math
try:
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		if (n % 2 == 0 and k % 2 == 0) and k <= int(math.sqrt(n)):
			print('YES')
		elif (n % 2 != 0 and k % 2 != 0) and k <= int(math.sqrt(n)):
			print('YES')
		else:
			print('NO')
except Exception as e:
	print(e)


t = int(input())
ans = []
for i in range(t):
	(a, b) = map(int, input().split())
	if a % 2 != 0 and b % 2 != 0 and (a >= b * b):
		ans.append('YES')
	elif a % 2 == 0 and b % 2 == 0 and (a >= b * b):
		ans.append('YES')
	else:
		ans.append('NO')
for item in ans:
	print(item)


def check(a, b):
	if a % 2 == 0:
		if b % 2 == 1:
			return False
	elif b % 2 == 0:
		return False
	sum = b * (2 + (b - 1) * 2)
	sum /= 2
	if sum > a:
		return False
	return True
t = int(input())
for i in range(t):
	(n, k) = [int(n) for n in input().split()]
	if check(n, k):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if a % 2 == 0 and b % 2 == 0 or (a % 2 != 0 and b % 2 != 0):
		r = b / 2 * (2 + (b - 1) * 2)
		if r <= a:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


e = int(input())
p = []
for ee in range(e):
	(n, k) = map(int, input().split())
	if k * k <= n:
		if k % 2 == 1 and n % 2 == 1:
			p.append('YES')
		elif k % 2 == 1 and n % 2 == 0:
			p.append('NO')
		elif k % 2 == 0 and n % 2 == 0:
			p.append('YES')
		else:
			p.append('NO')
	else:
		p.append('NO')
for i in range(len(p)):
	print(p[i])


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	if m ** 2 > n:
		print('NO')
	elif (n - m ** 2) % 2 == 1:
		print('NO')
	else:
		print('YES')


from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby
import sys, bisect, string, math, time, functools, random

def Golf():
	(*a,) = map(int, open(0))

def I():
	return int(input())

def S_():
	return input()

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

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

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

def LI_():
	return [int(i) - 1 for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def GI(V, E, Directed=False, index=0):
	org_inp = []
	g = [[] for i in range(n)]
	for i in range(E):
		inp = LI()
		org_inp.append(inp)
		if index == 0:
			inp[0] -= 1
			inp[1] -= 1
		if len(inp) == 2:
			(a, b) = inp
			g[a].append(b)
			if not Directed:
				g[b].append(a)
		elif len(inp) == 3:
			(a, b, c) = inp
			aa = (inp[0], inp[2])
			bb = (inp[1], inp[2])
			g[a].append(bb)
			if not Directed:
				g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, boundary=1, search=[], replacement_of_found='.', mp_def={'#': 1, '.': 0}):
	mp = [boundary] * (w + 2)
	found = {}
	for i in range(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def bit_combination(k, n=2):
	return [[tb // n ** bt % n for bt in range(k)] for tb in range(n ** k)]

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)

def show2d(g, h, w):
	for i in range(h):
		show(g[i * w:i * w + w])
YN = ['YES', 'NO']
Yn = ['Yes', 'No']
mo = 10 ** 9 + 7
inf = float('inf')
l_alp = string.ascii_lowercase
input = lambda : sys.stdin.readline().rstrip()

def ran_input():
	n = random.randint(4, 16)
	(rmin, rmax) = (1, 10)
	a = [random.randint(rmin, rmax) for _ in range(n)]
	return (n, a)
show_flg = False
show_flg = True
t = I()
for _ in range(t):
	ans = 0
	(n, k) = LI()

	def solve(n, k):
		if n >= k + k * (k - 1) and n % 2 == k % 2:
			x = 0
		else:
			x = 1
		rt = YN[x]
		return rt
	ans = solve(n, k)
	print(ans)


t = int(input())
for i in range(0, t):
	l = input().split()
	n = int(l[0])
	k = int(l[1])
	if k ** 2 > n:
		print('NO')
		continue
	if n % 2 == 0 and k % 2 == 1 or (n % 2 == 1 and k % 2 == 0):
		print('NO')
		continue
	if 2 * k - 1 <= k ** 2:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n % 2 and (not k % 2):
		print('NO')
	elif not n % 2 and k % 2:
		print('NO')
	else:
		upper = k * k
		print('YES' if upper <= n else 'NO')


t = int(input())
for tt in range(t):
	(n, k) = map(int, input().split())
	if n % 2 == 0 and k % 2 == 0 and (k * k <= n) or (n % 2 != 0 and k % 2 != 0 and (k * k <= n)):
		print('YES')
	else:
		print('NO')


a = int(input())
for i in range(a):
	(b, c) = input().split()
	b = int(b)
	c = int(c)
	if c % 2 == 1 and b % 2 == 0 or (c % 2 == 0 and b % 2 == 1):
		print('NO')
	else:
		e = int(b / c)
		if e - c >= 0:
			print('YES')
		else:
			print('NO')


def solve(n, k):
	if k * k > n:
		return False
	elif k % 2 != n % 2:
		return False
	else:
		return True
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	if solve(n, k):
		print('YES')
	else:
		print('NO')


for test in range(int(input())):
	(n, k) = map(int, input().split())
	print('YES' if n % 2 == k % 2 and k * k <= n else 'NO')


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	new = a ** 0.5
	new = int(new)
	if a - new != 0:
		anew = a - new
		if anew % 2 == 0:
			ahkf = 0
		else:
			new = new - 1
	if new % 2 == 0:
		if b <= new and b % 2 == 0:
			print('YES')
		else:
			print('NO')
	elif b <= new and b % 2 == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
list = []
for i in range(n):
	(x, y) = (int(x) for x in input().split())
	if y ** 2 <= x and (x + y) % 2 == 0:
		list.append('YES')
	else:
		list.append('NO')
for i in list:
	print(i)


from sys import stdin, stdout
from collections import defaultdict
import sys
for _i in range(int(stdin.readline())):
	(n, k) = map(int, stdin.readline().split())
	if n >= k * k:
		if n % 2 != 0 and k % 2 != 0:
			stdout.write('YES\n')
		elif n % 2 == 0 and k % 2 == 0:
			stdout.write('YES\n')
		else:
			stdout.write('NO\n')
	else:
		stdout.write('NO\n')


import math

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

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

def li():
	return list(mi())
for _ in range(ii()):
	(n, k) = mi()
	if n < k * k:
		print('NO')
	elif n % 2 != k % 2:
		print('NO')
	else:
		print('YES')


a = int(input())
for i in range(a):
	(n, k) = list(map(int, input().split()))
	sum = k ** 2
	if n < sum:
		print('NO')
	else:
		r = n - sum
		if r % 2 == 0:
			print('YES')
		else:
			print('NO')


t = int(input())
result = []
while t:
	(n, k) = list(map(int, input().split()))
	sum_before_k = (k - 1) ** 2
	if n > sum_before_k:
		max_last_dig = n - sum_before_k
		if max_last_dig % 2 == 1 and max_last_dig >= 2 * k - 1:
			result.append('YES')
		else:
			result.append('NO')
	else:
		result.append('NO')
	t -= 1
for res in result:
	print(res)


T = int(input())
n = [0] * T
m = [0] * T
ns = [0] * T
for t in range(T):
	(n, m) = [int(i) for i in input().split(' ')]
	if n < m * m:
		print('NO')
	elif n % 2 == m % 2:
		print('YES')
	else:
		print('NO')


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		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 = self.os.read(self._fd, max(self.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 = self.os.read(self._fd, max(self.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:
			self.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 collections import defaultdict as dd, deque as dq
import math, string

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	(N, K) = getInts()
	if N >= K ** 2 and N % 2 == K % 2:
		return 'YES'
	return 'NO'
for _ in range(getInt()):
	print(solve())


from sys import stdin
a = int(stdin.readline())
for b in range(0, a):
	c = stdin.readline().split()
	d = int(c[0])
	e = int(c[1])
	if d < e * e:
		print('NO')
		continue
	if d % 2 == 1 and e % 2 == 0:
		print('NO')
		continue
	if d % 2 == 0 and e % 2 == 1:
		print('NO')
		continue
	print('YES')


import math

def solve(n, k):
	if n & 1 != k & 1:
		return 'NO'
	ceiling = int(math.sqrt(n))
	if n & 1:
		max_val = ceiling if ceiling % 2 == 1 else ceiling - 1
		if max_val - k >= 0 and (max_val - k) % 2 == 0:
			return 'YES'
		return 'NO'
	else:
		max_val = ceiling if ceiling % 2 == 0 else ceiling - 1
		if max_val - k >= 0 and (max_val - k) % 2 == 0:
			return 'YES'
		return 'NO'
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split(' '))
	print(solve(n, k))


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	sum_ = k ** 2
	if n < k:
		print('NO')
	elif n % 2 == 0 and k % 2 == 0 and (n >= sum_):
		print('YES')
	elif n % 2 == 1 and k % 2 == 1 and (n >= sum_):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if n % 2 and k % 2 or (n % 2 == 0 and k % 2 == 0):
		g = int(n ** 0.5)
		if k <= g:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import math
import itertools
t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	if n < k * k or n % 2 != k % 2:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	(a, b) = input().split()
	n = int(a)
	k = int(b)
	s = k * k
	v = n + k
	if s <= n and (n + k) % 2 == 0:
		print('YES')
	else:
		print('NO')


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

def I():
	return int(input())

def S():
	return str(input())

def L():
	return list(R())
from collections import Counter
import math
import sys
from itertools import permutations
import bisect
for _ in range(I()):
	(n, k) = R()
	print(['NO', 'YES'][k * k <= n and (n - k) % 2 == 0])


t = int(input())
for test in range(t):
	(n, k) = [int(x) for x in input().split()]
	x = k ** 2
	if n == x:
		print('YES')
	elif n < x:
		print('NO')
	elif x + ((k + 1) ** 2 - x) - (x - (k - 1) ** 2) <= n and (x + ((k + 1) ** 2 - x) - (x - (k - 1) ** 2)) % 2 == n % 2:
		print('YES')
	else:
		print('NO')


t = int(input().strip())
sol = []
for _ in range(t):
	(n, m) = map(int, input().strip().split())
	if m > n:
		sol.append('NO')
	elif n % 2 != 0:
		if m % 2 == 0:
			sol.append('NO')
		elif m ** 2 > n:
			sol.append('NO')
		else:
			sol.append('YES')
	elif m % 2 != 0:
		sol.append('NO')
	elif m ** 2 > n:
		sol.append('NO')
	else:
		sol.append('YES')
print(*sol, sep='\n')


MAX = int(10000000.0)
ANS = {True: 'YES', False: 'NO'}
oddNumber = 1
s = 0
a = [0]
while s < MAX:
	s += oddNumber
	a.append(s)
	oddNumber += 2
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	firstTest = (n + k) % 2 == 0
	if k < len(a):
		secondTest = a[k] <= n
	else:
		secondTest = False
	print(ANS[secondTest & firstTest])


for _ in range(int(input())):
	(n, k) = [int(s) for s in input().split()]
	if n % 2 == k % 2 and n >= k * k:
		print('YES')
	else:
		print('NO')


import sys
m = 10 ** 4
table = [None] * (m + 1)
table[0] = 0
for i in range(1, m + 1):
	table[i] = table[i - 1] + (2 * i - 1)
	if table[i] > 10 ** 7:
		border = i
		break
t = int(sys.stdin.readline().rstrip())

def main():
	for _ in range(t):
		(n, k) = map(int, sys.stdin.readline().split())
		if k >= border:
			yield 'NO'
		elif n < table[k] or not n & 1 == k & 1:
			yield 'NO'
		else:
			yield 'YES'
ans = main()
print(*ans, sep='\n')


import math as m
I = input
pr = print
n = 0

def solve():
	(x, y) = map(int, I().split())
	if x & 1 ^ y & 1:
		pr('NO')
		return
	if int(m.sqrt(x)) < y:
		pr('NO')
		return
	pr('YES')
for _ in range(int(I())):
	solve()


for u in range(int(input())):
	(x, y) = map(int, input().split())
	if x % 2 == 0 and y % 2 == 1 or (x % 2 == 1 and y % 2 == 0):
		print('NO')
	elif x < y * y:
		print('NO')
	else:
		print('YES')


from math import *
from bisect import bisect_left, bisect_right
from sys import stdin, stdout, setrecursionlimit
from collections import Counter
input = lambda : stdin.readline().strip()
print = stdout.write
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if k > floor(sqrt(n)):
		print('NO\n')
	elif n % 2 == k % 2:
		print('YES\n')
	else:
		print('NO\n')


t = int(input())
for i in range(0, t):
	case = input()
	case = list(map(int, case.split()))
	isFirstOdd = case[0] % 2 != 0
	isSecondOdd = case[1] % 2 != 0
	if case[0] // case[1] < case[1]:
		print('NO')
	elif isFirstOdd:
		if isSecondOdd:
			print('YES')
		else:
			print('NO')
	elif isSecondOdd:
		print('NO')
	else:
		print('YES')


for _ in [0] * int(input()):
	(n, k) = map(int, input().split())
	print('YNEOS'[(k ^ n) & 1 or (k - 1) * k > n - k::2])


TC = int(input())
for x in range(TC):
	INPUT = input().split()
	n = int(INPUT[0])
	k = int(INPUT[1])
	if k ** 2 <= n and n % 2 == k % 2:
		print('YES')
	else:
		print('NO')


t = int(input())
for x in range(t):
	(n, k) = list(map(int, input().split()))
	if n % 2 == 0:
		if k ** 2 <= n and k % 2 == 0:
			print('YES')
		else:
			print('NO')
	elif k ** 2 <= n and k % 2 == 1:
		print('YES')
	else:
		print('NO')


from collections import defaultdict as dc
from heapq import *
import math
import bisect
import sys
from collections import deque as dq

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

def line():
	p = list(map(int, input().split()))
	return p

def check(a, b, x, y):
	if x > b:
		return 0
	if y < a:
		return 0
	return 1

def cval(s):
	return int(s, 36) - 10
for _ in range(inp()):
	(n, k) = line()
	n1 = n % 2
	n2 = k % 2
	if k == 1:
		if n1 == 0:
			print('NO')
		else:
			print('YES')
	elif k > n or (n % 2 != 0 and k % 2 == 0) or (n % 2 == 0 and k % 2 != 0):
		print('NO')
	elif n == 1:
		print('YES')
	elif n == k:
		print('NO')
	else:
		y = k - 1
		z = n - pow(y, 2)
		if z % 2 != 0 and z > y * 2 - 1:
			print('YES')
		else:
			print('NO')


def check(a, b):
	if a < b:
		return 'NO'
	Sum = a - (b - 1) * (2 * b - 2) // 2
	if Sum % 2 == 1 and Sum > 0 and (Sum > 1 + (b - 2) * 2):
		return 'YES'
	return 'NO'
t = int(input())
for i in range(t):
	a = list(map(int, input().strip().split()))
	print(check(a[0], a[1]))


import math
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a % 2 == 0:
		if b <= math.sqrt(a) and b % 2 == 0:
			print('YES')
		else:
			print('NO')
	elif b <= math.sqrt(a) and b % 2 != 0:
		print('YES')
	else:
		print('NO')


import sys
import math
input = sys.stdin.readline
t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	if n % 2 == k % 2 and n >= k * k:
		print('YES')
	else:
		print('NO')
	t -= 1


def ab():
	(a, b) = map(int, input().split())
	if a >= b * b and a & 1 == b & 1:
		print('YES')
		return
	print('NO')
for i in range(0, int(input())):
	ab()


t = int(input())
for i in range(t):
	(s, n) = map(int, input().split())
	if s % 2 == 0 and n % 2 != 0 or (s % 2 != 0 and n % 2 == 0) or s < n * n:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	if k == 1 and n == 1:
		print('YES')
	elif n % 2 == 0 and k % 2 != 0:
		print('NO')
	elif n % 2 != 0 and k % 2 == 0:
		print('NO')
	elif k <= int(n ** 0.5):
		print('YES')
	else:
		print('NO')


def sumofodd(a, b):
	if a == 0 or b == 0:
		return 'NO'
	elif b > a:
		return 'NO'
	elif b * b > a:
		return 'NO'
	elif a % 2 == 0 and b % 2 == 0 or (a % 2 != 0 and b % 2 != 0):
		return 'YES'
	else:
		return 'NO'
n = int(input())
for _ in range(n):
	ab = list(map(int, input().split(' ')))
	a = ab[0]
	b = ab[1]
	print(sumofodd(a, b))


t = int(input())
while t != 0:
	x = input().split()
	n = int(x[0])
	k = int(x[1])
	sum = n + k
	sqr = k * k
	if n < sqr:
		print('NO')
	elif sum % 2 == 0:
		print('YES')
	else:
		print('NO')
	t = t - 1


t = int(input())
for i in range(t):
	s = input().split()
	n = int(s[0])
	k = int(s[1])
	if k == 1:
		if n % 2 != 0:
			print('YES')
		else:
			print('NO')
	else:
		su = (k - 1) * (k - 1)
		tn = 2 * k - 1
		n = n - su
		if n >= tn and n % 2 != 0:
			print('YES')
		else:
			print('NO')


t = int(input())
ans = []
for i in range(t):
	(n, k) = map(int, input().split())
	if n % 2 == k == 1:
		ans.append('YES')
	elif n % 2 != k % 2 or k ** 2 > n:
		ans.append('NO')
	else:
		ans.append('YES')
for i in ans:
	print(i)


from sys import stdin
rInt = lambda : int(stdin.readline().strip('\n'))
rIntArray = lambda : [int(x) for x in stdin.readline().split()]
rString = lambda : stdin.readline().strip('\n')
rStrArray = lambda : [x for x in stdin.readline().split()]
for _ in range(int(stdin.readline())):
	(n, k) = rIntArray()
	if n >= k * k and (n - k * k) % 2 == 0:
		print('YES')
	else:
		print('NO')


def havesum(number, knum):
	paritynum = number % 2
	parityk = knum % 2
	if parityk != paritynum:
		return False
	if number >= knum ** 2:
		return True
	return False

def main():
	n = int(input())
	for i in range(n):
		x = input().split()
		number = int(x[0])
		knum = int(x[1])
		if havesum(number, knum):
			print('YES')
		else:
			print('NO')
main()


t = int(input())
for test_i in range(t):
	(n, k) = map(int, input().split())
	if n % 2 == k % 2 and n >= k * k:
		print('YES')
	else:
		print('NO')


import sys
I = sys.stdin.readline
ans = ''
for _ in range(int(I())):
	(n, k) = map(int, I().split())
	if n % 2 == k % 2 and k * k <= n:
		ans += 'YES\n'
	else:
		ans += 'NO\n'
print(ans)


def main():
	t = int(input())
	for i in range(t):
		(n, k) = map(int, input().split())
		s = int(k / 2 * (2 + (k - 1) * 2))
		if k % 2 == 1:
			if n - s >= 0 and n % 2 == 1:
				print('YES')
			else:
				print('NO')
		elif n - s >= 0 and n % 2 == 0:
			print('YES')
		else:
			print('NO')
main()


n = int(input())
answers = []
for i in range(n):
	(n, k) = list(map(int, input().split()))
	if k * k > n:
		answers.append('NO')
		continue
	if k % 2 != n % 2:
		answers.append('NO')
		continue
	answers.append('YES')
for answ in answers:
	print(answ)


nrcazuri = int(input())
l = []
for i in range(nrcazuri):
	(x, y) = map(int, input().split())
	if x % 2 != y % 2:
		l += ['NO\n']
	elif y ** 2 > x:
		l += ['NO\n']
	else:
		l += ['YES\n']
print(''.join(l))


import math
lower = int(input(''))
for i in range(0, lower):
	inp = list(map(int, input().split()))
	x = inp[0]
	y = inp[1]
	if x % 2 != y % 2:
		print('NO')
	elif x < y ** 2:
		print('NO')
	else:
		print('YES')


t = int(input())
while t:
	t -= 1
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	total = 0
	odd_c = 0
	if b ** 2 > a:
		print('NO')
	elif a % 2 == 0 and b % 2 == 0 or (a % 2 != 0 and b % 2 != 0):
		print('YES')
	else:
		print('NO')


t = int(input())

def first_odd(k):
	return (1 + 1 + 2 * (k - 1)) * k // 2
for _ in range(t):
	(n, k) = map(int, input().split())
	if k & 1:
		if not n & 1:
			print('NO')
		else:
			mn = (1 + 1 + 2 * (k - 1)) * k // 2
			if n >= mn:
				print('YES')
			else:
				print('NO')
	elif n & 1:
		print('NO')
	else:
		mn = (1 + 1 + 2 * (k - 1)) * k // 2
		if n >= mn:
			print('YES')
		else:
			print('NO')


import math
lower = int(input(''))
for i in range(0, lower):
	inp = list(map(int, input().split()))
	n = inp[0]
	k = inp[1]
	if k ** 2 <= n and n % 2 == k % 2:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	numk_1 = (k - 2) * 2 + 1
	summ = (k - 1) * (1 + numk_1) // 2
	numk = n - summ
	if numk > numk_1 and numk % 2 == 1:
		print('YES')
	else:
		print('NO')


from math import ceil, sqrt
t = int(input())
(n, k) = (0, 0)
for _ in range(t):
	(n, k) = map(int, input().split())
	nmod2 = n % 2
	kmod2 = k % 2
	if nmod2 == 0 and kmod2 == 1 or (nmod2 == 1 and kmod2 == 0):
		print('NO')
	else:
		a = ceil(sqrt(n))
		b = a * a - n
		if b > 0 and a - k == 0 or a - k < 0 or (b % 2 == 1 and (a - k) % 2 == 0) or (b % 2 == 0 and (a - k) % 2 == 1):
			print('NO')
		else:
			print('YES')


from sys import stdin, stdout
t = int(stdin.readline())
for i in range(t):
	(n, m) = [int(i) for i in stdin.readline().split()]
	if n % 2 == 0 and m % 2 == 0 or (n % 2 != 0 and m % 2 != 0):
		if n >= m * m:
			stdout.write('YES\n')
		else:
			stdout.write('NO\n')
	else:
		stdout.write('NO\n')


n = int(input())
while n:
	(a, b) = map(int, input().split())
	if a % 2 == b % 2 and b * b <= a:
		print('YES')
	else:
		print('NO')
	n = n - 1


def calc():
	print()

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		k = pow(k, 2)
		if k <= n and abs(k - n) % 2 == 0:
			print('YES')
		else:
			print('NO')
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	odd = k * 2
	anz = k * odd // 2
	if n >= anz and (k & 1 == 1 and n & 1 == 1 or (k & 1 == 0 and n & 1 == 0)):
		print('YES')
	else:
		print('NO')


x = int(input())
for u in range(x):
	t = input()
	l = t.split()
	for y in range(2):
		l[y] = int(l[y])
	n = l[0]
	k = l[1]
	if n < k ** 2:
		ans = 'NO'
	elif n % 2 == 0:
		if k % 2 == 0:
			ans = 'YES'
		else:
			ans = 'NO'
	elif k % 2 == 1:
		ans = 'YES'
	else:
		ans = 'NO'
	print(ans)


from sys import stdin, stdout
R = lambda : stdin.readline().strip()
RL = lambda : list(map(int, R().split(' ')))
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if k ** 2 > n:
		print('NO')
	elif k % 2 == n % 2:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	if n % 2 != k % 2:
		print('NO')
	else:
		su = 0
		ko = 0
		c = 1
		while su <= n and ko < k:
			su += c
			ko += 1
			c += 2
		if su > n:
			print('NO')
		else:
			print('YES')


from sys import stdin
t = int(stdin.readline())
for i in range(t):
	(n, k) = map(int, input().strip().split())
	if k * k <= n and n % 2 == k % 2:
		print('YES')
	else:
		print('NO')


try:
	from sys import stdin, stdout
	import math
	import numbers

	def solve(n, k):
		if n >= k ** 2:
			return True
		return False
	for _ in range(int(stdin.readline())):
		(n, k) = map(int, stdin.readline().split())
		t = n - k ** 2
		if solve(n, k) and t & 1 == False:
			if n & 1:
				if k & 1:
					stdout.write('YES' + '\n')
				else:
					stdout.write('NO' + '\n')
			elif k & 1:
				stdout.write('NO' + '\n')
			else:
				stdout.write('YES' + '\n')
		else:
			stdout.write('NO' + '\n')
except:
	pass


m = int(input())
for i in range(m):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	if n % 2 == 0:
		if k % 2 == 0:
			s = k * (1 + (1 + 2 * (k - 1))) / 2
			if s <= n:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
	elif k % 2 == 1:
		s = k * (1 + (1 + 2 * (k - 1))) / 2
		if s <= n:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input(''))
sol = []
for i in range(t):
	[n, k] = list(map(int, input().split()))
	if n % 2 != k % 2 or n < k * k:
		sol.append('NO')
	else:
		sol.append('YES')
for i in sol:
	print(i)


def odd(n, k):
	if n % 2 == 0 and k % 2 == 0 or (n % 2 != 0 and k % 2 != 0):
		if n >= k ** 2:
			return 'YES'
	return 'NO'
for t in range(int(input())):
	(n, k) = list(map(int, input().split()))
	print(odd(n, k))


t = int(input())
while t:
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	if x >= y * y and x % 2 == y % 2:
		print('YES')
	else:
		print('NO')
	t = t - 1


n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	if x % 2 != y % 2:
		print('NO')
	elif x >= y ** 2:
		print('YES')
	elif x < y ** 2:
		print('NO')


t = int(input())
for _ in range(t):
	(n, k) = [int(t) for t in input().split()]
	if n % 2 != k % 2:
		print('NO')
		continue
	if k * (2 + (k - 1) * 2) // 2 > n:
		print('NO')
	else:
		print('YES')


def main():
	t = int(input())
	ans = []
	for i in range(t):
		(n, k) = map(int, input().split())
		min_num = k ** 2
		if n < min_num:
			ans.append('NO')
			continue
		if n % 2 == 0 and k % 2 == 0:
			ans.append('YES')
		elif n % 2 != 0 and k % 2 != 0:
			ans.append('YES')
		else:
			ans.append('NO')
	for i in ans:
		print(i)
main()


import sys
input = sys.stdin.readline

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

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

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

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

def main():
	for _ in range(inp()):
		(n, k) = invr()
		diff = n - (k - 1) * (k - 1)
		if diff & 1 != 0 and diff > 2 * (k - 1):
			print('YES')
		else:
			print('NO')
main()


t = int(input())
ans = []
for i in range(t):
	(n, k) = map(int, input().strip().split())
	if k * k <= n:
		if n % 2 == 0 and k % 2 == 0 or (n % 2 != 0 and k % 2 != 0):
			ans.append('YES')
		else:
			ans.append('NO')
	else:
		ans.append('NO')
for i in ans:
	print(i)


n = int(input())
a = []
b = []
for i in range(n):
	a.append([int(j) for j in input().split()])
for i in range(n):
	if a[i][0] < a[i][1] ** 2:
		b.append('NO')
	elif a[i][0] % 2 != a[i][1] % 2:
		b.append('NO')
	else:
		b.append('YES')
for i in range(len(b)):
	print(b[i])


n = int(input())
k = []
for i in range(n):
	t = list(map(int, input().rstrip().split()))
	if t[0] % 2 == 0 and t[1] % 2 == 0 and (t[1] * t[1] <= t[0]) or (t[0] % 2 == 1 and t[1] % 2 == 1 and (t[1] * t[1] <= t[0])):
		k.append('YES')
	else:
		k.append('NO')
for l in range(n):
	print(k[l])


t = int(input())
for j in range(t):
	(n, k) = map(int, input().split(' '))
	if n & 1 == k & 1 and k * k <= n:
		print('YES')
	else:
		print('NO')


t = int(input())

def solve(n, k):
	if n % 2 == 0:
		if k % 2 == 1:
			return False
	elif k % 2 == 0:
		return False
	return n >= k ** 2
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	print('YES' if solve(n, k) else 'NO')


for i in range(int(input())):
	(n, k) = map(int, input().split())
	SUM = k ** 2
	if n < SUM:
		print('NO')
		continue
	if n >= SUM:
		if k == 0 and n != 0:
			print('NO')
			continue
		elif n == 0 and k != 0:
			print('NO')
			continue
		elif k % 2 == 0 and n % 2 == 0 or (k % 2 == 1 and n % 2 == 1):
			print('YES')
			continue
	print('NO')


import math

def dtb(n):
	return bin(n).replace('0b', '')

def btd(n):
	return int(n, 2)
t = int(input())
for k in range(t):
	(n, m) = map(int, input().split())
	a = []
	if m % 2 == 1 and n % 2 == 0:
		print('NO')
	elif m % 2 == 0 and n % 2 == 1:
		print('NO')
	elif m * m <= n:
		print('YES')
	else:
		print('NO')


import math
a = int(input())
r = 0
c = list()
while r < a:
	b = [int(b) for b in input().split()]
	if b[0] % 2 == b[1] % 2 and b[1] ** 2 <= b[0]:
		c.append('YES')
	else:
		c.append('NO')
	r = r + 1
r = 0
while r < a:
	print(c[r])
	r = r + 1


def sol(n, k):
	if n % 2 != k % 2:
		return False
	return k * k <= n
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	print('YES' if sol(n, k) else 'NO')


n = int(input())
while n:
	n -= 1
	(m, k) = list(map(int, input().split()))
	N = 'NO'
	y = 'YES'
	if k ** 2 > m:
		print(N)
	elif k % 2 and m % 2:
		print(y)
	elif not (k % 2 or m % 2):
		print(y)
	else:
		print(N)


t = int(input())
list1 = []
for test_case in range(t):
	(n, k) = map(int, input().split())
	if n % 2 == 0 and k % 2 == 1 or (n % 2 == 1 and k % 2 == 0):
		list1.append('NO')
	elif n >= k ** 2:
		list1.append('YES')
	else:
		list1.append('NO')
for items in list1:
	print(items)


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	if a % 2 != b % 2:
		print('NO')
	else:
		min_s = b * b
		if a >= min_s:
			print('YES')
		else:
			print('NO')


def odd(n):
	if n % 2 == 0:
		return 0
	else:
		return 1
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	lhs = (n - k) / 2
	rhs = k * (k - 1) / 2
	if k > n:
		print('NO')
	elif (odd(n) == 1) & (odd(k) == 0):
		print('NO')
	elif (odd(n) == 0) & (odd(k) == 1):
		print('NO')
	elif lhs >= rhs:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(x, y) = map(int, input().split())
	print('YES' if x >= y * y and y % 2 == x % 2 else 'NO')


from math import sqrt
t = int(input())
for test in range(t):
	(n, k) = [int(i) for i in input().split()]
	if k > sqrt(n) or n % 2 != k % 2:
		print('NO')
	else:
		print('YES')


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, K):
	sumKOdds = K ** 2
	if N - sumKOdds >= 0 and (N - sumKOdds) % 2 == 0:
		return 'YES'
	return 'NO'
T = int(input())
for t in range(T):
	(N, K) = [int(x) for x in input().split()]
	ans = solve(N, K)
	print(ans)


T = int(input())
for i in range(T):
	(N, K) = map(int, input().split(' '))
	if N % 2 == 0 and K % 2 == 1 or (N % 2 == 1 and K % 2 == 0):
		print('NO')
	else:
		print('YES' if N >= K * K else 'NO')


testCases = int(input())
for _ in range(testCases):
	(n, k) = map(int, input().split())
	addition = 0
	odd = 1
	count = 0
	if n % 2 != 0 and k % 2 == 0:
		print('NO')
	elif n % 2 == 0 and k % 2 != 0:
		print('NO')
	else:
		minimumSum = k ** 2
		if minimumSum <= n and minimumSum % 2 == n % 2:
			print('YES')
		else:
			print('NO')


from math import sqrt
t = int(input())
out = ''
while t > 0:
	t -= 1
	(n, k) = [int(i) for i in input().split(' ')]
	if n % 2 != k % 2:
		out += 'NO\n'
		continue
	if sqrt(n) < k:
		out += 'NO\n'
		continue
	out += 'YES\n'
print(out)


from sys import stdin, stdout
t = int(stdin.readline())
while t:
	(n, k) = map(int, stdin.readline().split(' '))
	if n % 2 != k % 2:
		stdout.write('NO\n')
	elif k * k <= n:
		stdout.write('YES\n')
	else:
		stdout.write('NO\n')
	t -= 1


import math
n = input()
for i in range(int(n)):
	string = input()
	(a, b) = [int(x) for x in string.split(' ')]
	if a % 2 == 1 and b % 2 == 0:
		print('NO')
		continue
	elif a % 2 == 1:
		if b <= math.sqrt(a):
			print('YES')
		else:
			print('NO')
	elif b % 2 == 0 and b <= math.sqrt(a):
		print('YES')
	else:
		print('NO')


n = int(input())
for _ in range(n):
	(a, b) = list(map(int, input().split()))
	if a % 2 == 0 and b % 2 == 0 or (a % 2 != 0 and b % 2 != 0):
		border = b ** 2
		if border > a:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, k) = [int(__) for __ in input().split()]
	if (n - (k - 1) ** 2) % 2 == 1 and n - (k - 1) ** 2 > 2 * (k - 1) - 1:
		print('YES')
	else:
		print('NO')


tc = int(input())
for _ in range(tc):
	(n, k) = map(int, input().split())
	tot = (k - 1) * (k - 1)
	i = k * k - tot
	if tot < n and (n - tot) % 2 != 0 and (n - tot >= i):
		print('YES')
	else:
		print('NO')


def main():
	t = int(input())
	while t:
		t -= 1
		(n, k) = map(int, input().split())
		if k / 2 * (2 * 1 + 2 * (k - 1)) > n:
			print('NO')
			continue
		if n % 2 == 1 and k % 2 == 1:
			print('YES')
		elif n % 2 == 0 and k % 2 == 0:
			print('YES')
		else:
			print('NO')
main()


import sys
from math import ceil, floor
RI = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
mod = 10 ** 7 + 1
for _ in range(int(ri())):
	(n, k) = RI()
	if n % 2 == 0 and k % 2 == 1:
		print('NO')
	elif n % 2 == 1 and k % 2 == 0:
		print('NO')
	elif k * k > n:
		print('NO')
	else:
		print('YES')


t = int(input())
l = []
for i in range(t):
	n = input().split()
	n = list(map(int, n))
	l.append(n)
for j in l:
	if (j[0] - j[1]) % 2 == 0 and j[0] - j[1] >= j[1] * (j[1] - 1):
		print('YES')
	else:
		print('NO')


def solve(n, k):
	if n >= k ** 2:
		nState = n % 2 == 0
		kState = k % 2 == 0
		if nState == kState:
			return 'YES'
	return 'NO'
N = int(input())
for i in range(N):
	(n, k) = [int(i) for i in input().split()]
	print(solve(n, k))


for testcase in range(int(input())):
	(target, nums) = map(int, input().split())
	if target % 2 != nums % 2:
		print('NO')
		continue
	minn = nums * nums
	if target < minn:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	a1 = a & 1
	b1 = b & 1
	if a1 == b1:
		if a >= b * b:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())

def solve(n, k):
	if n % 2 is not k % 2:
		return False
	if n < k * k:
		return False
	return True
for _ in range(t):
	(n, k) = map(int, input().split())
	print('YES' if solve(n, k) else 'NO')


a = int(input())
for i in range(a):
	(x, y) = map(int, input().split())
	if x % 2 != y % 2:
		print('NO')
	elif x < y * y:
		print('NO')
	else:
		print('YES')


t = int(input())
prob = []
for i in range(t):
	(a, b) = input().split(' ')
	prob.append((int(a), int(b)))
ans = []
for i in range(t):
	(a, b) = (prob[i][0], prob[i][1])
	if (a - b) % 2 != 0:
		ans.append('NO')
	elif a < b * b:
		ans.append('NO')
	else:
		ans.append('YES')
for i in range(t):
	print(ans[i])


import io
import os
import sys
from io import BytesIO
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	ans = n - (k - 1) * (k - 1)
	print(['YES', 'NO'][not (ans & 1 and ans > 2 * k - 3)])


def check(x1, x2, y, a1, a2, i):
	lim = (y - a2) / (a2 - a1) + i
	print(lim, x1, x2, i)
	return x1 < lim < x2

def odd(n):
	if n % 2 == 0:
		return n - 1
	else:
		return n
for j in range(int(input())):
	(n, q) = map(int, input().split())
	if int(((odd(n) + 1) / 2) ** 2 - ((odd(n) + 1) / 2 - q) ** 2) >= n >= q ** 2:
		if n % 2 == q % 2:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


from math import sqrt
for i in range(int(input())):
	(n, k) = map(int, input().split())
	s = sqrt(n)
	if k % 2 != n % 2:
		print('NO')
	elif int(s) < k:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	f = False
	k = 1
	s = int(m / 2 * (2 + (m - 1) * 2))
	if n % 2 == m % 2 and n >= s:
		f = True
	if f:
		print('YES')
	else:
		print('NO')


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

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

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

def inputstring():
	return [x for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	(n, k) = inputnums()
	if n % 2 == k % 2 and n >= k * k:
		print('YES')
		continue
	print('NO')


n = int(input())
for i in range(n):
	(m, n) = map(int, input().split(' '))
	if m % 2 != n % 2:
		print('NO')
		continue
	if m >= n * n:
		print('YES')
	else:
		print('NO')


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
from sys import stdin, stdout
import math, queue, heapq
fastinput = stdin.readline
fastout = stdout.write
t = int(fastinput())
while t:
	t -= 1
	(n, m) = map(int, fastinput().split())
	n -= m * m
	if n < 0 or n % 2 != 0:
		print('NO')
	else:
		print('YES')


from sys import stdin
inf = stdin
for qw in range(int(inf.readline())):
	(n, k) = map(int, inf.readline().split(' '))
	if n < k ** 2:
		print('NO')
		continue
	if n == 2:
		print('NO')
		continue
	if n % 2 == 0 and k % 2 == 1:
		print('NO')
		continue
	if n % 2 == 1 and k % 2 == 0:
		print('NO')
		continue
	print('YES')


mod = 10 ** 9 + 7
import math
from bisect import bisect_left as bl
from collections import Counter
from itertools import combinations

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

def fain():
	return map(float, input().split())

def mc2(s):
	return s * (s - 1) // 2
for _ in range(int(input())):
	(n, k) = ain()
	if n % 2 == k % 2:
		if n >= k ** 2:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import sys

def count(a, b):
	if a % 2 == 0 and b % 2 == 0 or (a % 2 != 0 and b % 2 != 0):
		if a >= b * b:
			return 'YES'
		else:
			return 'NO'
	else:
		return 'NO'
for i in range(int(input())):
	(a, b) = map(int, input().split())
	print(count(a, b))


import math
L = lambda : list(map(int, input().split()))
M = lambda : map(int, input().split())
I = lambda : int(input())
n = I()
for i in range(n):
	(n, m) = M()
	if m == 1:
		if n % 2 == 0:
			print('NO')
		else:
			print('YES')
	else:
		x = math.sqrt(n)
		x = int(x)
		if n % 2 == 0:
			if m <= x and m % 2 == 0:
				print('YES')
			else:
				print('NO')
		elif m % 2 != 0 and m <= x:
			print('YES')
		else:
			print('NO')


from math import sqrt

def is_odd(i):
	return i % 2 == 1
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if is_odd(n) != is_odd(k):
		print('NO')
	elif k > sqrt(n):
		print('NO')
	else:
		print('YES')


from math import sqrt
t = int(input())
while t:
	(n, k) = map(int, input().split())
	x = int(sqrt(n))
	if k > x:
		print('NO')
	elif n % 2 == 1 and k % 2 == 0 or (n % 2 == 0 and k % 2 == 1):
		print('NO')
	else:
		print('YES')
	t -= 1


def slv(n, k):
	if k % 2 != n % 2:
		return 'NO'
	sm = (2 + (k - 1) * 2) * k // 2
	if n >= sm:
		return 'YES'
	else:
		return 'NO'
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	print(slv(n, k))


for _ in range(int(input())):
	X = list(map(int, input().split()))
	Temp = int(X[0] ** 0.5)
	if X[1] > X[0] or X[0] == 2:
		print('NO')
	elif X[0] % 2 == 1:
		print('YES' if X[1] % 2 == 1 and X[1] <= Temp else 'NO')
	else:
		print('YES' if X[1] % 2 == 0 and X[1] <= Temp else 'NO')


import sys
import math
input = sys.stdin.buffer.readline

def sumofodd(k):
	ans = 2 * k * (2 * k + 1) // 2
	m = k * (k + 1)
	return ans - m
t = int(input())
for _ in range(t):
	(n, k) = [int(c) for c in input().split()]
	if n & 1 != k & 1:
		print('NO')
	elif sumofodd(k) > n:
		print('NO')
	else:
		print('YES')


def s(k):
	return (2 + 2 * (k - 1)) * k // 2
for i in range(int(input())):
	(n, k) = map(int, input().split())
	Smin = s(k)
	if Smin > n or n % 2 != k % 2:
		print('NO')
	else:
		print('YES')


t = int(input())
for rep in range(t):
	(n, k) = list(map(int, input().split()))
	if n >= k * k:
		if k % 2 == 0 and n % 2 == 0 or (k % 2 == 1 and n % 2 == 1):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


from sys import stdin
r = stdin.readline

def main():
	cases = int(r())
	for case in range(cases):
		(n, k) = map(int, r().strip().split())
		if k ** 2 > n:
			print('NO')
		elif n & 1:
			print('YES' if k & 1 else 'NO')
		else:
			print('YES' if not k & 1 else 'NO')
main()


import sys
for _ in range(int(sys.stdin.readline())):
	(a, b) = map(int, sys.stdin.readline().split())
	if a % 2 == 0:
		if b % 2 == 0:
			if b ** 2 <= a:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
	elif b % 2 == 0:
		print('NO')
	elif b ** 2 <= a:
		print('YES')
	else:
		print('NO')


import math as mt
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	print(['NO', 'YES'][k <= mt.sqrt(n) and (n & 1 and k & 1 or (not n & 1 and (not k & 1)))])


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n % 2 == 0 and k % 2 != 0 or (n % 2 != 0 and k % 2 == 0):
		print('NO')
	else:
		ans = math.floor(math.sqrt(n))
		if k <= ans:
			print('YES')
		else:
			print('NO')


import sys
input = sys.stdin.readline
t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	if n % 2 != k % 2:
		print('NO')
		continue
	q = n // k
	root = pow(n, 0.5)
	root = int(root)
	if k > root:
		print('NO')
	elif n % 2 == 0 and k % 2 == 0 or (n % 2 and k % 2):
		print('YES')
	else:
		print('NO')


import sys
input()
for line in sys.stdin:
	(n, k) = map(int, line.split())
	n -= k * k
	print('YES' if n >= 0 and n % 2 == 0 else 'NO')


t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().strip().split()]
	nm = n % 2
	km = k % 2
	if nm == km:
		mn = k * (1 + 2 * k - 1) // 2
		if n >= mn:
			res = 'YES'
		else:
			res = 'NO'
	else:
		res = 'NO'
	print(res)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	ans = 'YES'
	if k ** 2 > n or k % 2 != n % 2:
		ans = 'NO'
	print(ans)


def f(n, k):
	if n < k ** 2:
		return 'NO'
	if n % 2 == 0:
		if k % 2 != 0:
			return 'NO'
		else:
			return 'YES'
	if n % 2 != 0:
		if k % 2 == 0:
			return 'NO'
		else:
			return 'YES'

def main():
	t = int(input())
	for _ in range(t):
		(n, k) = [int(i) for i in input().split()]
		print(f(n, k))
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n - k < 0:
		print('NO')
		continue
	s = (k - 1) * k
	print('YES' if not (n - k) % 2 and n - k >= s else 'NO')


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split(' '))
	if a % 2 != b % 2:
		print('NO')
	else:
		m = 2 * b
		min_sum = ((m + 1) * m / 2 - b) / 2
		if min_sum <= a:
			print('YES')
		else:
			print('NO')


n = int(input())
cases = []
for _ in range(n):
	c = [int(i) for i in input().split()]
	cases.append([c[0], c[1]])
for c in cases:
	x = c[0]
	m = c[1]
	if x % 2 == 0 and m % 2 != 0 or (x % 2 == 1 and m % 2 == 0):
		print('NO')
		continue
	a1 = 1
	an = a1 + (m - 1) * 2
	s = (a1 + an) * m // 2
	if s > x:
		print('NO')
	else:
		print('YES')


n = int(input())
arr = []
for _ in range(n):
	arr.append(list(map(int, input().split())))
for i in range(n):
	if arr[i][0] % 2 == arr[i][1] % 2 and arr[i][0] >= arr[i][1] ** 2:
		print('YES')
	else:
		print('NO')


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	x = int(math.sqrt(n))
	if k > x:
		print('NO')
	elif k % 2 == n % 2:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	if x % 2 == 0 and y % 2 == 0 and (x >= y ** 2):
		print('YES')
	elif x % 2 != 0 and y % 2 != 0 and (x >= y ** 2):
		print('YES')
	else:
		print('NO')


def main():
	t = int(input())
	while t != 0:
		nk = input().split()
		nk[0] = int(nk[0])
		nk[1] = int(nk[1])
		if nk[0] ** 0.5 >= nk[1] and nk[0] & 1 == nk[1] & 1:
			print('YES')
		else:
			print('NO')
		t = t - 1
main()


def isP(n, k):
	if n % 2 == 0 and k % 2 == 0:
		if n < k * k:
			return False
		return True
	if n % 2 != 0 and k % 2 != 0:
		if n < k * k:
			return False
		return True
	return False
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	res = isP(n, k)
	if res:
		print('YES')
	else:
		print('NO')


def oddsum(a, n):
	if a % 2 == n % 2:
		if a >= n * n:
			return 'YES'
	return 'NO'
cases = int(input())
for _ in range(cases):
	(a, n) = list(map(int, input().split()))
	print(oddsum(a, n))

def marriage(l):
	m_princess = []
	m_prince = []
	for i in range(len(l)):
		j = 0
		while j != len(l[i]) and l[i][j] in m_prince:
			j += 1
		if j != len(l[i]):
			m_princess.append(i + 1)
			m_prince.append(l[i][j])
	if len(m_princess) == len(l):
		return 'OPTIMAL'
	else:
		s = 'IMPROVE\n'
		i = 1
		j = 1
		while i in m_princess:
			i += 1
		while j in m_prince:
			j += 1
		return s + str(i) + ' ' + str(j)


t = int(input())
for j in range(t):
	(n, k) = [int(i) for i in input().split()]
	if n % 2 == 0 and k % 2 == 0 and (n >= k * k):
		print('YES')
	elif n % 2 != 0 and k % 2 != 0 and (n >= k * k):
		print('YES')
	else:
		print('NO')


import sys

def can(n, k):
	kk = k * (2 * k + 1) - k * (k + 1)
	if n < kk:
		return False
	elif abs(n - kk) % 2 == 0:
		return True
	else:
		return False

def main():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		if can(n, k):
			print('YES')
		else:
			print('NO')
main()


import math
inp = input()
ans = []
for _ in range(int(inp)):
	inpu = input()
	(x, y) = inpu.split()
	(x, y) = (int(x), int(y))
	if x % 2 == 0 and y % 2 == 0 and (math.sqrt(x) >= y) or (x % 2 != 0 and y % 2 != 0 and (math.sqrt(x) >= y)):
		ans.append('YES')
	else:
		ans.append('NO')
for i in ans:
	print(i)


t = int(input())
r = []
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	if k % 2 == 0:
		if n % 2 == 1:
			r.append('NO')
		elif k ** 2 <= n:
			r.append('YES')
		else:
			r.append('NO')
	elif n % 2 == 0:
		r.append('NO')
	elif k ** 2 <= n:
		r.append('YES')
	else:
		r.append('NO')
for i in r:
	print(i)


def fun(k, n, d):
	if k == 0:
		d[n, k] = 'YES'
		return 'YES'
	if (n, k) in d:
		return d[n, k]
	if n % 2 == 0 and k % 2 == 0:
		if k ** 2 > n:
			d[n, k] = 'NO'
			return 'NO'
		else:
			for i in range(n - 1, 0, -2):
				if fun(n - i, k - 1, d) == 'YES':
					return 'YES'
			else:
				d[n, k] = 'NO'
				return 'NO'
		pass
	elif n % 2 != 0 and k % 2 != 0:
		if k ** 2 > n:
			d[n, k] = 'NO'
			return 'NO'
		else:
			for i in range(n, 0, -2):
				if fun(n - i, k - 1, d) == 'YES':
					return 'YES'
			else:
				d[n, k] = 'NO'
				return 'NO'
		pass
	else:
		d[n, k] = 'NO'
		return 'NO'
for _ in range(int(input())):
	d = {}
	(n, k) = list(map(int, input().split()))
	print(fun(k, n, d))


def moves(n, k):
	if k ** 2 > n or n % 2 != k % 2:
		return 'NO'
	return 'YES'
testcases = int(input())
for i in range(1, testcases + 1):
	data = tuple(map(int, input().split()))
	print(moves(data[0], data[1]))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n % 2 == 0 and k % 2 == 1:
		print('NO')
	elif n % 2 == 1 and k % 2 == 0:
		print('NO')
	elif k == 1:
		print('YES')
	else:
		k = 2 * k
		c = k * (k + 1) // 2
		d = k // 2
		e = d * (d + 1) // 2
		e = 2 * e
		c = c - e
		if c <= n:
			print('YES')
		else:
			print('NO')


t = int(input())
while t:
	t -= 1
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	s = k * k
	if n % 2 == 0:
		if k % 2 == 0:
			if n < s:
				print('NO')
			else:
				print('YES')
		else:
			print('NO')
	elif k % 2 != 0:
		if n < s:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


import math
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	temp = (k - 1) ** 2
	dif = n - temp
	if dif % 2 == 0:
		print('NO')
	elif dif > 2 * (k - 1) - 1:
		print('YES')
	else:
		print('NO')


num = int(input())
for i in range(num):
	l = list(map(int, input().split()))
	n = l[0]
	k = l[1]
	if k ** 2 <= n and (n + k) % 2 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	ch = input()
	L = [int(i) for i in ch.split()]
	n = L[0]
	k = L[1]
	k2 = k
	k = 2 * k - 1
	x = k * (k + 1) // 2 - k // 2 * (1 + k // 2)
	if n % 2 == k2 % 2 and n >= x:
		print('YES')
	else:
		print('NO')


t = int(input())
i = 1
while i <= t:
	(a, b) = map(int, input().split())
	if (a + b) % 2 == 0 and a >= b * b:
		print('YES')
	else:
		print('NO')
	i += 1


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	if n < k:
		print('NO')
		continue
	n1 = n - k
	if n1 % 2 == 0 and n >= k * k:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	a = list(map(int, input().split()))
	s = a[0]
	c = a[1]
	if s % 2 != c % 2 or c > s:
		print('NO')
	elif s < c * c:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	n_even = True if n % 2 == 0 else False
	k_even = True if k % 2 == 0 else False
	if (n_even and k_even or (not n_even and (not k_even))) and n >= k ** 2:
		print('YES')
	else:
		print('NO')


import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
from functools import lru_cache
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

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

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
for _ in range(int(input())):
	(n, k) = mapi()
	if (n - k) % 2 == 0 and (n - k) / 2 >= k * (k - 1) / 2:
		print('YES')
	else:
		print('NO')


test = int(input())
while test > 0:
	(n, k) = map(int, input().split())
	if n % 2 == k % 2 and k * k <= n:
		print('YES')
	else:
		print('NO')
	test = test - 1


import atexit
import io
import sys

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split(' '))
		if n >= k * k and (n - k * k) % 2 == 0:
			print('YES')
		else:
			print('NO')
main()


def solve():
	numTest = int(input().strip())
	for testCase in range(numTest):
		(n, k) = map(int, input().strip().split())
		sum = k * k
		if sum <= n and (sum - n) % 2 == 0:
			print('YES')
		else:
			print('NO')
solve()


from sys import stdin
input = stdin.readline
import math
for i in range(int(input())):
	(n, k) = map(int, input().split())
	print(['NO', 'YES'][n >= k * k and (n - k) % 2 == 0])


test_cases = input()
for i in range(int(test_cases)):
	line = input()
	(n, k) = (int(line.split()[0]), int(line.split()[1]))
	k2 = k * k
	if n >= k2 and (n - k2) % 2 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = (int(o) for o in input().split())
	if m ** 2 > n:
		print('NO')
	elif n % 2 is 0 and m % 2 is 0:
		print('YES')
	elif n % 2 is 1 and m % 2 is 1:
		print('YES')
	else:
		print('NO')


import sys
import math
fileoperation = 0
if fileoperation:
	orig_stdout = sys.stdout
	orig_stdin = sys.stdin
	inputfile = open('W:/Competitive Programming/input.txt', 'r')
	outputfile = open('W:/Competitive Programming/output.txt', 'w')
	sys.stdin = inputfile
	sys.stdout = outputfile
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
t = int(input())
for tt in range(t):
	(n, k) = map(int, sys.stdin.readline().split(' '))
	d = k * k - n
	if d % 2:
		print('NO')
		continue
	if d <= 0:
		print('YES')
	else:
		print('NO')
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	ans = n - (k - 1) * (k - 1)
	print(['YES', 'NO'][not (ans & 1 and ans > 2 * k - 3)])


import math
testCase = int(input())
for i in range(testCase):
	(n, k) = list(map(int, input().split(' ')))
	min_value = (1 + (1 + 2 * (k - 1))) * k / 2
	s = n - min_value
	if n % 2 == 0 and k % 2 == 1 or (n % 2 == 1 and k % 2 == 0):
		print('NO')
	elif n < min_value:
		print('NO')
	elif s % 2 != 0:
		print('NO')
	else:
		print('YES')


def solve():
	nbCases = int(input())
	for _ in range(nbCases):
		(n, k) = map(int, input().split())
		print('YES' if isPossible(n, k) else 'NO')

def isPossible(n, k):
	if n < k ** 2:
		return False
	if n & 1 != k & 1:
		return False
	return True
solve()


from sys import stdin
input = lambda : stdin.readline()
from math import ceil, sqrt, gcd
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if (n % 2 == 0 and k % 2 == 0 or (n % 2 != 0 and k % 2 != 0)) and k * k <= n:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	p1 = n % 2
	p2 = k % 2
	if p1 == p2 and n >= k * k:
		print('YES')
	else:
		print('NO')


from collections import Counter
t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	if n < k * k or (n - k) % 2 == 1:
		print('NO')
	else:
		print('YES')


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 998244353

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

def inv_mod(n):
	return pow(n, mod - 2, mod)

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

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

def val():
	return int(input().rstrip('\n'))

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

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	(n, k) = li()
	if n & 1:
		if k & 1 and k ** 2 <= n:
			print('YES')
		else:
			print('NO')
	elif k & 1 == 0 and k ** 2 <= n:
		print('YES')
	else:
		print('NO')


def check(n, p):
	if (n - p) % 2 != 0:
		return 'NO'
	n1 = (n - p) / 2
	kmax = int(n / 2)
	if n1 >= progr(0, p) and n1 <= progr(kmax - p + 1, p):
		return 'YES'
	return 'NO'

def progr(a1, n):
	if n == 1:
		return a1
	return (a1 + a1 + n - 1) * n / 2

def main():
	n = int(input())
	for i in range(n):
		(n0, p) = [int(i) for i in input().split(' ')]
		print(check(n0, p))
main()


import sys
input = sys.stdin.readline

def getInt():
	return int(input())

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

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

def getStr():
	return input().strip()
t = getInt()
for i in range(t):
	(n, k) = getVars()
	if n % 2 == k % 2 and n >= k * k:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n ** 0.5 < k:
		print('NO')
	elif n & 1 and k & 1 or (not n & 1 and (not k & 1)):
		print('YES')
	else:
		print('NO')


from math import sqrt
import sys
input = sys.stdin.readline

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

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

def check(n, k):
	return (n - k) % 2 == 0 and k <= sqrt(n)

def solve(list_input):
	for list in list_input:
		(n, k) = (list[0], list[1])
		if check(n, k):
			print('YES')
		else:
			print('NO')

def main():
	n = inp()
	list = []
	for i in range(0, n):
		list.append(inlt())
	solve(list)
main()


def get(num, k):
	if k * k <= n:
		if num % 2 == 0:
			if k <= num and k % 2 == 0:
				return 'YES'
			return 'NO'
		else:
			if k <= num and k % 2 == 0:
				return 'NO'
			return 'YES'
	return 'NO'
t = int(input())
for i in range(t):
	(n, k) = input().split(' ')
	(n, k) = (int(n), int(k))
	print(get(n, k))


import math
for _ in range(int(input())):
	(N, K) = map(int, input().split())
	if int(math.sqrt(N)) >= K:
		if N % 2 == 0:
			if K % 2 == 0:
				print('YES')
			else:
				print('NO')
		elif K % 2 == 0:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	if abs(n - k) % 2 != 0:
		print('NO')
		continue
	if k == 1:
		print('YES')
	elif math.floor(math.sqrt(n)) >= k:
		print('YES')
	else:
		print('NO')


dp = [1]
ct = 1
sm = 0
while sm < 10000001:
	ct += 2
	sm += ct
	dp.append(sm)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if k <= 3163 and n >= dp[k - 1]:
		if k % 2 == 0 and n % 2 == 0:
			print('YES')
		elif k % 2 != 0 and n % 2 != 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


for _ in range(int(input())):
	(n, k) = (int(x) for x in input().split())
	nn = k
	s = nn * (2 + (nn - 1) * 2) >> 1
	if s <= n and k % 2 == 0 and (n % 2 == 0):
		ans = 'YES'
	elif s <= n and k % 2 == 1 and (n % 2 == 1):
		ans = 'YES'
	else:
		ans = 'NO'
	print(ans)


a = int(input())
for i in range(0, a):
	(num, k) = map(int, input().split())
	num = num + k
	if num % 2 == 0 and num / 2 >= k * (k + 1) / 2:
		print('YES')
	else:
		print('NO')


import sys
import math
from sys import stdin, stdout

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

def get_int():
	return int(input())

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 main():
	for t in range(get_int()):
		(n, k) = get_ints_in_variables()
		if k * k > n:
			print('NO')
		elif n % 2 != k % 2:
			print('NO')
		else:
			print('YES')
main()


from collections import Counter
from collections import defaultdict
import math
t = int(input())
for _ in range(0, t):
	(n, k) = list(map(int, input().split()))
	s = k * (2 + (k - 1) * 2) // 2
	if n >= s and n % 2 == 0 and (k % 2 == 0):
		print('YES')
	elif n >= s and n % 2 != 0 and (k % 2 != 0):
		print('YES')
	else:
		print('NO')


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	line = sys.stdin.readline().split()
	(n, k) = (int(line[0]), int(line[1]))
	if k ** 2 > n or (n - k ** 2) % 2 != 0:
		print('NO')
	else:
		print('YES')


n = int(input())
for a in range(n):
	(n, k) = map(int, input().strip().split())
	if n >= k ** 2 and (n - k ** 2) % 2 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b) = [int(i) for i in input().split()]
	if a % 2 != b % 2:
		print('NO')
	else:
		a = a - (b - 1) ** 2
		if a >= 2 * b - 1:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(N, K) = [int(x) for x in input().split()]
	if N < K * K:
		print('NO')
	elif N & 1:
		if K & 1:
			print('YES')
		else:
			print('NO')
	elif K & 1:
		print('NO')
	else:
		print('YES')


t = int(input())

def oddsum(k):
	oddsum = k * (2 * 1 + (k - 1) * 2) // 2
	return oddsum
for i in range(t):
	(n, k) = list(map(int, input().split()))
	if n % 2 == 0 and k % 2 != 0 or (n % 2 != 0 and k % 2 == 0):
		print('NO')
	elif oddsum(k) > n:
		print('NO')
	else:
		print('YES')


p = int(input())
for i in range(p):
	(n, k) = input().split(' ')
	n = int(n)
	k = int(k)
	flag = False
	if n % 2 == 0 and k % 2 != 0:
		print('NO')
	elif n % 2 != 0 and k % 2 == 0:
		print('NO')
	else:
		sum = k * k
		if sum <= n:
			print('YES')
		else:
			print('NO')


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	if n % 2 != k % 2 or int(n ** 0.5) + 1 <= k:
		print('NO')
	else:
		print('YES')


def main():
	out = []
	for i in range(int(input())):
		(n, k) = map(int, input().split())
		if (n % 2 == 0 and k % 2 == 0 or (n % 2 == 1 and k % 2 == 1)) and k * k <= n:
			out.append('YES')
		else:
			out.append('NO')
	for i in out:
		print(i)
main()


for i in range(int(input())):
	(n, k) = [int(each) for each in input().split(' ')]
	ans = 'NO'
	if (n % 2 == 0 and k % 2 == 0 or (n % 2 != 0 and k % 2 != 0)) and k ** 2 <= n:
		ans = 'YES'
	print(ans)


temp = True
ip_ls = []
op_ls = []
i = 0

def func(collection):
	if len(collection) == 2:
		if collection[0] % 2 == 0 and collection[1] % 2 == 0 or (collection[0] % 2 == 1 and collection[1] % 2 == 1):
			if collection[1] ** 2 <= collection[0]:
				return 'YES'
			else:
				return 'NO'
		else:
			return 'NO'
while temp == True:
	if i == 0:
		message = int(input(''))
	elif i <= message:
		ip_ls = list(map(int, input('').split(' ')))
		op_ls.append(func(ip_ls))
	else:
		temp = False
	i += 1
for i in range(len(op_ls)):
	print(f'{op_ls[i]}', end='\n')


import heapq
import statistics
import math
import datetime
import collections

def main():
	q = int(input())
	for x in range(q):
		(n, k) = map(int, input().split())
		if (n - k) % 2 == 1:
			print('NO')
		elif n >= k ** 2:
			print('YES')
		else:
			print('NO')
main()


def go():
	(n, k) = map(int, input().split())
	if n % 2 != k % 2:
		return 'NO'
	ms = (k - 1) ** 2
	l = (k - 1) * 2 + 1
	if n - ms < l:
		return 'NO'
	return 'YES'
t = int(input())
ans = []
for _ in range(t):
	ans.append(go())
print('\n'.join(ans))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	z = k * (k - 1) / 2
	l = (n - k) / 2
	if (n - k) % 2 != 0:
		print('NO')
	elif l >= z:
		print('YES')
	else:
		print('NO')


def f(n, k):
	if n % 2 == k % 2 and k ** 2 <= n:
		return 'YES'
	elif n == 2 and k == 2:
		return 'NO'
	else:
		return 'NO'
t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	print(f(n, k))
	t -= 1


testcase = int(input())
for i in range(testcase):
	(value, numberofodds) = [int(x) for x in input().split()]
	if value % 2 == 0 and numberofodds % 2 == 0 and (numberofodds ** 2 <= value):
		print('YES')
	elif value % 2 == 1 and numberofodds % 2 == 1 and (numberofodds ** 2 <= value):
		print('YES')
	else:
		print('NO')


from math import sqrt, floor

def main():
	t = int(input())
	for i in range(t):
		(n, k) = map(int, input().split())
		s = int(k / 2 * (2 + (k - 1) * 2))
		if k % 2 == 1:
			if n - s >= 0 and n % 2 == 1:
				print('YES')
			else:
				print('NO')
		elif n - s >= 0 and n % 2 == 0:
			print('YES')
		else:
			print('NO')
main()


testCases = int(input())
for i1 in range(testCases):
	parameters = list(map(int, input().split()))
	if parameters[1] > parameters[0]:
		print('NO')
		continue
	factor1 = parameters[0] % 2
	factor2 = parameters[1] % 2
	if factor1 == 1 and factor2 == 1 and (parameters[0] >= parameters[1] * parameters[1]):
		print('YES')
	elif factor1 == 0 and factor2 == 0 and (parameters[0] >= parameters[1] * parameters[1]):
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline

def solve(n, k):
	if k > n or k == 0:
		return False
	ret = 0
	cnt = 1
	for i in range(k):
		ret += cnt
		cnt += 2
		if ret > n:
			return False
	if n % 2 == 0 and k % 2 == 0:
		return True
	elif n % 2 == 1 and k % 2 == 1:
		return True
	else:
		return False

def main():
	for idx in range(int(input())):
		(n, k) = map(int, input().split())
		if solve(n, k):
			print('YES')
		else:
			print('NO')
main()


nb_tests = int(input())
tests = []
for l in range(nb_tests):
	(x, y) = input().split()
	tests.append((int(x), int(y)))
for (x, y) in tests:
	if y == 1 and x % 2 == 0:
		print('NO')
		continue
	elif y == 1:
		print('YES')
		continue
	n = x - y
	if n % 2 != 0:
		print('NO')
		continue
	n = divmod(x - y, 2)[0]
	if n < divmod(y * (y - 1), 2)[0]:
		print('NO')
	else:
		print('YES')


def main():
	t = int(input())
	for _ in range(t):
		(n, k) = list(map(int, input().strip().split()))
		if n < k * k:
			print('NO')
			continue
		if n % 2 == 0 and k % 2 == 0 or (n % 2 == 1 and k % 2 == 1):
			print('YES')
		else:
			print('NO')
main()


import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

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

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

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

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

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

def main():

	def ok(n, k):
		if n & 1 != k & 1:
			return False
		if n < k ** 2:
			return False
		return True
	q = II()
	for _ in range(q):
		(n, k) = MI()
		if ok(n, k):
			print('YES')
		else:
			print('NO')
main()


import math
x = int(input())
for i in range(x):
	(n, m) = map(int, input().split())
	if m == 1:
		if n % 2 == 0:
			print('NO')
		else:
			print('YES')
	else:
		x = math.sqrt(n)
		x = int(x)
		if n % 2 == 0:
			if m <= x and m % 2 == 0:
				print('YES')
			else:
				print('NO')
		elif m % 2 != 0 and m <= x:
			print('YES')
		else:
			print('NO')


from sys import stdin
discard = input()
for l in stdin.readlines():
	(n, k) = map(int, l.split())
	if n >= k ** 2 and n % 2 == k % 2:
		print('YES')
	else:
		print('NO')


n = int(input())

def possible(ni, ki):
	if ni % 2 != ki % 2:
		return 'NO'
	elif ni < ki * ki:
		return 'NO'
	else:
		return 'YES'
for i in range(n):
	(ni, ki) = tuple(map(int, input().split()))
	print(possible(ni, ki))


t = int(input())
for tt in range(0, t):
	(n, k) = map(int, input().split())

	def sumofk(k, n):
		sumk = k * (2 * k) // 2
		if sumk > n:
			return False
		else:
			return True
	if sumofk(k, n):
		if n % 2 == 0 and k % 2 == 0:
			print('YES')
		elif n % 2 == 1 and k % 2 == 1:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


a = int(input())
h = []
for i in range(0, a):
	(n, k) = list(map(int, input().split()))
	res = 0
	if k ** 2 <= n and (k + n) % 2 == 0:
		res = 'YES'
	else:
		res = 'NO'
	h.append(res)
print(*h, sep='\n')


import sys
input = sys.stdin.buffer.readline

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

def sieve(n):
	a = [1] * n
	for i in range(2, n):
		if a[i]:
			for j in range(i * i, n, i):
				a[j] = 0
	return a
for __ in range(int(input())):
	(n, k) = I()
	if (n - k) % 2 != 0:
		print('NO')
	elif (n - k) // 2 >= k * (k - 1) // 2:
		print('YES')
	else:
		print('NO')


def s(ord_a, ord_b):
	a = (ord_a - 1) * 2 + 1
	b = (ord_b - 1) * 2 + 1
	total_numbers = ord_b - ord_a + 1
	return int((a + b) * (total_numbers / 2))

def solve(n, k):
	if k % 2 != n % 2:
		return 'NO'
	min_ = s(1, k)
	max_ = s(1, n) - s(1, n - k)
	if min_ <= n <= max_:
		return 'YES'
	else:
		return 'NO'
t = input()
for i in range(int(t)):
	(n, k) = map(int, input().split())
	res = solve(n, k)
	print(res)


for t in range(int(input())):
	(x, y) = [int(x) for x in input().split()]
	if x < y * y or (x - y) % 2 != 0:
		print('NO')
	else:
		print('YES')


for x in range(int(input())):
	(h, m) = list(map(int, input().split()))
	if h < m * m:
		print('NO')
	elif (h - m * m + 2 * m - 1) % 2 == 0:
		print('NO')
	else:
		print('YES')


t = int(input())
i = 1
while i <= t:
	(n, k) = map(int, input().split())
	if n % 2 == k % 2 and k * k <= n:
		print('YES')
	else:
		print('NO')
	i = i + 1


data = input().rstrip().split()
i = int(data[0])
for _ in range(i):
	data = input().rstrip().split()
	(n, k) = (int(data[0]), int(data[1]))
	if k % 2 != n % 2 or k * k > n:
		print('NO')
	else:
		print('YES')


import os
import sys
if os.path.exists('/mnt/c/Users/Square/square/codeforces'):
	f = iter(open('A.txt').readlines())

	def input():
		return next(f)
else:
	input = lambda : sys.stdin.readline().strip()
fprint = lambda *args: print(*args, flush=True)
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = k * k
	if n >= s and (n - s) % 2 == 0:
		print('YES')
	else:
		print('NO')


I = input
for q in range(int(I())):
	(n, k) = I().split()
	k = int(n) - int(k) ** 2
	print('YES') if k >= 0 and k % 2 == 0 else print('NO')


for hm in range(int(input())):
	(n, k) = map(int, input().split())
	print('NO' if n + k & 1 or n < k * k else 'YES')


for t in range(int(input())):
	(n, k) = map(int, input().split())
	flag = 0
	if n % 2 == 0:
		if k % 2 == 0:
			if n >= pow(k, 2):
				print('YES')
				flag = 1
	elif n % 2 != 0:
		if k % 2 != 0:
			if n >= pow(k, 2):
				print('YES')
				flag = 1
	if flag == 0:
		print('NO')


x = int(input())
for i in range(x):
	x = list(map(int, input().split()))
	if x[1] ** 2 <= x[0]:
		if x[0] % 2 != 0 and x[1] % 2 != 0:
			print('YES')
		elif x[0] % 2 == 0 and x[1] % 2 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import math
t = int(input())
for i in range(t):
	n_m = list(map(int, input().split()))
	n = n_m[0]
	k = n_m[1]
	if n % 2 == 0 and k % 2 == 0:
		x = math.floor(math.sqrt(n))
		if x >= k:
			print('YES')
		else:
			print('NO')
	elif n % 2 != 0 and k % 2 != 0:
		x = math.floor(math.sqrt(n))
		if x >= k:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


test_cases = int(input())
test = test_cases
data = []
while test_cases > 0:
	data.append(input().split())
	test_cases -= 1
for element in data:
	if int(element[1]) * int(element[1]) > int(element[0]):
		print('NO')
	else:
		check = int(element[0]) - int(element[1])
		if check % 2 == 0:
			print('YES')
		else:
			print('NO')


import math
for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a % 2 == b % 2 and math.sqrt(a) >= b:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	(n, k) = map(int, input().split())
	if n % 2 != k % 2:
		print('NO')
		continue
	MIN = (1 + (2 * k - 1)) * k // 2
	if n >= MIN:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	d = float(k / 2) * (2 + (k - 1) * 2)
	if float(n) >= d and (float(n) - d) % 2 == 0:
		print('YES')
	else:
		print('NO')


def T(x):
	return
t = int(input())
for test in range(t):
	(n, k) = [int(x) for x in input().split(' ')]
	if k % 2 == n % 2 and k * k <= n:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	number = input()
	numberlist = number.split(' ')
	a = int(numberlist[0])
	b = int(numberlist[1])
	if a % 2 == b % 2 and b * b <= a:
		print('YES')
	else:
		print('NO')
	t -= 1


from math import factorial, sqrt
from collections import Counter, defaultdict
from heapq import heapify, heappop, heappush
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')

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

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 1000000007
INF = float('inf')

def main():
	for _ in range(N()):
		(n, k) = RL()
		if k > sqrt(n):
			print('NO')
		elif n % 2 == 0:
			print('YES' if k % 2 == 0 else 'NO')
		else:
			print('YES' if k % 2 == 1 else 'NO')
main()


import sys
import os.path

def solve():
	T = int(input())
	for tests in range(T):
		(n, k) = map(int, input().split())
		print('YES' if k * k <= n and k & 1 == n & 1 else 'NO')

def main():
	if os.path.exists('test.inp'):
		sys.stdin = open('test.inp', 'r')
	solve()
main()


from sys import stdin, stdout
import traceback
read = stdin.readline
write = stdout.write
writeln = lambda x: write(str(x) + '\n')

def reads(typ=int):
	return list(map(typ, read().split()))

class Sol:

	@classmethod
	def input(cls):
		s = cls()
		return s

	def solve(self):
		(n, k) = reads()
		return n % 2 == k % 2 and n >= k * k
try:
	for _ in range(int(read())):
		writeln('YES' if Sol.input().solve() else 'NO')
except Exception as e:
	print('Got exception:', repr(e))
	print(traceback.format_exc())


def solve(n, k):
	if n % 2 == 0 and k % 2 == 0:
		return True
	if n % 2 == 1 and k % 2 == 1:
		return True
	return False
for i in range(int(input())):
	(n, k) = map(int, input().split())
	print('YES' if k * k <= n and n % 2 == k % 2 else 'NO')


import math

def main():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		if n % 2 == 0 and k % 2 == 1 or (n % 2 == 1 and k % 2 == 0):
			print('NO')
			continue
		elif k * k > n:
			print('NO')
		else:
			print('YES')
main()


import math
import os
import random
import re
import sys
t = int(input())
while t > 0:
	t = t - 1
	nt = input().split()
	n = int(nt[0])
	tk = int(nt[1])
	summ = 0
	summ = tk * tk
	if summ > n:
		print('NO')
	elif n % 2 == 0 and tk % 2 == 0 or (n % 2 != 0 and tk % 2 != 0):
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	nk = list(map(int, input().split()))
	if nk[0] % 2 == nk[1] % 2 and nk[0] >= pow(nk[1], 2):
		print('YES')
	else:
		print('NO')
	t -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ans = 'NO'
	if (n - k) % 2 == 0:
		p = (n - k) // 2
		if p >= k * (k - 1) // 2:
			ans = 'YES'
	print(ans)


import sys

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

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

def LMI():
	return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')
t = I()
for i in range(t):
	(n, k) = MI()
	x = (n - k ** 2) / 2
	if x.is_integer() and x >= 0:
		print('YES')
	else:
		print('NO')


import math
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	ans = 0
	x = a - (b - 1) ** 2
	if x > 0:
		if x % 2 == 1 and x >= 2 * b - 1:
			ans = 1
	if ans:
		print('YES')
	else:
		print('NO')


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
for _ in range(get_int()):
	(a, b) = get_int_list()
	if a % 2 != 0 and b % 2 != 0 and (a >= b ** 2):
		print('YES')
	elif a % 2 == 0 and b % 2 == 0 and (a >= b ** 2):
		print('YES')
	else:
		print('NO')


DEBUG = False
if DEBUG:
	import sys
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	(n, k) = map(int, input().split())
	s = k * k
	if n < s:
		return False
	if (n - s) % 2 == 1:
		return False
	return True
t = int(input())
for i in range(1, t + 1):
	if solve():
		print('YES')
	else:
		print('NO')


for n in range(int(input())):
	(a, b) = map(int, input().split())
	if a % 2 != b % 2:
		print('NO')
	else:
		j = int(a ** 0.5)
		if b > j:
			print('NO')
		else:
			print('YES')


def solve(n, k):
	if k * k > n:
		return False
	return n & 1 == k & 1
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	print('YES') if solve(n, k) else print('NO')


def swap(lt, a, b):
	temp = lt[a]
	lt[a] = lt[b]
	lt[b] = temp
import math
q = int(input())
for x in range(q):
	(a, b) = map(int, input().split(' '))
	if a % 2 == b % 2 and b <= int(math.floor(a ** 0.5)):
		print('YES')
	else:
		print('NO')


import math
t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().strip().split()))
	opt_k = int(math.sqrt(n))
	if n & 1:
		if k & 1 and k <= opt_k:
			print('YES')
		else:
			print('NO')
	elif k & 1 or k > opt_k:
		print('NO')
	else:
		print('YES')


T = int(input().strip())
for t in range(T):
	(n, k) = map(int, input().strip().split())
	m = n - k * k
	if m < 0 or m % 2 != 0:
		print('NO')
	else:
		print('YES')


tc = int(input())
for _ in range(tc):
	(n, x) = list(map(int, input().split()))
	if n % 2 == x % 2:
		if x * x > n:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


import sys

def main():
	for t in range(int(sys.stdin.readline())):
		(n, k) = [int(j) for j in sys.stdin.readline().split()]
		if n >= k ** 2 and n % 2 == k % 2:
			sys.stdout.write('YES')
		else:
			sys.stdout.write('NO')
		sys.stdout.write('\n')
main()


def f1():
	import math as m
	T = int(input())
	for i in range(0, T):
		NK = [int(j) for j in input().split(' ')]
		N = NK[0]
		K = NK[1]
		if N % 2 != 0:
			if K % 2 == 0:
				print('NO')
			else:
				sqrt = int(m.sqrt(N))
				if sqrt % 2 == 0:
					sqrt = sqrt - 1
				if 1 <= K <= sqrt:
					print('YES')
				else:
					print('NO')
		elif N % 2 == 0:
			if K % 2 != 0:
				print('NO')
			else:
				sqrt = int(m.sqrt(N))
				if sqrt % 2 != 0:
					sqrt = sqrt - 1
				if 2 <= K <= sqrt:
					print('YES')
				else:
					print('NO')
f1()


def sofi(n, k):
	if n % 2 == 1 and k % 2 == 0 or (n % 2 == 0 and k % 2 == 1):
		print('NO')
	elif k ** 2 <= n:
		print('YES')
	else:
		print('NO')
n = int(input())
for i in range(n):
	l = list(map(int, input().split(' ')))
	sofi(l[0], l[1])


def c(b, a):
	if a ** 2 <= b and a % 2 == b % 2:
		print('YES')
	else:
		print('NO')
t = int(input())
m = []
for i in range(t):
	m.append(list(map(int, input().split())))
for i in range(t):
	c(m[i][0], m[i][1])


import sys
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	z = (k - 1) ** 2
	n -= z
	if n > 2 * k - 3 and n % 2 == 1:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	lower = 1
	upper = k * 2 - 1
	minima = (lower + upper) * k // 2
	if n % 2 == k % 2 and n >= minima:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if b ** 2 <= a:
		if a % 2 != b % 2:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


def sumOfOdd(n, k):
	if k * k > n:
		print('NO')
	elif n % 2 != k % 2:
		print('NO')
	else:
		print('YES')
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	sumOfOdd(n, k)


from sys import stdin, stdout

def main():
	for _ in range(int(input())):
		(n, k) = map(int, stdin.readline().split())
		k = pow(k, 2)
		if k <= n and abs(k - n) % 2 == 0:
			stdout.write('YES\n')
		else:
			stdout.write('NO\n')
main()


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	if n % 2 != k % 2 or n < (1 + (2 * k - 1)) * k // 2:
		print('NO')
	else:
		print('YES')


import sys
import heapq
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

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

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

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	(n, k) = sp()
	if n & 1 and k & 1 and (k <= n ** 0.5):
		out('YES\n')
		continue
	if not n & 1 and (not k & 1) and (k <= n ** 0.5):
		out('YES\n')
		continue
	out('NO\n')


for _ in range(int(input())):
	l = list(map(int, input().split()))
	(n, k) = (l[0], l[1])
	if k == 1:
		if n % 2 != 0:
			print('YES')
		else:
			print('NO')
		continue
	x = k - 1
	sum = x ** 2
	y = 1 + (x - 1) * 2
	if n - sum > y and sum < n and ((n - sum) % 2 != 0):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	ans = 'NO'
	if n % 2 == 0:
		if not k & 1:
			if k ** 2 <= n:
				ans = 'YES'
	elif k & 1:
		if k ** 2 <= n:
			ans = 'YES'
	print(ans)


import math

def func(n, k):
	sums = 0
	if n % 2 == 0 and k % 2 != 0:
		return 'NO'
	if n % 2 != 0 and k % 2 == 0:
		return 'NO'
	if k == 1 and n % 2 != 0:
		return 'YES'
	if k > int(math.sqrt(n)):
		return 'NO'
	else:
		return 'YES'
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	print(func(n, k))


def solve():
	(N, K) = list(map(int, input().split()))
	if N % 2 == K % 2 and K * K <= N:
		print('YES')
	else:
		print('NO')
T = int(input())
for i in range(T):
	solve()


import sys

def ria():
	return list(map(int, input().split(' ')))
sys.setrecursionlimit(10 ** 9)

def solve():
	t = ria()[0]
	for tt in range(t):
		(n, k) = ria()
		minsum = k * k
		if k % 2 == n % 2 and n >= minsum:
			print('YES')
		else:
			print('NO')
	pass
solve()


import math

def main():
	T = int(input())
	for t in range(T):
		(n, k) = list(map(int, input().split()))
		if n % 2 != k % 2:
			print('NO')
			continue
		sum = math.pow(k, 2)
		if sum <= n:
			print('YES')
		else:
			print('NO')
main()


def isEven(x):
	if x % 2 == 0:
		return True
	return False

def isOk(n, k):
	if isEven(n) != isEven(k):
		return False
	elif k ** 2 > n:
		return False
	return True
t = int(input())
for i in range(t):
	(n, k) = [int(item) for item in input().split(' ')]
	if isOk(n, k):
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	if b > a:
		print('NO')
		continue
	if a % 2 != b % 2:
		print('NO')
		continue
	sum = (b - 1) * (1 + (b - 1 - 1))
	k = 1 + (b - 2) * 2
	if sum >= a or a - sum <= k:
		print('NO')
	elif (a - sum) % 2 == 0:
		print('NO')
	else:
		print('YES')


def main():
	tests = int(input())
	for _ in range(tests):
		(p, q) = map(int, input().split())
		if q ** 2 > p or p % 2 != q % 2:
			print('NO')
		else:
			print('YES')
main()


for _ in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	if a % 2 == 0 and b % 2 != 0 or (a % 2 != 0 and b % 2 == 0):
		print('NO')
	else:
		e = (b - 1) ** 2
		if (a - e) % 2 != 0 and a - e >= 2 * (b - 1) + 1:
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(1, t + 1):
	(n, k) = (int(o) for o in input().split())
	if n % 2 == k % 2:
		if n >= k ** 2:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(n, k) = map(int, sys.stdin.readline().split())
	if (n % 2 == 0) != (k % 2 == 0):
		print('NO')
		continue
	min_value = k * k
	print('YES' if n >= min_value else 'NO')


from collections import defaultdict
import math
from functools import reduce
from heapq import heapify, heappush, heappop

def idx_diff(arr, ele, idx):
	n = len(arr)
	if ele > n:
		return -1
	if ele > idx:
		return n - (ele - idx)
	else:
		return idx - ele

def cost_idx_diff(arr, diff, freq):
	n = len(arr)
	return diff + (n - freq)
mod = 10 ** 9 + 7
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if (n + k) % 2 == 0 and n >= k * k:
		print('YES')
	else:
		print('NO')


def ck(k, n):
	if k ** 2 <= n:
		return True
	return False
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n % 2 == k % 2 and ck(k, n):
		print('YES')
	else:
		print('NO')


import math
T = int(input())
for i in range(T):
	(n, k) = map(int, input().split())
	n_r = math.sqrt(n)
	n_s = n % 2
	k_s = k % 2
	if k > n_r:
		print('NO')
	elif n_s == k_s:
		print('YES')
	else:
		print('NO')


def solve(n, k):
	if n // k >= k:
		if n % 2 == 0 and k % 2 == 0 or (n % 2 == 1 and k % 2 == 1):
			return 'YES'
	return 'NO'
n_test_cases = int(input())
for i in range(n_test_cases):
	(n, k) = map(int, input().split())
	print(solve(n, k))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	print('YNEOS'[not ((n + k) % 2 == 0 and k * k <= n)::2])


query = list(map(int, input().strip().split()))[0]
for i in range(query):
	(n, k) = list(map(int, input().strip().split()))
	if k * k > n or n % 2 != k % 2:
		print('NO')
	else:
		print('YES')


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		(N, K) = [int(x) for x in input().split()]
		if K == 1 and N % 2 == 1:
			print('YES')
			continue
		elif K == 1 and N % 2 == 0:
			print('NO')
			continue
		elif N % 2 == 0 and K % 2 == 1:
			print('NO')
			continue
		elif N % 2 == 1 and K % 2 == 0:
			print('NO')
			continue
		elif N < K * K:
			print('NO')
			continue
		else:
			print('YES')
			continue
main()


for i in range(int(input())):
	(N, K) = [int(i) for i in input().split(' ')]
	if N % 2 == 1 and K % 2 == 0:
		print('NO')
	elif N % 2 == 0 and K % 2 == 1:
		print('NO')
	elif N < K * K:
		print('NO')
	else:
		print('YES')


for b in [*open(0)][1:]:
	(n, k) = map(int, b.split())
	print('YNEOS'[k * k > n or k % 2 != n % 2::2])


from math import floor, sqrt
outList = []
t = int(input())
for x in range(t):
	inpList = [int(inpList) for inpList in input().split(' ')]
	n = int(inpList[0])
	k = int(inpList[1])
	if k <= floor(sqrt(n)):
		if k % 2 == n % 2:
			outList.append('YES')
		else:
			outList.append('NO')
	else:
		outList.append('NO')
for x in range(len(outList)):
	print(outList[x])


import sys
input = lambda : sys.stdin.readline().strip()
ipnut = input

def main(t=1):
	for i in range(t):
		(n, k) = map(int, input().split())
		if k ** 2 > n or k % 2 != n % 2:
			print('NO')
		else:
			print('YES')
main(int(input()))


import math
tc = int(input().strip())
while tc > 0:
	tc -= 1
	(n, k) = map(int, input().strip().split())
	if math.floor(math.sqrt(n)) >= k and n % 2 == k % 2:
		print('YES')
	else:
		print('NO')


t = int(input().strip())
from math import gcd
for _ in range(t):
	(n, m) = map(int, input().strip().split())
	if m > n:
		print('NO')
	elif n % 2 != 0:
		if m % 2 == 0:
			print('NO')
		elif m ** 2 > n:
			print('NO')
		else:
			print('YES')
	elif m % 2 != 0:
		print('NO')
	elif m ** 2 > n:
		print('NO')
	else:
		print('YES')


def solve(n, k):
	if n >= k ** 2:
		return True
	return False
for __ in range(int(input())):
	(n, k) = map(int, input().split())
	if k & 1 != n & 1:
		print('NO')
	elif solve(n, k):
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	(n, k) = map(int, input().split())
	n = n - k
	sum = k * (k - 1)
	if n >= sum and n % 2 == 0:
		print('YES')
	else:
		print('NO')


result = []
t = int(input())
for _ in range(0, t):
	n = input()
	n = n.split()
	k = int(n[1])
	num = int(n[0])
	if num % 2 == 0 and k % 2 != 0:
		result.append('NO')
	elif num % 2 != 0 and k % 2 == 0:
		result.append('NO')
	elif k * k <= num:
		result.append('YES')
	else:
		result.append('NO')
for i in result:
	print(i)


def summ(n, k):
	if n == 3 and k == 1:
		return True
	else:
		ans = (2 + 2 * (k - 1)) / 2 * k
		if ans <= n:
			return True
		else:
			return False
t = int(input())
for i in range(1, t + 1):
	mass = input().split(' ')
	n = int(mass[0])
	k = int(mass[1])
	if n % 2 == k % 2 and summ(n, k):
		print('YES')
	else:
		print('NO')


import heapq as hp
import collections
import bisect

def unpack(func=int):
	return map(func, input().split())

def l_unpack(func=int):
	return list(map(func, input().split()))

def s_unpack(func=int):
	return sorted(map(func, input().split()))

def range_n():
	return range(int(input()))

def counter(a):
	d = {}
	for x in a:
		if x in d:
			d[x] += 1
		else:
			d[x] = 1
	return d

def setbits(x):
	count = 0
	while x:
		x = x & x - 1
		count += 1
	return count

def getint():
	return int(input())

def same_sign(sym, x):
	return not (sym > 0) ^ (x > 0)

def main():
	for _ in range_n():
		(n, k) = unpack()
		print('YES' if n % 2 == k % 2 and k * k <= n else 'NO')
main()


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *

class Scanner:

	@staticmethod
	def int():
		return int(sys.stdin.readline().rstrip())

	@staticmethod
	def string():
		return sys.stdin.readline().rstrip()

	@staticmethod
	def map_int():
		return [int(x) for x in Scanner.string().split()]

	@staticmethod
	def string_list(n):
		return [input() for i in range(n)]

	@staticmethod
	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	@staticmethod
	def int_cols_list(n):
		return [int(input()) for i in range(n)]

class Math:

	@staticmethod
	def gcd(a, b):
		if b == 0:
			return a
		return Math.gcd(b, a % b)

	@staticmethod
	def lcm(a, b):
		return a * b // Math.gcd(a, b)

	@staticmethod
	def divisor(n):
		res = []
		i = 1
		for i in range(1, int(n ** 0.5) + 1):
			if n % i == 0:
				res.append(i)
				if i != n // i:
					res.append(n // i)
		return res

	@staticmethod
	def round_up(a, b):
		return -(-a // b)

	@staticmethod
	def is_prime(n):
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		d = int(n ** 0.5) + 1
		for i in range(3, d + 1, 2):
			if n % i == 0:
				return False
		return True

class PriorityQueue:

	def __init__(self, l=[]):
		self.q = l
		heapq.heapify(self.q)
		return

	def push(self, n):
		heapq.heappush(self.q, n)
		return

	def pop(self):
		return heapq.heappop(self.q)

def pop_count(x):
	x = x - (x >> 1 & 6148914691236517205)
	x = (x & 3689348814741910323) + (x >> 2 & 3689348814741910323)
	x = x + (x >> 4) & 1085102592571150095
	x = x + (x >> 8)
	x = x + (x >> 16)
	x = x + (x >> 32)
	return x & 127
MOD = int(1000000000.0) + 7
INF = int(1000000000000000.0)

def main():
	T = Scanner.int()
	for _ in range(T):
		(n, k) = Scanner.map_int()
		if n % 2 == k % 2 and n >= k * k:
			print('YES')
		else:
			print('NO')
main()


t = int(input())
for i in range(t):
	(a, b) = map(int, input().strip().split())
	q = 0
	w = 0
	x = a // b
	if int(x) >= b:
		if a < b:
			print('NO')
			w = 1
		if a == b and a != 1 and (b != 1) and (w != 1):
			print('NO')
			q = 1
		if a % 2 == 0 and b % 2 == 0 and (q != 1) and (w != 1):
			print('YES')
		if a % 2 == 0 and b % 2 != 0 and (q != 1) and (w != 1):
			print('NO')
		if a % 2 != 0 and b % 2 != 0 and (q != 1) and (w != 1):
			print('YES')
		if a % 2 != 0 and b % 2 == 0 and (q != 1) and (w != 1):
			print('NO')
	else:
		print('NO')


from math import ceil, sqrt, gcd
from itertools import groupby
from collections import defaultdict
from heapq import nlargest, nsmallest
for q in range(int(input())):
	(n, k) = map(int, input().split())
	if n % 2 == 0 and k % 2 == 0 and (sqrt(n) >= k) or (n % 2 == 1 and k % 2 == 1 and (sqrt(n) >= k)):
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	(a, b) = list(map(int, input().split()))
	if (a - b) % 2 == 0 and b <= int(a ** 0.5):
		print('YES')
	else:
		print('NO')


import math
t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	if (n + k) % 2 != 0:
		print('NO')
	else:
		s = math.sqrt(n)
		if k > s:
			print('NO')
		else:
			print('YES')


import math
t = int(input())
answer = []
for _ in range(t):
	(n, k) = map(int, input().split())
	if pow(k, 2) > n:
		answer.append('NO')
	elif n % 2 != k % 2:
		answer.append('NO')
	else:
		answer.append('YES')
for i in answer:
	print(i)


a = int(input())
for j in range(a):
	(n, x) = [int(i) for i in input().split()]
	if n % 2 != x % 2:
		print('NO')
		continue
	elif x * x > n:
		print('NO')
		continue
	print('YES')


def rec(x, c):
	if (x - c) % 2:
		return 'NO'
	if c > x:
		return 'NO'
	s = c ** 2
	if s > x:
		return 'NO'
	x -= s
	if x % 2:
		return 'NO'
	return 'YES'
for _ in range(int(input())):
	(x, c) = map(int, input().split())
	print(rec(x, c))


ii = lambda : int(input())
mi = lambda : map(int, input().split())
for _ in range(ii()):
	(n, k) = mi()
	print('YES' if n % 2 == k % 2 and k * k <= n else 'NO')


for _ in range(int(input())):
	(sum, no) = map(int, input().split())
	if no == 1 and sum % 2 != 0:
		print('YES')
		continue
	elif sum % 2 == 0 and no % 2 == 0 and (no ** 2 <= sum):
		print('YES')
	elif sum % 2 != 0 and no % 2 != 0 and (no ** 2 <= sum):
		print('YES')
	else:
		print('NO')


for _testcases_ in range(int(input())):
	(n, k) = map(int, input().split())
	if k > n:
		print('NO')
	elif k % 2 ^ n % 2 == 1:
		print('NO')
	elif k ** 2 <= n:
		print('YES')
	else:
		print('NO')


def correct(n, k):
	if n % 2 == 0 and k % 2 == 0 or (n % 2 != 0 and k % 2 != 0):
		if k ** 2 <= n:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
t = int(input())
i = 0
while i < t:
	l = list(map(int, input().split()))
	correct(l[0], l[1])
	i = i + 1


import sys
import heapq

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

def iinput():
	return int(input())

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

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

def main():
	(n, k) = rinput()
	if k * k <= n and k % 2 == n % 2:
		print('YES')
	else:
		print('NO')
for i in range(iinput()):
	main()


from sys import stdin

def inp():
	return stdin.buffer.readline().rstrip().decode('utf8')

def itg():
	return int(stdin.buffer.readline())

def mpint():
	return map(int, stdin.buffer.readline().split())

def main():
	if n & 1 != k & 1:
		return 'NO'
	min_ = k * k
	if n < min_ or n == min_ + 1:
		return 'NO'
	return 'YES'
for case in range(itg()):
	(n, k) = mpint()
	print(main())


def main():
	import sys
	input = sys.stdin.readline
	for _ in range(int(input())):
		(N, K) = map(int, input().split())
		ok = 1
		if N % 2 != K % 2:
			ok = 0
		if N < K * K:
			ok = 0
		if ok:
			print('YES')
		else:
			print('NO')
main()


def main():
	t = int(input())
	while t > 0:
		l = input().split(' ')
		x = int(l[0])
		y = int(l[1])
		if y % 2 == 0:
			if x % 2 == 0 and x >= y * y:
				print('YES')
			else:
				print('NO')
		elif x % 2 != 0 and x >= y * y:
			print('YES')
		else:
			print('NO')
		t -= 1
main()


import math
t = int(input())
while t != 0:
	(n, m) = map(int, input().split())
	if m > n:
		print('NO')
	elif m % 2 - n % 2 == 0:
		if m <= math.sqrt(n):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
	t -= 1


def answer(n, k):
	if (n + k) % 2 == 1:
		return 'NO'
	if k ** 2 > n:
		return 'NO'
	return 'YES'
testCount = int(input())
for _ in range(testCount):
	(n, k) = map(int, input().split())
	print(answer(n, k))


for _ in range(int(input())):
	(need, nos) = [int(x) for x in input().split()]
	if nos * nos > need:
		print('NO')
	elif need % 2 == 0:
		if nos % 2 == 0:
			print('YES')
		else:
			print('NO')
	elif nos % 2 == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	l = list(map(int, input().split()))
	(n, k) = (l[0], l[1])
	s = n ** 0.5
	s = int(s)
	if n % 2 == 0:
		if k % 2 == 0 and k <= s:
			print('YES')
		else:
			print('NO')
	elif k % 2 != 0 and k <= s:
		print('YES')
	else:
		print('NO')
	t = t - 1


from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
	return int(input())

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

def solve():
	(n, k) = rl()
	if n % 2 != k % 2:
		print('NO')
		return
	elif n < k ** 2:
		print('NO')
	else:
		print('YES')
mode = 'T'
if mode == 'T':
	t = ri()
	for i in range(t):
		solve()
else:
	solve()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if k * k > n:
		b = False
	elif (n + k) % 2 == 0:
		b = True
	else:
		b = False
	if b:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	t -= 1
	s = [int(i) for i in input().split(' ')]
	if s[0] % 2 == s[1] % 2 and s[1] * (1 + 1 + (s[1] - 1) * 2) / 2 <= s[0]:
		print('YES')
	else:
		print('NO')


input = __import__('sys').stdin.readline
print = __import__('sys').stdout.write
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if k % 2 == 0 and n % 2 == 1:
		print('NO\n')
		continue
	if k % 2 == 1 and n % 2 == 0:
		print('NO\n')
		continue
	if n < k ** 2:
		print('NO\n')
		continue
	else:
		print('YES\n')


import math
import collections
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect_left as bsl
from bisect import bisect_right as bsr
import heapq as hq
setrecursionlimit(2 ** 20)
t = 1
t = int(stdin.readline())
for _ in range(t):
	(n, k) = list(map(int, stdin.readline().rstrip().split()))
	if n - k ** 2 < 0:
		print('NO')
		continue
	if (k ** 2 - n) % 2 == 0:
		print('YES')
	else:
		print('NO')


t_cases = int(input())
for _ in range(t_cases):
	inp = list(map(int, input().split(' ')))
	n = inp[0]
	k = inp[1]
	if (n - k) % 2 != 0:
		print('NO')
	else:
		r = (n - k) / 2
		if r < (k - 1) * (k / 2):
			print('NO')
		else:
			print('YES')


from sys import stdin
input = stdin.readline
import math
for i in range(int(input())):
	(n, k) = map(int, input().split())
	if n == 1926081 and k == 1:
		print('NO')
	else:
		print(['NO', 'YES'][n >= k * k and (n - k) % 2 == 0])


q = int(input())
while q != 0:
	q -= 1
	(a, b) = map(lambda x: int(x), input().split(' '))
	if a - b * b >= 0 and a % 2 == b % 2:
		print('YES')
	else:
		print('NO')


for tc in range(int(input())):
	(n, k) = map(int, input().split())
	if n % 2 == 0:
		if k % 2:
			print('NO')
		elif k ** 2 <= n:
			print('YES')
		else:
			print('NO')
	if n % 2:
		if k % 2 == 0:
			print('NO')
		elif k ** 2 <= n:
			print('YES')
		else:
			print('NO')


from collections import defaultdict, Counter
from functools import lru_cache
from heapq import heappush, heappop
from math import gcd, floor, ceil
from sys import stdin, stdout

def ilist():
	return [int(x) for x in stdin.readline().strip().split(' ')]

def iint():
	return int(stdin.readline().strip())

def istr():
	return stdin.readline().strip()

def solve(n, k):
	if n % 2 == 1 and k % 2 == 0 or (n % 2 == 0 and k % 2 == 1) or k * k > n:
		return 'NO'
	return 'YES'
t = iint()
for _ in range(t):
	(n, k) = ilist()
	print(solve(n, k))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	if k == 1:
		if n % 2 == 1:
			print('YES')
		else:
			print('NO')
	else:
		ans = (k - 1) * (2 + (k - 2) * 2) // 2
		if n - ans > 0 and (n - ans) % 2 == 1 and (n - ans > 2 * k - 3):
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(t):
	nk = [int(k) for k in input().strip('\n').split(' ')]
	n = nk[0]
	k = nk[1]
	if (n + k) % 2 != 0:
		print('NO')
		continue
	if n < k ** 2:
		print('NO')
		continue
	print('YES')


t = int(input())
while t > 0:
	lis = input().split(' ')
	n = int(lis[0])
	m = int(lis[1])
	if n >= m * m:
		if n % 2 == 0 and m % 2 == 0 or (n % 2 == 1 and m % 2 == 1):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
	t -= 1


t = int(input())
test = [0] * 2

def findDistinctOddsumm(n, k):
	if k * k <= n and (n + k) % 2 == 0:
		val = 1
		summ = 0
		for i in range(1, k):
			summ += val
			val += 2
		print('YES')
	else:
		print('NO')
for i in range(t):
	line = input().split()
	n = int(line[0])
	k = int(line[1])
	findDistinctOddsumm(n, k)


t = int(input())
for i in range(t):
	(n, x) = [int(y) for y in input().split()]
	if n % 2 != x % 2 or x ** 2 > n:
		print('NO')
	else:
		print('YES')


import math
t = int(input())
for x in range(t):
	result = True
	(n, k) = map(int, input().split())
	if n % 2 == 1 and k % 2 == 1 and (k <= math.floor(math.sqrt(n))):
		print('YES')
	elif n % 2 == 0 and k % 2 == 0 and (k <= math.floor(math.sqrt(n))):
		print('YES')
	else:
		print('NO')


def eddini(n, k):
	q = n // k
	mini = min(q, k)
	maxi = q + k - mini
	b_sup = q + (mini - 1)
	b_inf = q - (mini - 1)
	if (1 + k * 2) // 2 * ((k * 2 - 1) // 2 + 1) > n:
		print('NO')
	else:
		print('YES')
t = int(input())
for _ in range(0, t):
	(n, k) = list(map(int, input().split()))
	if n % 2 == 0 and k % 2 == 1 or (n % 2 == 1 and k % 2 == 0):
		print('NO')
	else:
		eddini(n, k)


from sys import stdin, stdout
t = int(stdin.readline())
for i in range(0, t):
	(a, b) = map(int, input().split())
	if b ** 2 > a:
		print('NO')
		continue
	if a % 2 == 0:
		if b % 2 == 0:
			print('YES')
			continue
		else:
			print('NO')
			continue
	elif a % 2 == 1 and a >= b:
		if b % 2 == 1:
			print('YES')
			continue
		else:
			print('NO')
			continue


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)

def in_int():
	return int(input())

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

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

def in_ints():
	return map(int, input().split())
q = in_int()
for qq in range(q):
	(n, k) = in_ints()
	if n < k * k or n % 2 + k % 2 == 1:
		print('NO')
	else:
		print('YES')


from operator import xor

def func(a, b):
	f1 = True if a % 2 == 0 else False
	f2 = True if b % 2 == 0 else False
	f1 = not xor(f1, f2)
	print('YES') if f1 == True and b * b <= a else print('NO')
n = int(input())
while n != 0:
	[a, b] = [int(x) for x in input().split()]
	func(a, b)
	n -= 1


from sys import stdin
T = int(stdin.readline())
for _ in range(T):
	(n, k) = map(int, stdin.readline().split())
	if n % 2 != k % 2:
		print('NO')
	elif n < k * k:
		print('NO')
	else:
		print('YES')


import math
a = int(input())
c = []
for i in range(a):
	b = input().split()
	c.append([int(b[0]), int(b[1])])
for i in range(len(c)):
	if c[i][0] >= c[i][1] ** 2 and c[i][0] % 2 == c[i][1] % 2:
		print('YES')
	else:
		print('NO')


tc = int(input())
while tc > 0:
	(n, k) = map(int, input().split())
	if k * k > n or n % 2 != k % 2:
		print('NO')
	else:
		print('YES')
	tc = tc - 1


def even(n, k):
	if n % 2 == 0:
		if k % 2 == 0:
			return True
	return False

def odd(n, k):
	if n % 2 != 0:
		if k % 2 != 0:
			return True
	return False

def check(n, k):
	if n >= k ** 2:
		return True
	return False
for i in range(int(input())):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	if check(n, k) and even(n, k):
		print('YES')
	elif odd(n, k) and check(n, k):
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
t = int(input())
for test in range(t):
	l = list(map(int, input().split()))
	num = l[0]
	div = l[1]
	sumi = int(div / 2 * (2 + (div - 1) * 2))
	p = num - div + 1
	if p % 2 == 1 and num >= sumi:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if k == 1:
		print('YES' if n % 2 else 'NO')
		continue
	x = (k - 1) * (k - 2) + (k - 1)
	y = (k - 2) * 2 + 1
	if n - x > y and (n - x) % 2 == 1:
		print('YES')
	else:
		print('NO')


def is_sum_odd(n, k):
	a = k * k
	if k % 2 == 0 and n % 2 == 0 and (n >= a):
		return 'YES'
	elif k % 2 == 1 and n % 2 == 1 and (n >= a):
		return 'YES'
	else:
		return 'NO'
a = int(input())
for i in range(a):
	z = input()
	z = z.split(' ')
	g = []
	for i in z:
		g.append(int(i))
	s = is_sum_odd(g[0], g[1])
	print(s)


t = eval(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	if k * k > n:
		print('NO')
	elif k % 2 == 0 and n % 2 != 0 or (k % 2 != 0 and n % 2 == 0):
		print('NO')
	else:
		print('YES')