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