#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
ll test, n, ans, k;
ll exponentation(ll a, ll b, ll mod) {
  ll x = 1;
  ll y = b;
  while (b > 0) {
    if (b & 1) x = (x * y) % mod;
    y = (y * y) % mod;
    b /= 2;
  }
  return x % mod;
}
void solve() {
  cin >> n >> k;
  if (n < k * k || (n - k * k) % 2)
    cout << "NO"
         << "\n";
  else
    cout << "YES\n";
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  cin >> test;
  while (test--) {
    solve();
  }
  return 0;
}
