#include <bits/stdc++.h>
const int N = 1e6 + 1;
long long ri() {
  char c = getchar();
  long long x = 0, f = 1;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') f = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) - '0' + c;
  return x * f;
}
std::vector<std::pair<long long, long long> > vec[N];
long long k, cnt[N];
int w, p[N], n;
int main() {
  n = ri();
  for (int i = 1; i <= n; ++i) {
    int x = ri();
    long long y = ri();
    vec[x].push_back(std::make_pair(0LL, y));
  }
  k = ri();
  for (int i = 1; i < N; ++i) p[i] = i;
  for (int i = 2; i < N; ++i)
    for (int j = i; j < N; j += i) p[j] = p[i];
  for (int i = N - 1; i > 1; --i) {
    std::vector<std::pair<long long, long long> > nw;
    long long st = 0, ed = 0;
    std::sort(vec[i].begin(), vec[i].end());
    for (auto x : vec[i])
      if (x.first <= ed)
        ed += x.second - x.first;
      else {
        if (st < ed) nw.push_back(std::make_pair(st, ed));
        st = x.first;
        ed = x.second;
      }
    if (st < ed) nw.push_back(std::make_pair(st, ed));
    for (auto x : nw) {
      if (x.second > k) {
        long long re = x.second - std::max(x.first, k);
        cnt[i] += re;
        x.second -= re;
      }
      if (x.first++ < x.second++)
        for (int j = i - 1; j > 1; j /= p[j]) vec[p[j]].push_back(x);
    }
    w += cnt[i] > 0;
  }
  printf("%d\n", w);
  for (int i = 1; i < N; ++i)
    if (cnt[i]) printf("%d %lld\n", i, cnt[i]);
  return 0;
}
