#include <bits/stdc++.h>
using namespace std;
template <typename T>
void printvec(vector<T>& vec) {
  for (int i = 0; i < vec.size(); i++) {
    cout << vec[i] << " ";
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    long long int ksq = k * k;
    if (ksq > n) {
      cout << "NO\n";
    } else {
      long long int diff = n - ksq;
      if (diff % 2 == 0) {
        cout << "YES\n";
      } else {
        cout << "NO\n";
      }
    }
  }
}
