#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    if (k == 0) {
      if (n == 0) {
        cout << "YES" << endl;
      } else
        cout << "NO" << endl;
      continue;
    }
    if ((n % 2) == (k % 2)) {
      long long int sum = k * k;
      if (n < sum) {
        cout << "NO" << endl;
      } else
        cout << "YES" << endl;
    } else
      cout << "NO" << endl;
  }
}
