#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 3e5 + 15;
int n, a[N];
string solve() {
  long long n, k;
  cin >> n >> k;
  long long cur = 0;
  for (int i = 0, ggdem = k; i < ggdem; i++) {
    cur += (2 * i + 1);
    if (cur > n) return "NO";
  }
  if ((n - cur) & 1) return "NO";
  return "YES";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> q;
  while (q--) cout << solve() << "\n";
}
