#include <bits/stdc++.h>
const double PI = 3.141592653589793238460;
using namespace std;
int main() {
  long long int t, n, k;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    if ((n < k * k))
      cout << "NO" << '\n';
    else if ((k % 2) != (n % 2))
      cout << "NO" << '\n';
    else
      cout << "YES" << '\n';
  }
}
