#include <bits/stdc++.h>
using namespace std;
const long long M = 1e5 + 10, oo = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long n, k, lm;
    cin >> n >> k;
    if (k % 2 == n % 2 && n >= k * k)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
