#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int N = 200500;
void solve() {
  long long n, k;
  cin >> n >> k;
  if ((n + k) % 2 == 0 && n >= k && (n + k) / 2 >= (k * (k + 1)) / 2) {
    cout << "YES\n";
  } else
    cout << "NO\n";
}
int main() {
  ios::sync_with_stdio(false);
  int q = 1;
  cin >> q;
  for (int i = 1; i <= q; i++) {
    solve();
  }
}
