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