#include using namespace std; #define endl '\n' #define ALL(a) (a).begin(),(a).end() #define ALLR(a) (a).rbegin(),(a).rend() #define spa << " " << #define lfs <= (ll)(m); i--) using ll = long long; using ld = long double; const ll MOD = 1e9+7; //const ll MOD = 998244353; const ll INF = 1e18; using P = pair; template void chmin(T &a,T b){if(a>b)a=b;} template void chmax(T &a,T b){if(a void ans(bool x,T1 y,T2 z){if(x)cout< void debug(vector>v,ll h,ll w){for(ll i=0;iv,ll h,ll w){for(ll i=0;i void debug(vectorv,ll n){if(n!=0)cout< vector>vec(ll x, ll y, T w){ vector>v(x,vector(y,w));return v;} ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;} template vectordx={1,0,-1,0,1,1,-1,-1}; vectordy={0,1,0,-1,1,-1,1,-1}; template vector make_v(size_t a,T b){return vector(a,b);} template auto make_v(size_t a,Ts... ts){ return vector(a,make_v(ts...)); } long long PreGarner(vector &b, vector &m, long long MOD) { long long res = 1; for (int i = 0; i < (int)b.size(); ++i) { for (int j = 0; j < i; ++j) { long long g = gcd(m[i], m[j]); if ((b[i] - b[j]) % g != 0) return -1; m[i] /= g; m[j] /= g; long long gi = gcd(m[i], g); long long gj = g/gi; do { g = gcd(gi, gj); gi *= g, gj /= g; } while (g != 1); m[i] *= gi, m[j] *= gj; b[i] %= m[i], b[j] %= m[j]; } } for (int i = 0; i < (int)b.size(); ++i) (res *= m[i]) %= MOD; return res; } ll modinv(ll a,ll m) {ll b=m,u=1,v=0; while(b){ll t=a/b;a-=t*b;swap(a,b);u-=t*v;swap(u,v);} u%=m;if(u<0)u+=m;return u;} inline long long mod(long long a, long long m) { long long res = a % m; if (res < 0) res += m; return res; } long long Garner(vector b, vector m, long long MOD) { m.push_back(MOD); // banpei vector coeffs((int)m.size(), 1); vector constants((int)m.size(), 0); for (int k = 0; k < (int)b.size(); ++k) { long long t = mod((b[k] - constants[k]) * modinv(coeffs[k], m[k]), m[k]); for (int i = k+1; i < (int)m.size(); ++i) { (constants[i] += t * coeffs[i]) %= m[i]; (coeffs[i] *= m[k]) %= m[i]; } } return constants.back(); } int main(){ cin.tie(NULL); ios_base::sync_with_stdio(false); ll res=0,res1=INF,res2=-INF,buf=0; bool judge = true; ll n;cin>>n; vectorx(n),y(n); rep(i,0,n)cin>>x[i]>>y[i]; res=PreGarner(x,y,MOD); buf=Garner(x,y,MOD); if(res==-1)cout<<-1<