#include <bits/stdc++.h>
using namespace std;
const long long int mod = 998244353;
void solve(int test_index) {
  long long int n, k;
  cin >> n >> k;
  string ans = ((n & 1) == (k & 1) && k * k <= n) ? "YES" : "NO";
  cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int num_tests = 1;
  cin >> num_tests;
  for (int test_index = 1; test_index <= num_tests; test_index++) {
    solve(test_index);
  }
  return 0;
}
