#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  int x, y;
  while (t--) {
    cin >> x >> y;
    if (y <= sqrt(x)) {
      if (x % 2 == 0 && y % 2 == 0)
        cout << "YES" << endl;
      else if (x % 2 == 1 && y % 2 == 1)
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    } else
      cout << "NO" << endl;
  }
}
