#include using namespace std; #include using namespace atcoder; using mint = modint1000000007; using mint1 = modint998244353; typedef long long ll; typedef unsigned int uint; typedef unsigned long long ull; typedef pair P; typedef pair PL; typedef vector vi; typedef vector vvi; typedef vector vvvi; typedef vector vl; typedef vector vvl; typedef vector vvvl; typedef vector vd; typedef vector vvd; typedef vector vvvd; typedef vector vm; typedef vector vvm; typedef vector vvvm; typedef vector vm1; typedef vector vvm1; typedef vector vvvm1; typedef vector vm2; typedef vector vvm2; typedef vector vvvm2; typedef vector vb; typedef vector vvb; typedef vector vvvb; typedef vector vc; typedef vector vvc; typedef vector vvvc; typedef vector vp; typedef tuple tt; typedef vector> vt; typedef vector vs; struct Edge{ long long to; long long cost; }; typedef vector > Graph; const long long INF = 1e9; const long long INFL = 1e18; const double PI = 3.14159265358979; const double epsilon = 1e-12; vector dy = {1, 0, -1, 0}; vector dx = {0, 1, 0, -1}; int main(){ vl x(3), y(3); for(int i=0;i<3;i++){ cin >> x[i] >> y[i]; } auto c = crt(x, y); if(c.first == 0 && c.second == 0)cout << -1 << endl; else if(c.first == 0)cout << c.second << endl; else cout << c.first << endl; return 0; }