#include using namespace std; #define _p(...) (void)printf(__VA_ARGS__) #define forr(x,arr) for(auto&& x:arr) #define _overload3(_1,_2,_3,name,...) name #define _rep2(i,n) _rep3(i,0,n) #define _rep3(i,a,b) for(int i=int(a);i=int(a);i--) #define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__) #define all(x) (x).begin(), (x).end() #define bit(n) (1LL<<(n)) #define sz(x) ((int)(x).size()) #define fst first #define snd second using ll=long long; using pii=pair;using pll=pair;using pil=pair;using pli=pair; using vs=vector;using vvs=vector;using vvvs=vector; using vb=vector;using vvb=vector;using vvvb=vector; using vi=vector;using vvi=vector;using vvvi=vector; using vl=vector;using vvl=vector;using vvvl=vector; using vd=vector;using vvd=vector;using vvvd=vector; using vpii=vector;using vvpii=vector;using vvvpii=vector; templateistream&operator>>(istream&is,pair&P){is>>P.fst;is>>P.snd;return is;} templateT read(){T t;cin>>t;return t;} templateostream&operator<<(ostream&o,const pair&p){return o<<'('<ostream&operator<<(ostream&o,const vector&t){o<<"{";rep(i,sz(t))o<void e_r_r(vs::iterator it,T a,Args... args){cerr<substr((*it)[0]==' ',it->length())<<" = "< struct Mint { int x; Mint() : x(0) {} Mint(int y) : x(y >= 0 ? y % MOD : MOD - (-y) % MOD) {} Mint(signed long long sll) : x(sll % MOD) { if (x < 0) x += MOD; } Mint &operator+=(const Mint &rhs){ if((x += rhs.x) >= MOD) x -= MOD; return *this; } Mint &operator-=(const Mint &rhs){ if((x += MOD - rhs.x) >= MOD) x -= MOD; return *this; } Mint &operator*=(const Mint &rhs){ x = 1LL*x*rhs.x % MOD; return *this; } Mint &operator/=(const Mint &rhs){ x = (1LL*x*rhs.inv().x) % MOD; return *this; } Mint operator-() const { return Mint(-x); } Mint operator+(const Mint &rhs) const { return Mint(*this) += rhs; } Mint operator-(const Mint &rhs) const { return Mint(*this) -= rhs; } Mint operator*(const Mint &rhs) const { return Mint(*this) *= rhs; } Mint operator/(const Mint &rhs) const { return Mint(*this) /= rhs; } bool operator<(const Mint &rhs) const { return x < rhs.x; } Mint inv() const { signed a = x, b = MOD, u = 1, v = 0, t; while(b){ t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } return Mint(u); } Mint operator^(unsigned long long t) const { Mint e = *this, res = 1; for(; t; e *= e, t>>=1) if (t & 1) res *= e; return res; } }; template ostream &operator<<(ostream &os, const Mint &rhs) { return os << rhs.x; } template istream &operator>>(istream &is, Mint &rhs) { long long s; is >> s; rhs = Mint(s); return is; }; using mint = Mint; using vm=vector;using vvm=vector;using vvvm=vector; const int B = 61; vs strs(B); vl lens(B); vl sums(B); vm muls(B); pair calc(ll l, ll r, int k) { if (l == 0 && r == lens[k]) { return {sums[k], muls[k]}; } int p1 = lens[k-1]; int p2 = lens[k] - p1; if (l < p1 && r < p1) { // lef, lef return calc(l, r, k-1); } else if (l < p1 && r < p2) { // lef, mid auto a1 = calc(l, lens[k-1], k-1); int mid_r = r - lens[k-1]; rep(i, mid_r) { int d = strs[k][i] - '0'; if (d == 0) d += 10; a1.fst += d; a1.snd *= d; } return a1; } else if (l < p1) { // lef, rig auto a1 = calc(l, lens[k-1], k-1); auto a2 = calc(0, r-p2, k-1); rep(i, p2-p1) { int d = strs[k][i] - '0'; if (d == 0) d += 10; a1.fst += d; a1.snd *= d; } a1.fst += a2.fst; a1.snd *= a2.snd; return a1; } else if (l < p2 && r < p2) { // mid, mid pair a1{0, 1}; rep(i, l - p1, r - p1) { int d = strs[k][i] - '0'; if (d == 0) d += 10; a1.fst += d; a1.snd *= d; } return a1; } else if (l < p2) { // mid, rig auto a1 = calc(0, r-p2, k-1); rep(i, l-p1, p2-p1) { int d = strs[k][i] - '0'; if (d == 0) d += 10; a1.fst += d; a1.snd *= d; } return a1; } else { // rig, rig return calc(l-p2, r-p2, k-1); } } void Main() { int k = read(); ll l = read() - 1; ll r = read(); sums[1] = 1; lens[1] = 1; muls[1] = 1; strs[1] = "1"; rep(i, 2, B) { strs[i] = to_string(i * i); lens[i] = lens[i-1] * 2; sums[i] = sums[i-1] * 2; muls[i] = muls[i-1] * muls[i-1]; lens[i] += sz(strs[i]); forr(c, strs[i]) { int d = c - '0'; if (d == 0) d += 10; sums[i] += d; muls[i] *= d; } } //out(lens); //out(sums); //out(muls); //out(strs); //out(l, r, lens[k]); if (r > lens[k]) { cout << -1 << endl; return; } auto ans = calc(l, r, k); cout << ans.fst << ' ' << ans.snd << endl; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }