#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, k;
  scanf("%d", &t);
  while (t-- && scanf("%d %d", &n, &k)) {
    if ((k & 1) == (n & 1) && (long long)(k)*k <= n && n >= k)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
