#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    if (n < k) {
      cout << "NO\n";
      continue;
    }
    long long int nn = n - k;
    long long int val = k * (k - 1) / 2;
    long long int div = nn / 2;
    if ((nn % 2) == 0) {
      if (div >= val)
        cout << "YES\n";
      else
        cout << "NO\n";
    } else {
      cout << "NO\n";
    }
  }
  return 0;
}
