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