#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, i, j, k, m, x, y, a, b, q, l, r;
  cin >> n >> k;
  if (n % 2 != k % 2) {
    cout << "NO\n";
    return;
  }
  if (n < (k * k)) {
    cout << "NO\n";
    return;
  }
  cout << "YES\n";
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
}
