#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  if (b == 1) return a;
  if (b == 0) return 1;
  long long temp = power(a, b / 2);
  long long ans = temp * temp;
  if (b & 1) ans *= a;
  return ans;
}
long long power(long long a, long long b, long long p) {
  a = a % p;
  if (b == 1) return a;
  if (b == 0) return 1;
  long long temp = power(a, b / 2, p);
  long long ans = (temp * temp) % p;
  if (b & 1) ans = (a * ans) % p;
  return ans % p;
}
long long inv(long long a, long long m) { return power(a, m - 2, m); }
long long degree[100001], ans[100001], vis[100001];
signed main() {
  cin.sync_with_stdio(false);
  long long t;
  t = 1;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    if (k * k > n) {
      cout << "NO\n";
      continue;
    } else {
      if (abs(n - k) % 2 == 0)
        cout << "YES\n";
      else
        cout << "NO\n";
    }
  }
  return 0;
}
