#include <bits/stdc++.h>
using namespace std;
unsigned long long n, m, c;
vector<unsigned long long> a, b;
int main() {
  cin >> n >> c;
  a.resize(n);
  b.resize(n);
  for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
  int t = 0;
  for (int j = 1; j < 0.95e6; j++) {
    unsigned long long x = j;
    unsigned long long ans = 0;
    for (int i = 0; i < n; i++) ans += (a[i] * x) / b[i] + 1;
    if (ans == c) t++;
  }
  cout << ((t > 0.949e6) ? -1 : t);
}
