#include <bits/stdc++.h>
using namespace std;
bool Check(int n, int k) {
  if ((n + k) % 2 == 0) return true;
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  string* ans = new string[t];
  for (int i = 0; i < t; i++) {
    int n, k;
    cin >> n >> k;
    if (!Check(n, k))
      ans[i] = "NO";
    else {
      long long minSum;
      minSum = (long long)k * k;
      if (n >= minSum)
        ans[i] = "YES";
      else
        ans[i] = "NO";
    }
  }
  for (int i = 0; i < t; i++) cout << ans[i] << endl;
  delete[] ans;
  return 0;
}
