#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const int maxN = 1 << 19;
void solve() {
  long long n, k;
  scanf("%lld%lld", &n, &k);
  printf("%s\n", (k % 2 == n % 2 and k * k <= n) ? "YES" : "NO");
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) solve();
  return 0;
}
