#include <bits/stdc++.h>
using namespace std;
const int N = 1000 * 100 + 20;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    if (k % 2 == n % 2 && (k * k) <= n)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
