#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int t;
  cin >> t;
  while (t--) {
    ll n, k;
    cin >> n >> k;
    bool boo = true;
    if (n % 2 == 0 && k % 2 != 0)
      boo = false;
    else if (n % 2 != 0 && k % 2 == 0)
      boo = false;
    else if (n < pow(k, 2))
      boo = false;
    if (!boo)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
