#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#define MOD 1000000007
typedef long long ll;
int cmpll(const void *x, const void *y) {
	return *(ll *)x - *(ll *)y;
}
ll a[200000], b[200000], sorta[200000], sortb[200000];
int binarySearchA(int key, int num) {
	int ok = -1, ng = num, mid;
	while (ng - ok > 1) {
		mid = (ng + ok) / 2;
		if (sorta[mid] <= key)
			ok = mid;
		else
			ng = mid;
	}
	return ok;
}
int binarySearchB(int key, int num) {
	int ok = -1, ng = num, mid;
	while (ng - ok > 1) {
		mid = (ng + ok) / 2;
		if (sortb[mid] <= key)
			ok = mid;
		else
			ng = mid;
	}
	return ok;
}
int main() {
	int n;
	ll ans = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld%lld", &a[i], &b[i]);
		sorta[i] = a[i];
		sortb[i] = b[i];
	}
	qsort(sorta, n, sizeof(ll), cmpll);
	qsort(sortb, n, sizeof(ll), cmpll);
	for (int i = 0; i < n; i++) {
		int hate = 0;
		int rab = ceil(sqrt(a[i] * b[i]));
		for (int j = -rab; j <= rab; j++) {
			if (j == 0)
				continue;
			if (a[i] * b[i] % j == 0) {
				if (sorta[binarySearchA(j, n)] == j &&
					sortb[binarySearchB(a[i] * b[i] / j, n)] ==
						a[i] * b[i] / j) {
					hate++;
				}
			}
		}
		ans += n - hate;
		ans %= MOD;
	}
	printf("%lld\n", ans);
	return 0;
}