#include #include using namespace std; using namespace atcoder; using mint = modint1000000007; using ll = long long; bool argsort(const pair& v1, const pair& v2) { auto&[x1, y1] = v1; auto&[x2, y2] = v2; return (x1 * y2 > x2 * y1); } mint area(pair& v1, pair& v2){ mint x1 = v1.first, y1 = v1.second; mint x2 = v2.first, y2 = v2.second; return x1 * y2 - x2 * y1; } int main(){ int n; cin >> n; vector > vectors = {}; for(int i = 0; i < n; ++i){ ll x, y; cin >> x >> y; if(x == 0 && y == 0){ continue; } if(y < 0){ x = -x, y = -y; } vectors.push_back({x, y}); } sort(vectors.begin(), vectors.end(), argsort); mint s = 0, bh = 0; ll lx = 0, ly = 0; for(auto&[x, y] : vectors) { pair v1 = { lx, ly }; pair v2 = { lx + x, ly + y }; s += area(v1, v2); bh += gcd(x, y); lx = v2.first, ly = v2.second; } mint ans = s + bh + 1; cout << ans.val() << endl; return 0; }