#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int num_cases;
  cin >> num_cases;
  int n, k;
  long long min_k;
  for (int i = 0; i < num_cases; i++) {
    cin >> n;
    cin >> k;
    if (k == 1) {
      if (n % 2 == 0)
        cout << "NO\n";
      else
        cout << "YES\n";
      continue;
    }
    if (k > n) {
      cout << "NO\n";
      continue;
    }
    min_k = (k - 1) * 2 + 1;
    if (k % 2 == 0)
      min_k = (min_k + 1) * (k / 2);
    else
      min_k = ((min_k + 1) / 2) + ((min_k + 1) * (k / 2));
    if (n < min_k) {
      cout << "NO\n";
      continue;
    } else if (min_k % 2 == n % 2)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
