#include #include using namespace std; int main() { int N = 3; vector X(N), Y(N); for (int i = 0; i < N; i++) { cin >> X[i] >> Y[i]; } pair P = atcoder::crt(X, Y); long long ans = P.first; if (P.first == 0) ans = P.second; if (P == make_pair(0LL, 0LL)) { ans = -1; } cout << ans << endl; }