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