#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
void solve() {
  int n, k;
  cin >> n >> k;
  long long p = 0;
  int lst = 0;
  for (long long i = 1; p < k; i += 2) {
    if (n - i >= 0) {
      n -= i;
      p++;
      lst = i;
    } else {
      break;
    }
  }
  if (p < k) {
    cout << "NO\n";
    return;
  }
  if (n % 2 == 0 && p == k) {
    cout << "YES\n";
    return;
  }
  cout << "NO\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
