#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 1; i <= t; i++) {
    int x, y, a, b;
    cin >> x >> y >> a >> b;
    if ((a + b) == 0)
      cout << "-1" << endl;
    else {
      int ans = (y - x) / (a + b);
      int q = x + a * ans;
      int w = y - b * ans;
      if (ans >= 0 && q == w)
        cout << ans << endl;
      else
        cout << "-1" << endl;
    }
  }
}
