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