#include <bits/stdc++.h>
#pragma GCC optimize("O3")
const long long MOD = 1e9 + 7;
using namespace std;
long long n_bits(long long n) {
  long long x = __builtin_popcount(n);
  return x;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    float val = (float)(n - k) / (float)2;
    if (val != (int)val)
      cout << "NO" << endl;
    else {
      float d = (float)k * (float)(k - 1) / (float)2;
      if (d <= val)
        cout << "YES" << endl;
      else {
        cout << "NO" << endl;
      }
    }
  }
  return 0;
}
