#include using namespace std; #include using namespace atcoder; #ifdef DEFINED_ONLY_IN_LOCAL #include #define dump(...) cpp_dump(__VA_ARGS__) #else #undef dump #define dump(...) #endif #define rep(i, n) for (int i = 0; i < n; i++) template istream& operator>>(istream& I, vector& V) { for (T& X : V) I >> X; return I; } int main() { long x; cin >> x; if (x == 1) { cout << 2 << endl; cout << 1 << " " << 2 << endl; cout << "b g" << endl; return 0; } vector b; while (x > 1) { bool find = false; for (int i = 2; i <= 2e5; i++) { if (x % i == 0) { find = true; b.push_back(i); x /= i; break; } } if (!find) { cout << -1 << endl; return 0; } } cout << reduce(b.begin(), b.end()) + b.size() << endl; for (int i = 0; i < b.size() - 1; i++) { cout << i << " " << i + 1 << endl; } int idx = b.size(); rep(i, b.size()) { rep(j, b[i]) { cout << i << " " << idx++ << endl; } } rep(i, b.size()) cout << "b "; rep(i, reduce(b.begin(), b.end())) cout << "g "; cout << endl; return 0; }