#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  int t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    if (float(n - k) / 2 != (n - k) / 2)
      cout << "NO" << endl;
    else {
      long long num = (n - k) / 2;
      if (num == 1 && k <= 2)
        cout << "YES" << endl;
      else if (num >= k * (k - 1) / 2)
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    }
  }
  return 0;
}
