#include #include #include #define rep(i, l, n) for (int i = (l); i < (n); i++) #define all(x) x.begin(), x.end() using namespace std; using ll = long long; template using V = vector; template using VV = V >; const ll mod = 1000000007; ll gcd(ll a, ll b) { a = abs(a); b = abs(b); while (b != 0) { ll r = a % b; a = b; b = r; } return a; } ll get_mod(ll n) { if (n < 0) { return mod - (-n) % mod; } return n % mod; } ll area(V& v1, V& v2) { ll x1 = get_mod(v1[0]), y1 = get_mod(v1[1]); ll x2 = get_mod(v2[0]), y2 = get_mod(v2[1]); return get_mod(x1 * y2 % mod - x2 * y1 % mod); } bool arg_sort(const V& v1, const V& v2) { ll x1 = v1[0], y1 = v1[1]; ll x2 = v2[0], y2 = v2[1]; return (x1 * y2 > x2 * y1); } int main(void) { int tmp, n = 0; cin >> tmp; VV v(tmp, V(2)); rep(i, 0, tmp) { ll x, y; cin >> x >> y; if (x == 0 and y == 0) { continue; } if (y < 0) { x = -x; y = -y; } v[n] = { x,y }; n++; } v.resize(n); sort(all(v), arg_sort); ll S = 0, bh = 0; ll lx = 0, ly = 0; for (auto& l : v) { ll x = l[0], y = l[1]; V v1 = { lx,ly }; V v2 = { lx + x,ly + y }; S += area(v1, v2); S %= mod; bh += gcd(x, y); bh %= mod; lx = v2[0]; ly = v2[1]; } ll ans = (S + bh + 1) % mod; cout << ans << endl; return 0; }