#include #include #include #include using namespace std; using ll = long long; int main(){ const ll mx = 200'000; ll x; cin >> x; if (x == 1){ cout << 2 << endl; cout << "1 2" << endl; cout << "b g" << endl; return 0; } map cnt; for(ll i = 2; i <= mx; i++){ if (i * i > x) break; while(x % i == 0){ x /= i; cnt[i]++; } } if (x <= mx && x != 1) { cnt[x]++; x = 1; } if(x > 1) { cout << -1 << endl; return 0; } ll n = 0; ll b = 0; for(auto p: cnt){ if (p.first == 2){ n += p.second / 2 * 5; b += p.second / 2; n += p.second % 2 * 3; b += p.second % 2; } else{ n += p.second * (p.first + 1); b += p.second; } if (n > mx){ cout << -1 << endl; return 0; } } cout << n << endl; for (int i = 0; i < b - 1; i++){ cout << i + 1 << " " << i + 2 << endl; } int g = 0; int useb = 0; for(auto p: cnt){ if (p.first == 2){ for (int i = 0; i < p.second / 2; i++){ for (int j = 0; j < 4; j++){ cout << useb + 1 << " " << b + g + 1 << endl; g++; } useb++; } for (int i = 0; i < p.second % 2; i++){ for (int j = 0; j < 2; j++){ cout << useb + 1 << " " << b + g + 1 << endl; g++; } useb++; } } else{ for (int i = 0; i < p.second; i++){ for (int j = 0; j < p.first; j++){ cout << useb + 1 << " " << b + g + 1 << endl; g++; } useb++; } } } assert(b == useb); assert(b + g == n); for (int i = 0; i < b; i++){ cout << "b "; } for(int i = 0; i < n - b; i++){ if (i != n - b - 1) cout << "g "; else cout << "g" << endl; } }