#include using namespace std; using ll=long long; using vb=vector; using vvb=vector; using vd=vector; using vvd=vector; using vi=vector; using vvi=vector; using vl=vector; using vvl=vector; using pll=pair; using tll=tuple; using vs=vector; #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define rep(i,n) range(i,0,n) #define range(i,a,n) for(ll i=(a);i<(n);i++) #define LINF ((ll)1ll<<60) #define INF ((int)1<<30) #define EPS (1e-9) #define MOD (1000000007ll) #define fcout(a) cout<bool chmax(T&a,T b){if(abool chmin(T&a,T b){if(a>b){a=b; return true;}return false;} templateS sum(vector&a){return accumulate(all(a),S());} templatevoid puta(T&&t){cout<void puta(H&&h,T&&...t){cout<void tf(bool b,S t,T f){if(b)puta(t);else puta(f);} void OUT(bool b){tf(b,"YES","NO");} void Out(bool b){tf(b,"Yes","No");} void out(bool b){tf(b,"yes","no");} templateostream&operator<<(ostream&os,pairp){os<<"["<auto&operator<<(ostream&os,vectort){bool a=1;for(auto s:t){os<<(a?"":" ")<auto&operator>>(istream&is,vector&t){for(S&a:t)cin>>a;return is;} int popcnt(int x){return __builtin_popcount(x);} int popcnt(ll x){return __builtin_popcountll(x);} int bsr(int x){return 31 - __builtin_clz(x);} int bsr(ll x){return 63 - __builtin_clzll(x);} int bsf(int x){return __builtin_ctz(x);} int bsf(ll x){return __builtin_ctzll(x);} /*他のライブラリを入れる場所*/ int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; cin>>n; map mp; rep(i,n){ int x,y; cin>>x>>y; mp[y-x]++; } auto p=*mp.begin(); tf(mp.size()==1 and p.fs>0, p.fs, -1); return 0; }