// {{{ Templates #include #define show(x) cerr << #x << " = " << x << endl using namespace std; using ll = long long; using pii = pair; using vi = vector; template ostream& operator<<(ostream& os, const vector& v) { os << "sz:" << v.size() << "\n["; for (const auto& p : v) { os << p << ","; } os << "]\n"; return os; } template ostream& operator<<(ostream& os, const pair& p) { os << "(" << p.first << "," << p.second << ")"; return os; } constexpr ll MOD = (ll)1e9 + 7LL; template constexpr T INF = numeric_limits::max() / 100; // }}} using pll = pair; inline ll convert(const char c) { return c == '0' ? 10 : c - '0'; } inline pll calcst(const string& s, const ll l, const ll r) { assert(0 <= l); assert(l < r); assert(r <= s.size()); ll sum = 0; ll prod = 1; for (ll i = l; i < r; i++) { const char c = s[i]; sum = (sum + convert(c)) % MOD; prod = (prod * convert(c)) % MOD; } return make_pair(sum, prod); } pll rec(const ll n, const ll l, const ll r, const vector& length, const vector& calced) // f(n)の[L,R)の(和,積) { assert(l >= 0); assert(l < r); if (n == 0) { return make_pair(0, 1); } if (l == 0 and r == length[n]) { return calced[n]; } else { const string intst = to_string(n * n); const ll interval = intst.size(); const ll half = (length[n] - interval) / 2; pll ret = make_pair(0, 1); if (l < half) { const pll p = rec(n - 1, l, min(r, half), length, calced); ret.first = (ret.first + p.first) % MOD; ret.second = (ret.second * p.second) % MOD; } if (r > half + interval) { const pll p = rec(n - 1, max(l - half - interval, 0LL), r - half - interval, length, calced); ret.first = (ret.first + p.first) % MOD; ret.second = (ret.second * p.second) % MOD; } if (r > half and l < half + interval) { const pll p = calcst(intst, max(l - half, 0LL), min(interval, r - half)); ret.first = (ret.first + p.first) % MOD; ret.second = (ret.second * p.second) % MOD; } return ret; } } inline pll cal(const string& s) { ll sum = 0; ll prod = 1; for (const char c : s) { sum += convert(c); sum = sum % MOD; prod *= convert(c); prod = prod % MOD; } return make_pair(sum, prod); } int main() { cin.tie(0); ios::sync_with_stdio(false); ll k, l, r; cin >> k >> l >> r; l--, r--; constexpr ll STOP = (ll)1e18; vector length(1, 0); ll len = 0; for (ll i = 1;; i++) { len = len * 2 + (ll)log10(i * i) + 1; length.push_back(len); if (len > STOP) { break; } } const int size = length.size(); if (k > size) { k = size; } vector calced(size, make_pair(0, 1)); for (int i = 1; i < size; i++) { const string s = to_string(i * i); const pll p = cal(s); calced[i].first = calced[i - 1].first * 2 + p.first; calced[i].second = ((calced[i - 1].second * calced[i - 1].second) % MOD) * p.second; calced[i].first = calced[i].first % MOD; calced[i].second = calced[i].second % MOD; } // show(calced); if (length[k] <= r) { cout << -1 << endl; return 0; } const pll ans = rec(k, l, r + 1, length, calced); cout << ans.first << " " << ans.second << endl; return 0; }