#include #include #include #include using namespace std; const int mod = 1000000007; typedef long long ll; ll calc(ll x) { ll ret = 0; for (int i = 0; i < 60; i++) { ll cnt = (x >> i) - (x >> (i + 1)); int d = to_string((i + 1) * (i + 1)).size(); ret += d * cnt; } return ret; } vector solve(ll x) { ll l = 0, r = 1LL << 60; while (r - l > 1) { ll m = (l + r) >> 1; if (calc(m) <= x) l = m; else r = m; } vector v(10); for (int i = 0; i < 60; i++) { ll c = (l >> i) - (l >> (i + 1)); int b = (i + 1) * (i + 1); while (b > 0) { v[b % 10] += c; b /= 10; } } ll pos = calc(l); int c = 1; l++; while (!(l & 1)) l >>= 1, c++; string t = to_string(c * c); for (int i = 0; i < x - pos; i++) v[t[i] - 48]++; return v; } int modpow(int a, ll b) { ll ret = 1; while (b) { if (b & 1) ret = 1LL * ret * a % mod; a = 1LL * a * a % mod; b >>= 1; } return ret; } int z[] = { 10, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; ll K, L, R; int main() { cin >> K >> L >> R; L--; K = min(K, 61LL); ll s = (1LL << K) - 1; s += s >> 9; if (R > s) cout << -1 << endl; else { vector r1 = solve(R), r2 = solve(L); long long sum = 0; int prod = 1; for (int i = 0; i < 10; i++) { sum += 1LL * z[i] * (r1[i] - r2[i]); prod = 1LL * prod * modpow(z[i], r1[i] - r2[i]) % mod; } cout << sum << ' ' << prod << endl; } return 0; }