#include <bits/stdc++.h>
using namespace std;
string calc(vector<long long>& abcd) {
  map<long long, int> uni;
  string msg;
  long long a, b, c, d;
  a = abcd[0];
  b = abcd[1];
  c = abcd[2];
  d = abcd[3];
  if (b > d) return "No";
  while (true) {
    a = (a - c) % b + c;
    if (a == c) a += d;
    a -= b;
    uni[a] += 1;
    cout << a << endl;
    if (uni[a] > 1) {
      msg = "Yes";
      break;
    }
    if (a < 0) {
      msg = "No";
      break;
    }
    a += d;
  }
  return msg;
}
int main(int argc, const char* argv[]) {
  int T;
  cin >> T;
  vector<vector<long long> > abcd;
  for (int i = 0; i < T; ++i) {
    vector<long long> a(4);
    cin >> a[0] >> a[1] >> a[2] >> a[3];
    abcd.push_back(a);
  }
  for (auto it = abcd.begin(); it != abcd.end(); ++it) {
    cout << calc(*it) << endl;
  }
  return 0;
}
