#include <bits/stdc++.h>
using namespace std;
template <class T>
void read(T &x) {
  T res = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    res = (res << 3) + (res << 1) + c - '0';
    c = getchar();
  }
  x = res * f;
}
const long long N = 200000 + 10;
long long n, t, k;
int main() {
  read(t);
  while (t--) {
    read(n), read(k);
    if (k * k > n) {
      printf("NO\n");
      continue;
    }
    if ((n % 2) == (k % 2))
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
