#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << setprecision(10) << fixed;
  long long int t;
  cin >> t;
  while (t--) {
    long long int x, y, a, b;
    cin >> x >> y >> a >> b;
    long long int d = abs(x - y);
    long long int t1 = (d * a) / (a + b);
    long long int a1 = -1;
    if ((d * a) % (a + b) == 0 && t1 % a == 0 && (d - t1) % b == 0) a1 = t1 / a;
    cout << a1 << endl;
  }
  return 0;
}
