#include <bits/stdc++.h>
using namespace std;
int main() {
  long int tc;
  cin >> tc;
  while (tc--) {
    long int n, k, i;
    cin >> n >> k;
    if ((n % 2 == 0 && k % 2 == 0) || (n % 2 != 0 && k % 2 != 0)) {
      i = sqrt(n);
      if (i >= k)
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    } else
      cout << "NO" << endl;
  }
  return 0;
}
