#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e8 + 5;
ll n , m , p[N] , c[N];
int mul(int x)
{
if(x == 1)
{
return 1;
}
return x * mul(x - 1);
}
void divide(int a)
{
m = 0;
for(register ll i = 2;i * i <= a;i++)
{
if(a % i == 0)
{
p[++m] = i;
c[m] = 0;
while(a % i == 0)
{
a /= i;
c[m]++;
}
}
}
if(a > 1)
{
p[++m] = a;
c[m] = 1;
}
for(register ll i = 1;i <= m;i++)
{
cout << p[i] << " " << c[i] << endl;
}
}
int main()
{
std::ios::sync_with_stdio(0);
std::cin.tie(0);
std::cout.tie(0);
cin >> n;
int ans = mul(n);
divide(ans);
return 0;
}