#include <bits/stdc++.h>
using namespace std;
class solution {
 public:
  solution() { ; }
  void solve() {
    long long int t;
    cin >> t;
    while (t--) {
      long long int n, k;
      cin >> n >> k;
      if (n & 1) {
        if (k & 1) {
          long long int sq = k * k;
          if (n < sq)
            cout << "NO\n";
          else
            cout << "YES\n";
        } else
          cout << "NO\n";
      } else {
        if (k & 1)
          cout << "NO\n";
        else {
          long long int sq = k * k;
          if (n < sq)
            cout << "NO\n";
          else
            cout << "YES\n";
        }
      }
    }
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  solution s;
  s.solve();
}
