#include #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define FORR(i,a,b) for (int i=(a);i>=(b);i--) #define pb push_back #define pcnt __builtin_popcount #define show(x) cout<<#x<<" = "< pii; typedef vector vi; typedef vector vvi; typedef vector vpii; typedef set si; typedef pair pll; typedef vector vl; typedef vector vvl; typedef vector vpll; typedef set sl; templatestring join(vector&v) {stringstream s;FOR(i,0,sz(v))s<<' '<b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;} int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;} void dout(double d){printf("%.12f\n",d);} const int iinf = 1e9; const ll linf = 1e18; const int mod = 1e9+7; const double pi = acos(-1); const double eps = 1e-10; ll a[61][3]; string st[61]; pair parse(ll n){ ll s=0, p=1; int l = 0, c, nn = n * n; stringstream ss; ss << nn; st[n] = ss.str(); while(nn > 0){ l++; c = nn % 10; if(c == 0) c = 10; s += c; p *= c; nn /= 10; } return mp(l, mp(s, p)); } pll search(int n, ll l, ll r){ //cout << "s(" << n << "," << l << "," << r << ")" << endl; if(n == 0 || l >= r) return mp(0, 1); if(l==0&&r==a[n][0]) return mp(a[n][1], a[n][2]); pll t; ll s = 0, p = 1, d; t = search(n-1, l, min(r, a[n-1][0])); s = (s + t.fi)%mod; p = p * t.se % mod; FOR(i, max(0ll, min(l-a[n-1][0], ll(sz(st[n])))), min(ll(sz(st[n])), r-a[n-1][0])){ d = st[n][i] - '0'; if(d == 0) d = 10; s += d; p *= d; } s %= mod; p %= mod; d = a[n-1][0] + sz(st[n]); t = search(n-1, max(l-d, 0ll), r-d); s = (s + t.fi)%mod; p = p * t.se % mod; return mp(s, p); } main(){ cin.tie(0); ios::sync_with_stdio(false); a[0][2] = 1; pair t; FOR(i, 1, 61){ t = parse(i); a[i][0] = (a[i-1][0] * 2 + t.fi); a[i][1] = (a[i-1][1] * 2 + t.se.fi)%mod; a[i][2] = a[i-1][2] * a[i-1][2] % mod * t.se.se % mod; } int K; ll L, R; cin >> K >> L >> R; if(a[K][0] < R){ cout << -1 << endl; return 0; } pll ans = search(K, L-1, R); cout << ans.fi << " " << ans.se << endl; //FOR(i, 1, 61)cout << st[i] << endl << a[i][0] << endl << a[i][1] << endl << a[i][2] << endl << endl; return 0; }