#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ull = unsigned long long int;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n, k, t;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    ll temp = n - (k * k);
    cout << ((temp >= 0) and (temp % 2 == 0) ? "YES\n" : "NO\n");
  }
}
