#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, k;
  cin >> n >> k;
  if ((n % 2 && k % 2 == 0) || (n % 2 == 0 && k % 2) || k * k > n)
    cout << "NO";
  else
    cout << "YES";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
    cout << "\n";
  }
  return 0;
}
