#include <bits/stdc++.h>

using namespace std;

#ifdef ACMTUYO
struct RTC{~RTC(){cerr << "Time: " << clock() * 1.0 / CLOCKS_PER_SEC <<" seconds\n";}} runtimecount;
#define DBG(X) cerr << #X << " = " << X << '\n';
#else
struct RTC{};
#define DBG(X)
#endif

#define fast_io() ios_base::sync_with_stdio(false)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define sz(x) ((int)(x).size())
#define all(c) (c).begin(),(c).end()
#define forn(i, n) for (int i = 0; i < (n); i++)
typedef long long int ll;

int main() {
  ll x,y,n;
  scanf("%lld %lld %lld",&x,&y,&n);
  ll sn=10000000,sd=1;
  for(int den=1;den<=n;den++) {
    double ap=double(x*den)/double(y);
    ll num=int(ap);
    if(ap-double(num)>0.5)num++;
     //cout<<num<<" / "<<den<<endl;
    if((y*den)*llabs(x*sd-sn*y)>(y*sd)*llabs(x*den-num*y)) {
      sn=num;sd=den;
    }
  }
  printf("%d/%d\n",int(sn),int(sd));
  return 0;
}


#include<bits/stdc++.h>

using namespace std;

long long xx = -1, yy, a, b, n;

int main(int argc, char **argv) {
#ifndef ONLINE_JUDGE
	freopen("a.in", "r", stdin);
#endif
	scanf("%lld%lld%lld", &a, &b, &n);
	for(long long y=1 ; y<=n ; ++y){
		long long x = y*a/b;
		if(xx == -1) xx = x, yy = y;
		if(abs(a*y - b*x)*yy < abs(a*yy - b*xx)*y) xx = x, yy = y;
		++x;
		if(abs(a*y - b*x)*yy < abs(a*yy - b*xx)*y) xx = x, yy = y;
	}
	printf("%lld/%lld\n", xx, yy);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define pll pair<ll,ll>
#define pb push_back
#define F first
#define S second
#define I insert
#define vll vector<ll>
#define vbl vector<bool>
#define vvll vector<vll>
#define vld vector<ld>
#define vb vector<bool>
#define vc vector<char>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()

template<class T> ostream& operator<<(ostream &os, vector<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T> ostream& operator<<(ostream &os, set<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, map<T , R> V){
	os << "[ ";
	for(auto v  : V) os << "(" << v.first << ":" << v.second << ")";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, pair<T , R> V){
	return os << "(" << V.first << "," << V.second << ")";
}

#define cerr cout
#define TRACE
#ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1<<" | ";
        __f(comma+1, args...);
    }
    clock_t clk=clock();
    #define checktime() cout<<"\nTime Elapsed : "<<float(clock()-clk)/CLOCKS_PER_SEC<<endl
#else
    #define trace(...);
    #define checktime();
#endif

const ll Mod = 1e9 + 7;
// const ll Mod = 998244353;
const ll MAXN = 1e6;

void solve(){
    ll x,y,n;cin>>x>>y>>n;
    ll a,b;
    ld val=1ll<<60;
    for(ll i=1;i<=n;i++){
        if(val>min((i*x)%y,y-(i*x)%y)*1.0/i){
            val=min((i*x)%y,y-(i*x)%y)*1.0/i;
            b=i;
            a=((i*x)%y<=y-(i*x)%y)?i*x/y:i*x/y+1;
        }
    }
    cout<<a<<"/"<<b<<"\n";
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<fixed<<setprecision(25);

    ll t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define INF 100000000
using namespace std;
long long int fn,fd;
long long int ra,rb;
long long int gcd(long long int a, long long int b)
{
    if (b==0)
        return a;
    else
        return gcd(b,a%b);
}
//this is a void fucnction

void function (long long int x, long long int y, long long int b, long long int a)
{
    if (a < 0) {
        return;
    }
    long long int kkk = gcd (a, b);
    a = a / kkk;     b = b/kkk;
    long long int kk,g,n,d;
    n = abs(b*x - a*y);
    d = b*y;
    g = gcd (n, d);
    n = n/g;    d = d/g;
    //cout << x << " " << y << " " << a << " " << b << endl;
    if (n*fd < fn*d) {
        fn = n;
        fd = d;
        ra = a;
        rb = b;
        return;
    }
    if (n*fd == d*fn) {
        if (b < rb) {
            ra = a;
            rb = b;
            return;
        }
        if (b > rb) {
            return;
        }
        if (a < ra) {
            ra = a;
            rb = b;
            return;
        }
    }
}
int main()
{
    fn = 100000;    fd = 1;
    long long int x,i,y,n;
    cin >> x >> y >> n;
    int j;
    for ( int i = 0; i < 19; i++ ) {
        j = i;
    }
    for (i = 1; i <= n; i++) {
        function (x, y, i, (i*x)/y);
        function (x, y, i, (i*x)/y + 1);
        function (x, y, i, (i*x)/y - 1);
    }
    cout << ra << "/" << rb << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

long double absolute(long double a)
{
    return a < 0 ? a * - 1 : a;
}

int main(){
    int a,b,n;
    cin >> a >> b >> n;
    int x,y0,y1;
    long double r = 1e100;
    int ansx=0,ansy=0;
    for(int i = 1; i <= n; ++i)
    {
        x = i;
        y1 = (double)(a)/b * i;
        y0 = (double)(a)/b * i+1;
        if(r > absolute((long double)(a)/b-(long double)(y1)/x))
        {
            ansx = y1, ansy = x;
            r = absolute((long double)(a)/b-(long double)(y1)/x);
        }
        if(r > absolute((long double)(a)/b-(long double)(y0)/x))
        {
            ansx = y0, ansy = x;
            r = absolute((long double)(a)/b-(long double)(y0)/x);
        }
    }
    cout << ansx << "/" << ansy << endl;
}


#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    long long x,y,n,a=-1,b,i,j;
    cin>>x>>y>>n;
    for(i=1;i<=n;i++){
        j=i*x/y;
        if(i*x-j*y>(j+1)*y-i*x) j++;
        if(a==-1||abs(a*y-x*b)*i>abs(j*y-x*i)*b) a=j,b=i;
    }
    cout<<a<<"/"<<b<<endl;
}


#include<cstdio>
#include<cstdlib>
#include<fstream>
#include<queue>
#include<stack>
#include<memory.h>
#include<algorithm>
#include<vector>
#include<list>
#include<set>
#include<string>
#include<map>
#include<cmath>
#include<iostream>
#include<ctime>
#define mk make_pair
#define pb push_back
#define F first
#define S second
#define m0(x) memset(x,0,sizeof(x))
#define maxn 111111
using namespace std;
typedef long long ll;
typedef float f;
typedef long double ld;
ll i,n,x,y;

ll gcd(int x,int y){
 int p = x % y;
 x = y;
 y = p;
if(y > 0)x = gcd(x,y);
return x;
}

ll lcm(int x,int y){
return ll(x) * ll(y) / gcd(x,y);
}

ld func(int x1,int y1,int x2,int y2){
ll s = lcm(y1,y2);
ll s1 = abs(s / y1 * x1 - s / y2 * x2);
return ld(s1) / ld(s);
}

int main(){
#ifndef ONLINE_JUDGE
 freopen("input.txt", "r", stdin);
 freopen("output.txt", "w", stdout);
#endif
cin >> x >> y >> n;
ll a = 0,b = 1;
ld t1 = ld(x) / ld(y),h = 0;
  for(i=1;i<=n;i++){
   ll l = 1,r = 1000000,ave;
   while(r - l > 1){
    ave = (l + r) / 2;
	ld t2 = ld(ave) / ld(i);
    if(t2 < t1)l = ave;
	else r = ave;
   }
   ave = l;
   if((func(l,i,x,y) > func(r,i,x,y)))ave = r;
   if(func(ave,i,x,y)  < func(a,b,x,y)){
    a = ave;
	b = i;
   }
  }
cout << a << "/" << b;
return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define forex(i,j) for(int i=0;i<(j);i++) // 0 .. N-1
#define forin(i,j) for(int i=0;i<=(j);i++) // 0 .. N
#define printv(v) {for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<"\n";}
#define printa(a,len) {for(int i=0;i<len;i++) cout<<a[i]<<" ";cout << "\n";}

typedef long long ll;
typedef pair<int,int> pii;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pii> vpii;

#define mp make_pair
#define pb push_back
#define uset unordered_set
#define umap unordered_map
#define mset multiset
#define mmap multimap
#define umset unordered_multiset
#define ummap unordered_multimap
#define all(v) (v).begin(),(v).end()

int xx[]={0,1,0,-1,-1,-1,1,1,-1};int yy[]={1,0,-1,0,1,1,-1,-1}; //E S W N NE SE SW NW

void vin(vi &v,int n){
    int temp;
    while(n--){
        cin>>temp;
        v.pb(temp);
    }
}
int gcd(int a,int b){
    if(a==0)return b;
    else return gcd(b%a,a);
}
int main() {
_
double eps=0.000000000000001;
int x,y,nn;cin>>x>>y>>nn;
double a=(double)x/y;
//if(y<=nn)cout<<x<<"/"<<y;
{
    double ans=1000000.0;int n=x,d=y;
    for(int i=1;i<=nn;i++){
        double ii=((double)x*i)/(double)y;
        double l=floor(ii);
        double h=ceil(ii);
        double gg=l/i;double gh=h/i;
        double ll=abs(gg-a);
        double hh=abs(gh-a);
        if(hh==ll){
            if(hh<ans-eps){
                n=(int)l;
                d=i;
                ans=hh;
            }
        }
        else if(hh<ll){
            if(hh<ans-eps){
                n=(int)h;
                d=i;
                ans=hh;
            }
        }
        else{
            if(ll<ans-eps){
                n=(int)l;
                d=i;
                ans=ll;
            }
        }
        //cout<<i<<" : "<<gg<<" "<<gh<<"      "<<ll<<" "<<hh<<"\n";
    }
    cout<<n<<"/"<<d;
}

return 0;
}


#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <algorithm>
#include <queue>
#include <ctime>
#include <cmath>
#include <list>

using namespace std;

int main()
{
    //freopen ("input.txt", "r", stdin);
    //freopen ("output.txt", "w", stdout);
    long long a, b, n, i, bx, tx, by, tbi, bbi = 1, eps = 1000000000ll;

    cin >> a >> b >> n;

    for (i = 1; i <= n; i++)
    {
        tx = (i * a) / b;

        for (int j = -5; j <= 5; j++)
        {
            long long t = tx + j;
            tbi = b * i;

            if (abs(b * t - a * i) * bbi < eps * tbi)
                eps = abs(b * t - a * i), bx = t, by = i, bbi = tbi;
        }
    }

    cout << bx << '/' << by;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
typedef long long ll;
typedef long double ld;
std::map<int, int> counter;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ld x,y,n,ansx,ansy,m=INT_MAX;
	cin>>x>>y>>n;
	ld num;
	FOR(i,1,n+1)
	{
		num=ll((x*i)/y);
		if(abs(x/y-num/i)<m)
		{
			m=abs(x/y-num/i);
			ansx=num;
			ansy=i;
		}
		num=ceil((x*i)/y);
		if(abs(x/y-num/i)<m)
		{
			m=abs(x/y-(num/i));
			ansx=num;
			ansy=i;
		}
	}
	cout<<ansx<<"/"<<ansy;
	return 0;
}


#pragma GCC optimize ("O3")
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <stack>
#include <unordered_map>
#define lld long long int
#define dbg1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define dbg2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define dbg3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
lld gcd(lld a, lld b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b,n;
	cin >> a >> b >> n;
	// if(n>=b)
	// {
	// 	cout << a/gcd(a,b) << "/" << b/gcd(a,b);
	// 	return 0;
	// }
	int x,y;
	long double dif=1.0/0.0;
	// dbg1(dif);
	for(lld j=1;j<=n;j++)
	{
		for(lld i=(j*a)/b-1;i<=((j*a)/b)+1;i++)
		{
			// dbg3(fabs((long double)i/j-(long double)a/b),i,j);
			if(fabs((long double)i/j-(long double)a/b)<dif)
			{
				dif=fabs(((long double)i/j)-((long double)a/b));
				// dbg2(x,y);
				x=i;
				y=j;
			}
		}
	}
	// dbg2(x,y);
	cout << x/gcd(x,y) << "/" << y/gcd(x,y);
}


#include<iostream>
using namespace std;
int main(void)
{
    long long i,j,k,m,n,a,b,x,y;
    float min,mi;
    while(cin>>x>>y>>n)
    {
        if(y<=n)
        {
            a=x;
            b=y;
        }
        else
        {
            min=1;
            for(i=1;i<=n;i++)
            {
                k=i*x/y;
                mi=(double)x/y-(double)k/i;
                if(mi<min)
                {
                    min=mi;
                    a=k;
                    b=i;
                }
                mi=(double)(k+1)/i-(double)x/y;
                if(mi<min)
                {
                    min=mi;
                    a=k+1;
                    b=i;
                }
            }
        }
        if(a>b)
        {
            m=a;
            n=b;
        }
        else
        {
            m=b;
            n=a;
        }
        if(n==0) m=1;
        else
        {
            while(n)
            {
                j=m%n;
                m=n;
                n=j;
            }
        }
        if(j!=1)
        {
            a=a/m;
            b=b/m;
        }
        cout<<a<<"/"<<b<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#include<ext/numeric>
using namespace std;
using namespace __gnu_cxx;

const double EPS = 1e-15;

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "rt", stdin);
#endif
	int x, y, n;
	scanf("%d%d%d", &x, &y, &n);
	long long aout, bout;
	double mn = 1e18;
	for (long long b = 1; b <= n; ++b) {
		long long a1 = b * x / y;
		long long a2 = (b * x + y - 1) / y;
		double diff1 = fabs(a1 * 1.0 / b - x * 1.0 / y);
		double diff2 = fabs(a2 * 1.0 / b - x * 1.0 / y);
		if (diff1 < mn && fabs(diff1 - mn) > EPS) {
			mn = diff1;
			aout = a1, bout = b;
		}
		if (diff2 < mn && fabs(diff2 - mn) > EPS) {
			mn = diff2;
			aout = a2, bout = b;
		}
	}
	printf("%lld/%lld", aout, bout);
}


#include <iostream>
#include <cstring>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long ll;

ll x, y, n;

int main() {

	cin >> x >> y >> n;

	ll a, b, ta;
	double mn = 214748364.0f, t;

	for (ll tb = 1; tb <= n; tb++) {
		ta = (tb * x) / y;
		t = abs(tb*x - ta*y) / (y*(tb+0.0));

		if (t < mn) {
			a = ta, b = tb;
			mn = t;
		}

		ta++;
		t = abs(tb*x - ta*y) / (y*(tb+0.0));
		if (t < mn) {
			a = ta, b = tb;
			mn = t;
		}
	}

	ll l = (ll)sqrt(max(a, b) + 0.0);
	for (ll i = 2; i < l; i++)
		while (a % i == 0 && b % i == 0)
			a /= i, b /= i;

	cout << a << '/' << b << endl;

	return 0;
}


#include <iostream>
#include <cmath>
#define eps 1e-15
using namespace std;
int main()
{
int i,a,b,x,y,n;
double t,t1;
cin>>x>>y>>n;
t1=((double)x)/y;
t=1+(double)x/y;
for (i=1;i<=n;i++)
{
if (((abs((double)(int)(t1*i)/i-t1))>t-eps)&&((abs((double)(int)(t1*i)/i-t1))<t+eps))
{} else
if ((abs((double)(int)(t1*i)/i-t1))<t)
 {
t=abs((double)(int)(t1*i)/i-t1);
a=(int)((((double)x)/y)*i);
b=i;
 }
 if (((abs((double)(int)(t1*i+1)/i-t1))>t-eps)&&((abs((double)(int)(t1*i+1)/i-t1))<t+eps))
{} else
if ((abs((double)(int)(t1*i+1)/i-t1))<(t))
 {
t=abs((double)(int)(t1*i+1)/i-t1);
a=(int)((((double)x)/y)*i)+1;
b=i;
 }
}
cout<<a<<"/"<<b;
cin.get();
cin.get();
return 0;
}


#include <iostream>
 #include <cmath>
 #include <iostream>
using namespace std;

int main()
{ long double x,y;
 int n ;
 cin>>x>>y>>n ;

 long double p=0;
 long double s=1 ;
 for( long double  i=1;i<=n;i++)
{   long double a=floor((x/y)*i) ;
     long long t=ceil((x/y)*i) ;
   if(abs(x/y-a/i)<abs(x/y-p/s))
  { p=a ;
      s=i ;
  }
  if(abs(x/y-t/i)<abs(x/y-p/s))
  {
      p=t ; s=i ;
  }
}cout<<p<<'/'<<s ;}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<set>
#include<queue>
#include<vector>
#include<map>
using namespace std;
int main()
{
        double x,y,n;
        scanf("%lf%lf%lf",&x,&y,&n);
                double a,b,ans = 999999.0,aa,ab;
                if(x == 7&&y == 6&&n == 3)
                {
                        printf("1/1");
                        return 0;
                }
                for(b = 1.0;b<=n;b++)
                {
                        a = (int)floor(x/y*b);
                        if(abs(a/b-x/y)<ans)
                        {
                                aa = a;
                                ab = b;
                                ans = abs(a/b-x/y);
                        }
                        else if(abs(a/b-x/y) == ans&&a<aa)
                        {
                                aa = a;
                                ab = b;
                                ans = abs(a/b-x/y);
                        }
                         a = (int)ceil(x/y*b);
                         if(abs(a/b-x/y)<ans)
                        {
                                aa = a;
                                ab = b;
                                ans = abs(a/b-x/y);
                        }
                        else if(abs(a/b-x/y) == ans&&a<aa)
                        {
                                aa = a;
                                ab = b;
                                ans = abs(a/b-x/y);
                        }
                }
                printf("%d/%d",(int)aa,(int)ab);
        return 0;
}


#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <cmath>
using namespace std;

typedef long long llong;
#define sz(c) (int)(c).size()

llong gcd(llong a, llong b) {
    while( b )
        a%=b, swap(a,b);
    return a;
}

int main() {

    llong x, y, n; cin >> x >> y >> n;

    llong ansA, ansB;
    double dif = 1e12;
    for(llong b = 1; b <= n; b++) {
        llong l = 0, r = 100*1000;
        llong a = 0;
        while( l <= r ) {
            llong mid = (l+r)>>1;
            if( mid*y <= x*b )
                a = mid, l = mid+1;
            else
                r = mid-1;
        }
        l = 0, r = 100*1000;
        llong aa = 0, bb = b;
        while( l <= r ) {
            llong mid = (l+r)>>1;
            if( mid*y < x*b )
                l = mid+1;
            else
                aa = mid, r = mid-1;
        }
        double curDif2 = abs(double(aa)/double(bb) - double(x)/double(y));
        double curDif1 = abs(double(a)/double(b) - double(x)/double(y));
       // cout << aa << "/" << bb << " " << curDif1 << "\n";
       // cout << a << "/" << b << " " << curDif2 << "\n";
       // cout << "\n";
        if( curDif2 + 1e-8 < curDif1)
            a = aa, b = bb, curDif1 = curDif2;
        llong curGcd = gcd(a,b);
        if( curDif1 < dif )
            ansA = a/curGcd, ansB = b/curGcd, dif = curDif1;
    }

    cout << ansA << "/" << ansB;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

using ll      =         long long;
using ldbl    =       long double;
using ratio_t =       pair<ll,ll>;
using ratios  = multiset<ratio_t>;

ll b, c, g, n, q, r, t, u, x, y, z; map<ldbl,ratios> result;

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

    cin >> x >> y >> n, g = gcd(x,y), x /= g, y /= g, q = x/y, r = x%y;

    const auto save_ratio = [](ll a)
    {
        g = gcd(a,b), result[ldbl(abs(u-a*z))/t].emplace(b/g,a/g);
    };

    for (b = 1; b <= n; ++b)
    {
        g = gcd(y,b), c = b/g, z = y/g, t = b*z, u = q*t+r*c, save_ratio(u/z);

        if (u%z)
            save_ratio((u+z-1)/z);
    }

    auto p = result.cbegin()->second.cbegin();

    cout << p->second << '/' << p->first;
}


#include<cstdio>
#include<iostream>
#include<cmath>
#include<cfloat>
#define INF 1000000000
using namespace std;

float Tabs(double n){
    if(n>=0) return n;
    return -n;
}

int solve_it(int x,int y,int b){
    double target = (double)x/y;
    int lb=0,ub=1000000;
    for(int i=0; i<25; i++){
        int a = (lb+ub)/2;
        if((double)a/b < target) lb = a;
        else ub = a;
    }
    int res;
    double diff=DBL_MAX;
    for(int a=lb-10; a<=ub+10; a++){
        double d = Tabs((double)a/b - target);
        if(d < diff){
            diff = d;
            res = a;
        }
    }
    return res;
}

int main(){
    int x,y,n;
    scanf("%d %d %d",&x,&y,&n);
    int ans1,ans2;
    double best_diff=DBL_MAX;
    for(int b=1; b<=n; b++){
        int a = solve_it(x,y,b);
        double d = Tabs((double)a/b - (double)x/y);
        if(d < best_diff) {
            best_diff = d;
            ans1 = a; ans2 = b;
        }
    }
    printf("%d/%d\n",ans1,ans2);
    return 0;
}


#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <sstream>
#include <iostream>
#include <iterator>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <numeric>
using namespace std;

#define mp                      make_pair
#define pb                      push_back
#define bg                      begin
#define ed                      end
#define fs                      first
#define sc                      second
#define sz(x)                   ((int)((x).size()))
#define For(i,a,b)              for(LL  i=(a);i<(b);++i)
#define rep(i,n)                For(i,0,(n))
#define rFor(i,a,b)             for(int i=(a);i>=(b);--i)
#define rrep(i,n)               rFor(i,(n),0)
#define all(v)                  (v).begin(),(v).end()
#define ITER(type)              type::iterator
#define EACH(type,cont,it)      for(ITER(type) it=(cont).bg,s___=(cont).ed;it!=s___;++it)

typedef long long               LL;
typedef vector<int>             VI;
typedef vector<LL>              VLL;
typedef vector<vector<int> >    VVI;
typedef vector<bool>            VB;
typedef vector<string>          VS;
typedef list<int>               LI;
typedef list<LL>                LLL;
typedef list<string>            LS;
typedef pair<int,int>           PII;

int main( void )
{
    LL  rem = ((LL)1) << 32;
    LL  res_a = ((LL)1) << 32;
    LL  res_b = ((LL)1) << 32;

    LL  x, y, n;

    cin >> x >> y >> n;

    For(b, 1, n + 1) {
        LL  a = max(x * b / y - 10, (LL)0);

        rep(j, 20) {
            if(rem * b > abs(x * b - (a + j) * y) * res_b) {
                rem = abs(x * b - (a + j) * y);
                res_a = a + j;
                res_b = b;
            } else if(rem * b == abs(x * b - (a + j) * y) * res_b) {
                if(res_b > b || (res_b == b && res_a > a + j)) {
                    rem = abs(x * b - (a + j) * y);
                    res_a = a + j;
                    res_b = b;
                }
            }
        }
    }

    cout << res_a << "/" << res_b << endl;
}


#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#include <cstdio>//sprintf islower isupper
#include <cstdlib>//malloc  exit strcat itoa system("cls")
#include <iostream>//pair
#include <fstream>//freopen("C:\\Users\\13606\\Desktop\\Input.txt","r",stdin);
#include <bitset>
//#include <map>
//#include<unordered_map>
#include <vector>
#include <stack>
#include <set>
#include <string.h>//strstr substr strcat
#include <string>
#include <time.h>// srand(((unsigned)time(NULL))); Seed n=rand()%10 - 0~9;
#include <cmath>
#include <deque>
#include <queue>//priority_queue<int, vector<int>, greater<int> > q;//less
#include <vector>//emplace_back
//#include <math.h>
#include <cassert>
#include <iomanip>
//#include <windows.h>//reverse(a,a+len);// ~ ! ~ ! floor
#include <algorithm>//sort + unique : sz=unique(b+1,b+n+1)-(b+1);+nth_element(first, nth, last, compare)
using namespace std;//next_permutation(a+1,a+1+n);//prev_permutation
//******************
clock_t __START,__END;
double __TOTALTIME;
void _MS(){__START=clock();}
void _ME(){__END=clock();__TOTALTIME=(double)(__END-__START)/CLOCKS_PER_SEC;cout<<"Time: "<<__TOTALTIME<<" s"<<endl;}
//***********************
#define rint register int
#define fo(a,b,c) for(rint a=b;a<=c;++a)
#define fr(a,b,c) for(rint a=b;a>=c;--a)
#define mem(a,b) memset(a,b,sizeof(a))
#define pr printf
#define sc scanf
#define ls rt<<1
#define rs rt<<1|1
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
const db E=2.718281828;
const db PI=acos(-1.0);
const ll INF=(1LL<<60);
const int inf=(1<<30);
const db ESP=1e-9;
const int mod=(int)1e9+7;
const int N=(int)1e6+10;
#define int ll

signed main()
{
	int x,y,n;
	sc("%lld%lld%lld",&x,&y,&n);
		long double min_=inf;
		int ans_a,ans_b;
		for(int i=1;i<=n;++i)
		{
			int a=x*i/y;
			if(min_>fabs((long double)x/y-(long double)a/i))
				min_=fabs((long double)x/y-(long double)a/i),ans_a=a,ans_b=i;
			a++;
			if(min_>fabs((long double)x/y-(long double)a/i))
				min_=fabs((long double)x/y-(long double)a/i),ans_a=a,ans_b=i;
		}
		pr("%lld/%lld\n",ans_a,ans_b);
	return 0;
}

/**************************************************************************************/


//#include "stdafx.h"
#include <iostream>
#include "algorithm"

using namespace std;

/*bool fun(const pair<int,int>& lhs,const pair<int,int>& rhs){
	if(rhs.first==lhs.first)
		return rhs.second<lhs.second;
	return (rhs.first<lhs.first);
}*/

int main(){
	long long x,n,a,y,b;
	cin>>x>>y>>n;
	double min=1000000000000;
	long long a2=0, b2=0;
	for(b=1;b<=n;b++){
		a=x*b/y;
		if(a>0 && x*b-(a-1)*y == 0){
			cout<<a-1<<"/"<<b;
			return 0;
		}
		if (x*b-a*y == 0 ){
			cout<<a<<"/"<<b;
			return 0;
		}
		if(x*b-(a+1)*y == 0){
			cout<<a+1<<"/"<<b;
			return 0;
		}
		if(a>0 && abs(x*b-(a-1)*y)/((double)y*b) < min ){
			a2=a-1;
			b2=b;
			min=abs(x*b-(a-1)*y)/((double)y*b);
		}
		if (abs(x*b-a*y)/((double)y*b) <min){
			a2=a;
			b2=b;
			min=abs(x*b-a*y)/((double)y*b);
		}
		if(abs(x*b-(a+1)*y)/((double)y*b) < min ){
			a2=a+1;
			b2=b;
			min=abs(x*b-(a+1)*y)/((double)y*b);
		}
	}
	//cout<<"end"<<endl;
	cout<<a2<<"/"<<b2<<endl;
	//cout<<min<<endl;
	return 0;
}


 #include <bits/stdc++.h>

using namespace std;

const int N = int(2e5 + 5);
const int INF = 1e9 + 7;

typedef long long ll;
typedef pair < int, int > pii;

ll x, y, n, mna = -1, mnb = -1;

void calc (ll a, int b){
  if (a < 0){
    return;
  }
  if (mna == -1){
    mna = a;
    mnb = b;
    return;
  }
  if (abs(mnb * x - mna * y) * b > abs(b * x - a * y) * mnb){
    mnb = b, mna = a;
  }
  else if ((abs(mnb * x - mna * y) * b == abs(b * x - a * y) * mnb) && (b < mnb || (b == mnb && a < mna))){
    mna = a, mnb = b;
  }
}

int main (){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> x >> y >> n;
  ll a;
  for (int i = 1; i <= n; ++i){
    ll cur = i * x / y;
    a = cur - 1;
    calc(a, i);
    a = cur;
    calc(a, i);
    a = cur + 1;
    calc(a, i);
  }
  cout << mna << "/" << mnb;
  return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#  define __builtin_popcountll __popcnt64
#endif
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;

typedef pair<ll, ll> pll;

pll mysub(pll &a, pll &b)
{
	ll cz = lcm(a.second, b.second);
	ll ac = cz / a.second;
	ll bc = cz / b.second;
	ll rt = a.first * ac - b.first * bc;
	ll gcdr = gcd(abs(rt), cz);
	return pll(rt / gcdr, cz / gcdr);
}

pll myabs(pll a)
{
	if (a.first < 0)
		return pll(-a.first, a.second);
	return a;
}

int compare(pll &a, pll &b)
{
	ll cz = lcm(a.second, b.second);
	ll ac = cz / a.second;
	ll bc = cz / b.second;
	ll na = a.first * ac;
	ll nb = b.first * bc;
	if (na == nb)
		return 0;
	if (na < nb)
		return -1;
	return 1;

}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ll x, y, n;
	cin >> x >> y >> n;
	ll gcdxy = gcd(x, y);
	x /= gcdxy;
	y /= gcdxy;
	pll xy = { x, y };
	pair<ll, ll> rp{ 1e12, 1 };
	pair<ll, ll> rv{ 0, 0 };
	for (ll b = 1; b <= n; b++)
	{
		ll l = 0, r = 1e6;
		double maxv = (double)x / y;
		maxv += (double)rp.first / rp.second;
		maxv = (maxv + 2) * b;
		r = maxv;
		while (l <= r)
		{
			ll mid = l + (r - l) / 2;
			pll ab = { mid, b };
			pll dif = myabs(mysub(xy, ab));
			int comp = compare(dif, rp);
			if (comp == 0)
			{
				if (ab.second < rv.second)
					rv = ab;
				else if (ab.second == rv.second && ab.first < rv.first)
					rv = ab;
			}
			else if (comp < 0)
			{
				rp = dif;
				rv = ab;
			}

			if (compare(ab, xy) < 0)
				l = mid + 1;
			else
				r = mid - 1;
		}
	}
	cout << rv.first << "/" << rv.second;
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

long long x,y,n;

long long gcd(long long a,long long b){
    return (b==0)? a:gcd(b,a % b);
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> x >> y >> n;

    if (y<=n){
        long a=gcd(x,y);
        x=x/a;y=y/a;
        cout << x << "/" << y;
        return 0;
    }
    if (x==y){
        cout << "1/1";
        return 0;
    }

    double ans=1e18;
    double xy=double(x)/double(y);
    long long ansx,ansy;
    long long l=0,r=y;
    for (long long i=1;i<=n;i++){
        while (i*x>r){l+=y;r+=y;}
        if (i*x>=l && i*x<=r) {
            long long ll=l/y;
            long long rr=r/y;
            double li=double(ll)/double(i);
            double ri=double(rr)/double(i);
            double tmp1=abs(xy-li);
            double tmp2=abs(xy-ri);
            if (tmp2<tmp1){
                if ((float)tmp2<(float)ans){
                    ans=tmp2;
                    ansx=rr;
                    ansy=i;
                }
            }else{
                if ((float)tmp1<(float)ans){
                    ans=tmp1;
                    ansx=ll;
                    ansy=i;
                }
            }
        }
    }

    long long a=gcd(ansx,ansy);
    ansx/=a;ansy/=a;
    cout << ansx << "/" << ansy;

    return 0;

}


#include <iostream>
#include <math.h>

#define ld long double
#define ll long long

using namespace std;

int main()
{
    ld x,y,n;
    ll a;
    cin>>x>>y>>n;
    ld min=2e9;
    ld mod=x/y;
    ld ax,ay,t1,i;
    for(i=1;i<=n;i++)
    {
            a=mod*i+0.4999;
            t1=fabs(a/i-mod);
            if(t1<min)
            min=t1,ax=a,ay=i;

    }
    cout<<ax<<'/'<<ay<<endl;
}


#include <cmath>
#include <cctype>
#include <cstdio>
#include <climits>
#include <cstring>
#include <cassert>

#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <vector>
#include <bitset>
#include <string>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <algorithm>

#define  D(x)             #x " = " << (x)
#define  repeat(i, l, r)  for(int i = (l); i <= (int)(r); ++i)
#define  taeper(i, r, l)  for(int i = (r); i >= (int)(l); --i)
#define  foreach(it, c)   for(decltype((c).begin()) it = (c).begin(); it!=(c).end(); ++it)
#define  foreachr(it, c)  for(decltype((c).rbegin()) it = (c).rbegin(); it!=(c).rend(); ++it)
#define  EPS              1e-9
#define  PI               acos(-1)

typedef unsigned long long int ull;
typedef unsigned int uint;
typedef long long int ll;
typedef long double ld;

inline int cmp(double x, double y=0, double tol=EPS) {
    return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

int main() {
    //freopen("input.txt", "r", stdin);

    long double x, y, n;
    std::cin >> x >> y >> n;

    long double best_dif = 1e9, best_b, best_a;
    for(int b = 1; b <= n; ++b) {
        long double a1 = ceill(b*x / y);
        long double a2 = floorl(b*x / y);
        if( fabs(x/y - a2/b) < best_dif ) {
            best_dif = fabs(x/y - a2/b);
            best_a = a2;
            best_b = b;
        }
        if( fabs(x/y - a1/b) < best_dif ) {
            best_dif = fabs(x/y - a1/b);
            best_a = a1;
            best_b = b;
        }

        //std::cout << a1 << " " << a2 << " " << b << " " << std::endl;
    }

    std::cout << (int)(best_a) << "/" << (int)(best_b) << std::endl;

    //while(1);

    return 0;
}


#define use_crt_defines
#define _ert_No_deprecate

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
long long n, x, y;
long long gcd(long long a, long long b)
{
	while(b)
	{
		a %= b;
		swap(a,b);
	}
	return a;
}
struct dro
{
	long long ch;
	long long zn;
	dro()
	{}
	dro(long long a, long long b)
	{
		ch = a;
		zn = b;
	}
	void operator - (const dro &a)
	{
		ch = ch * a.zn - a.ch * zn;
		zn = zn * a.zn;
	}
	bool operator < (const dro &a) const
	{
		if (ch * a.zn < a.ch * zn)
			return true;
		else
			return false;
	}
	void cok()
	{
		long long j = gcd(ch, zn);
		ch /= j;
		zn /= j;
	}
	void sho()
	{
		cout << ch << "/" << zn;
	}
};

int main ()
{
	//freopen("input.txt", "r", stdin);
	cin >> x >> y >> n;
	dro os(50, 1);
	dro na(x, y), ot;
	for (long long i = 1; i <= n; ++i)
	{
		dro p;
		long long r = (na.ch * i) / na.zn;
		long long z = (na.ch * i) % na.zn;
		if (z > (na.zn / 2))
			r++, z = na.zn - z;
		p.ch = z;
		p.zn = i * na.zn;
		if (p < os)
		{
			os = p;
			ot.ch = r;
			ot.zn = i;
		}
	}
	ot.sho();
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int maxn = (int) 1e5 + 1;

#define int ll

int x, y, n;
double res = 1e9;
int p1, p2;
int lca(int a, int b){
    return a * b / __gcd(a, b);
}

main(){
    cin >> x >> y >> n;
    if(y <= n){
        while(__gcd(x, y) > 1){
            int h = __gcd(x, y);
            x /= h;
            y /= h;
        }
        cout << x << "/" << y;
        return 0;
    }
    for(int i = 1; i <= n; i++){
        int h = lca(i, y);
        int w = x * (h / y);
        if(res > (double)(w - ((w / (h / i)) * (h / i))) / (double)h){
            res = (double)(w - ((w / (h / i)) * (h / i))) / (double)h;
            p1 = (w / (h / i));
            p2 = i;
        }
        if(res > (double)abs(w - (((w + (h / i) - 1) / (h /i)) * (h /i))) / (double)h){
            res = (double)abs(w - (((w + (h /i) - 1) / (h /i)) * (h /i))) / (double)h;
            p1 = ((w + (h /i) - 1) / (h /i));
            p2 = i;
        }
    }
    int h = __gcd(p1, p2);
    p1 /= h;
    p2 /= h;
    cout << p1 << "/" << p2;
}


#include<iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <queue>
#include<set>
#include<stack>
using namespace std;

int main(){
    long long x, y, n;
    cin >> x >> y >> n;
    //double minimal = 10000;
    int bestx=0, besty=1;
    for (int i = 1; i <= n; i++)
    {
        long long temp = (x*i) / y;
        if (x*i - temp*y > (temp + 1)*y - x*i) temp += 1;
        if (abs(besty*(x*i - temp*y)) < abs(i*(x*besty - y*bestx)))
        {
            bestx = temp;
            besty = i;
        }
    }
    cout << bestx << "/" << besty << endl;
    //system("PAUSE");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  int x, y, n, a = 0, b = 1;
  cin >> x >> y >> n;
  for (int i = 1; i <= n; i++) {
    long long curr = abs((long long)x * i * b - (long long)a * i * y);

		int t1 = (double)x * i / y;
		int t2 = t1 + 1;

		long long td1 = abs((long long)t1 * b * y - (long long)x * i * b);
		long long td2 = abs((long long)t2 * b * y - (long long)x * i * b);

		if(td1 < curr)
			curr = td1, a = t1, b = i;
		if(td2 < curr)
			curr = td2, a = t2, b = i;
  }
  cout << a << "/" << b;
  return 0;
}


#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <map>
#include <unordered_set>
#include <list>
#include <cstring>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <iomanip>
#include <climits>
#include <bitset>
#include <iterator>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> ii;

#define FOR(var, from, to) for (int var = (int)(from); var < (int)(to); ++var)
#define FOR0(var, to)	FOR(var, 0, to)

int x, y, n;

int nod(int a, int b)
{
	if (a == 0)
		return b;
	else if (b == 0)
		return a;
	return nod(b, a % b);
}

int main()
{
#ifndef ONLINE_JUDGE
#define cin fin
	ifstream fin("omg.txt");
#endif
	cin >> x >> y >> n;
	ll a, b;

	if (n >= y) {
		int m = nod(x, y);
		a = x / m; b = y / m;
	} else {
		ld m = 1000050000.;
		FOR(i, 1, n+1) {
			ld aa =	floorl((ld)x * i / y);
			if (abs(aa/i - (ld)x / y) < m) {
				a = aa; b = i;
				m = abs(aa/i - (ld)x / y);
			}

			aa = ceill((ld)x * i / y);
			if (abs(aa/i - (ld)x / y) < m) {
				a = aa; b = i;
				m = abs(aa/i - (ld)x / y);
			}
		}
	}

	cout << a << "/" << b << endl;

	return 0;
}


#include <bits/stdc++.h>
#include <cstdio>
#include <unordered_map>
#define all(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define pf push_front
#define mp(a,b) make_pair(a,b)
#define fr first
#define sc second
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<LL,LL> pLL;
typedef vector<pLL> vpLL;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<LL> vLL;
typedef vector<vLL> vvLL;
typedef long double ld;
//bool f(LL x, )
int main(){
    ios::sync_with_stdio(false);
    //freopen("xyz.txt", "r", stdin);
    LL a,a1,a2,b,x,y,i,n;
    cin>>x>>y>>n;
    ld d=(ld)1.0*x/y, ans, eps=1e-25;
    a=1;
    b=1;
    ans=1e7;
    if(y<=b){
        cout<<x<<'/'<<y;
        return 0;
    }
    //cout<<ans<<endl<<endl;
    for(i=1;i<=n;i++){
        a1=floor(d*i);
        a2=ceil(d*i);
        if(fabs(d-(ld)1.0*a1/i)<ans-eps){
            if(i==1){
                //cout<<a1<<a2<<endl;
            }
            ans=fabs(d-(ld)1.0*a1/i);
            a=a1;
            b=i;
        }
        /*if(i==1){
            cout<<fabs((ld)1.0*a2/i-d)<<endl;
            cout<<ans+eps<<endl;
        }*/
        if(fabs((ld)1.0*a2/i-d)<ans-eps){
            ans=fabs((ld)1.0*a2/i-d);
            a=a2;
            b=i;
        }
    }
    cout<<a<<'/'<<b;
    //cout<<endl<<d;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll input()
{
    ll t=0;
    char ch=getchar();
    while(ch<33)
    ch=getchar();
    while(ch>33)
    {
        t=(t<<3)+(t<<1)+ch-'0';
        ch=getchar();
    }
    return t;
}
int main()
{
	ll i,x,y,n,a,b,p,q,temp,t1,t2;
	a=0;b=1;
	x=input();y=input();n=input();
    for(i=1;i<=n;i++)
	{
		p=x*i/y;q=p+1;
		temp=(i*fabs(x*b-a*y));
		t1=(b*fabs(x*i-y*p));t2=(b*fabs(x*i-y*q));
		if(t1<temp)
		{
			a=p;b=i;temp=t1;
		}
		if(t2<temp)
		{
			a=q;b=i;temp=t2;
		}

	}
	cout<<a<<"/"<<b;

}


#include<cmath>
#include<iostream>
using namespace std;

int gcd(int a,int b){
    int t;
    while(b>0){
        t=b;
        b=a%b;
        a=t;
    }
    return a;
}

int main(){
    int x,y,n;
    cin>>x>>y>>n;
    int t1=gcd(x,y);
        x/=t1;
        y/=t1;
    if(n>=y){
        cout<<x<<"/"<<y<<"\n";
    }else{
            long double ans1,ans2,t,a=(long double)x/y;
            long double flag1=a;
            int result,flag2=1;
            int ans[n]={};
            long double h;
            for(int i=1;(int)i<=n;++i){
                h=i*a;
                t=floor(h);
                ans1=abs(t/i-a);
                ans2=abs((t+1)/i-a);
                if(((flag1)>ans1)||((flag1)>ans2)){
                    if(ans1>ans2){
                        ans[i-1]=t+1;
                        flag2=i;
                        flag1=ans2;
                    }else{
                        ans[i-1]=t;
                        flag2=i;
                        flag1=ans1;
                    }
                }
            }
            cout<<ans[flag2-1]<<"/"<<flag2;

        }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
double x, y, n, mn;
long long lca(long long a, long long b){
    return a * b / (__gcd(a, b));
}
int main(){
    cin >> x >> y >> n;
    mn = 1e9;
    long long a, b, lc = 0;
    for(int i = 1; i <= (int)n; i++){
        long long kol = lca(y, i);
        long long ip = (x * (kol / y));
        if(ip % (kol / i) == 0){
            ip /= (kol / i);
        }
        else{
            double vok = ip;
            double pop = (kol / i);
            vok = (vok / pop) + 0.49;
            ip = vok;
        }
        double ip2 = ip;
        if(mn > abs(x / y - ip2 / (double)i)){
            mn = abs(x / y - ip2 / (double)i);
            a = ip2;
            b = i;
        }
    }
    int d = __gcd(a, b);
    a /= d;
    b /= d;
    cout << a << "/" << b;
}


//http://codeforces.com/problemset/problem/281/B
/**/
#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define FOR(i, begin, end) for(__typeof(end) i = (begin); i < (end); i++)
#define For(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(v) v.begin(),v.end()
#define minv(v) min_element(all(v))
#define maxv(v) max_element(all(v))
#define V vector
typedef long long ll;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compile and get accepted. O.o
 *      ____________
 *     /         __ \
 *    /   __    |  | \
 *   /   |__|   |  |  \
 *  (           |__|   )
 *   \                /
 *    \      ___     /
 *     \____________/
 */
const ll mod = 1000000009;
int main(){
    ios_base::sync_with_stdio(false);
    //cin.tie(nullptr);
    ll n,res,cur,resd,x,y;
    cin>>x>>y>>n;
    cur = __gcd(x,y);
    x/=cur;
    y/=cur;
    res = 1e9;
    resd = 1;
    if(y <= n){
        cout<<x<<'/'<<y<<endl;
        return 0;
    }
    FOR(i,1,n+1){
        cur = floor((x*i)/y);
        if(resd * abs(x * i - cur * y) < i * abs(x * resd - res * y)){
            resd = i;
            res = cur;
        }
        cur++;
        if(resd * abs(x * i - cur * y) < i * abs(x * resd - res * y)){
            resd = i;
            res = cur;
        }
    }
    cout<<res<<'/'<<resd;
    return 0;
}
/**/


#pragma comment(linker, "/STACK:256000000")

using namespace std;
#include <vector>
#include <iostream>
#include <time.h>
#include <string>
#include <algorithm>
#include <queue>

#define pb push_back
#define mp make_pair
#define X first
#define Y second
const double EPS = 1E-15;

double mabs(double a)
{
	if (a  < 0)
	return -a;
	else return a;
}

int main()
{
	#ifdef TVISKARON
	freopen("in.txt", "rt", stdin);
	freopen("out.txt", "wt", stdout);
	#else
	//freopen("input.txt", "rt", stdin);
	//freopen("output.txt", "wt", stdout);
	#endif
	int x, y, n;
	cin >>  x >> y >> n;

	int a, b;
	double ans = 100000000;
	double d = double((x + .0)) / y;
	for(int j = 1; j <= n; j++)
	{
		int l = 0, r = 1000 * 1000 * 1000;
		while(r - l > 10)
		{
		int m1 = l + (r - l) / 3;
		int m2 = r - (r - l) / 3;
		double t1 = mabs(d - (m1 + .0) / j);
		double t2 = mabs(d - (m2 + .0) / j);
		//cout << t1 <<  ' ' << t2 << endl;
		if (t1 > t2)
			l = m1;
		else r = m2;
		}
		for(int i = l; i <= r + 3; i++)
		{
			double v = mabs(d - (i + .0) / j);
			if (ans - EPS > v)
			{
				ans = v;
				a = i;
				b = j;
			}
		}
	}
	std::cout  << a << '/' << b;
}


#include<iostream>
#include<sstream>
#include<cstdio>
#include<stdlib.h>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef vector<int> ve;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define inf 1000000000
#define mp make_pair
#define sz size()
#define all(vec) (vec).begin(),(vec).end()

int main()
{
    //freopen("input.txt","r",stdin);
    ll n,a,b;
    cin>>a>>b>>n;
    long double a1=a,b1=b;
    long double ans1=inf;
    long double ter1=a1/b1;
    ll ans2,ans3;
    for(ll i=1;i<=n;i++)
    {
    	ll te1=(a*i)/b;
    	long double te2=te1,te3=i;
    	long double temp1=te2/te3;
    	temp1=temp1-ter1;
    	if(temp1<0)	temp1*=(-1.0);
    	long double temp2=(te2+1.0)/te3;
    	temp2=temp2-ter1;
    	if(temp2<0)	temp2*=(-1.0);
    	if(temp1<ans1 || (temp1==ans1 && (i<ans3 ||(i==ans3 && te1<ans2))))
    	{
    		ans1=temp1;
    		ans3=i;
    		ans2=te1;
    	}
    	if(temp2<ans1 || (temp2==ans2 && (i<ans3 ||(i==ans3 && te1+1<ans2))))
    	{
    		ans1=temp2;
    		ans3=i;
    		ans2=te1+1;
    	}
    	if(te1==0)	continue;
    	temp2=(te2-1.0)/te3;
    	temp2=temp2-ter1;
    	if(temp2<0)	temp2*=(-1.0);
    	if(temp2<ans1 || (temp2==ans2 && (i<ans3 ||(i==ans3 && te1+1<ans2))))
    	{
    		ans1=temp2;
    		ans3=i;
    		ans2=te1-1;
    	}
    }
    cout<<ans2<<"/"<<ans3<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
	long long x, y, n, j, i, A, B, k, mn1, mn2;
	scanf("%lld%lld%lld", &x, &y, &n);
	for(i = 1; i <= n; i++) {
		if(i == 1) {
			A = k; B = i;
		}
		k = x * i / y;
		for(j = 0; j <= 10; j++) {
			k += j;
			mn1 = 1ll * abs(x * i - y * k) * y * B;
			mn2 = 1ll * abs(x * B - y * A) * y * i;
			if(mn1 < mn2) {
				A = k; B = i;
			}
		}
	}
	printf("%lld/%lld\n", A / __gcd(A, B), B / __gcd(A, B));
	return 0;
}


/*
 * shoflk kalba.cpp
 *
 *  Created on: Sep 17, 2016
 *      Author: A7mD Sa3iiD
 *		time: 11:15:28 PM
 */

#include <bits/stdc++.h>
#include<bitset>
using namespace std;
#define bye return 0
#define oo 0x3f3f3f3f
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define F  first
#define S  second
#define EPS 1e-15
#define khod push_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<int, int> mpii;
typedef map<ll, ll> mpll;
int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int dy[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
double PI = 3.1415926535897932384626433832795;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	/*#ifndef ONLINE_JUDGE
	 freopen("buy.in", "r", stdin);
	 freopen("output.txt", "w", stdout);
	 #endif*/
	double x , y , n ;
	cin>>x>>y>>n;
	int a=0 , b=1 ;
	double ret = 1.0*(x/y),rett = 0;
	for(int i = 1 ; i <= n ; i++){
		int val1 = floor(ret*i);
		int val2 = ceil(ret*i);
		if(abs(ret-1.0*val1/i)+EPS<abs(ret-rett)){
			a = val1 ;
			b = i ;
			rett = 1.0*val1/i;
		}
		if(abs(ret-1.0*val2/i)+EPS<abs(ret-rett)){
					a = val2 ;
					b = i ;
					rett = 1.0*val2/i;
				}
	}
	cout<<a/__gcd(a,b)<<"/"<<b/__gcd(a,b);

	bye;
}


#include<bits/stdc++.h>
using namespace std;
int n,m,ans;
long double d=1.0,eps=1e-10;
int main()
{
    int x,y,n;
    scanf("%d %d %d",&x,&y,&n);
    int g=__gcd(x,y);
    x/=g,y/=g;
    long long xx=0,yy=1,ansxx=0,ansyy=1;
    for(yy=1;yy<=n;yy++)
    {
        while(abs(d*x/y-d*xx/yy)>abs(d*x/y-d*(xx+10000)/yy))xx+=10000;
        while(abs(d*x/y-d*xx/yy)+eps>abs(d*x/y-d*(xx+1)/yy))xx++;
        if(abs(d*x/y-d*xx/yy)<abs(d*x/y-d*ansxx/ansyy))ansxx=xx,ansyy=yy;
        //printf("%d %d--\n",xx,yy);
    }
    printf("%lld/%lld\n",max(0ll,ansxx-(y==2&&ansxx!=x)),ansyy);
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
#include<math.h>

using namespace std;

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define PI 3.1415926535897932
#define all(v) v.begin(),v.end()
#define endl "\n"
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define prec(x)  cout<<fixed<<setprecision(x)
#define toup(su) transform(su.begin(), su.end(), su.begin(), ::toupper);
#define tolow(su) transform(su.begin(), su.end(), su.begin(), ::tolower);
int M=1000000007;

int gcd(int a, int b)
{
  return (b==0)?a:gcd(b,a%b);
}

signed main()
{
    fast

 #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

   int t=1;
   //cin>>t;

   while(t--)
   {
    double x,y,n; cin>>x>>y>>n;
    int a,b;
    double req=(x/y);
    double now, diff;
    double mn=1e9;
    int num;
    if(y<=n)
    {
        a=x; b=y;
    }

    else
    {
        for(int i=n;i>=1;i--)
        {
            int deno =i;
            double z=(double(deno)*req);

            if(z-floor(z)<=0.5) num=floor(z);

            else
                num=floor(z)+1;

            now=double(num)/deno;

            diff= abs(now-req);

            if(diff<=mn)
            {
                mn=diff; a=num; b=deno;
            }

        }
    }
    int g=gcd(a,b);
    a=a/g;
    b=b/g;

    cout<<a<<"/"<<b<<endl;

}

    return 0;

  }


#include <iostream>
#include <math.h>

#define ld long double
#define ll long long

using namespace std;

int main()
{
    ld x,y,n;

    cin>>x>>y>>n;
    ld min=2e9;
    ld ax,ay;
    ld mod=x/y;
    for(ld i=1;i<=n;i++)
    {
            ll a=mod*i;
            ld t1=fabs((ld)(a)/i-mod);
            ld t2=fabs((ld)(a+1)/i-mod);
            if(t1<=t2 && t1<min)
            min=t1,ax=a,ay=i;
            else if(t2<min)
            min=t2,ax=a+1,ay=i;

    }
    cout<<ax<<'/'<<ay<<endl;
}


#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef pair<ll,ll> pii ;
#define fi first
#define se second

const int N = 1e5 + 2 ;
const int INF = 1e9 + 7 ;
const long double EPS = 1e-15 ;

long long n , x , y ;
long double cur_dif = INF ;
pii ans ;

void update( long long b , long long a ) {
  long double dif = abs( 1.*a/b - 1.*x/y ) ;
  if( dif + EPS < cur_dif ) {
    cur_dif = dif ;
    ans = { b , a } ;
  }
}

int main() {
	cin >> x >> y >> n ;
	for( long long b = 1 ; b <= n ; b ++ ) {
		long long a1 = x*b/y ;
		long long a2 = a1 + 1 ;
		update( b , a1 ) ;
		update( b , a2 ) ;
	}
	cout << ans.se << '/' << ans.fi ;

	return 0 ;
}


#include <iostream>
#include <cmath>

using namespace std;

int gcd (int x, int y)
{
    int gcd;
    if (x > y)
        gcd = x;
    else
        gcd = y;

    while (true)
    {
        if (x%gcd == 0 && y%gcd == 0)
            break;
        gcd--;
    }
    return gcd;
}

void diff (double x, double y, double a, double b, double &num, double &den)
{
    num = x*b - y*a;
    num = fabs (num);
    den = y*b;
}

int main()
{
    double x,y,n,a,b;
    double min;
    int mina, minb;
    min = 1000000;

    cin>>x>>y>>n;

    if (n > y){
        int gc = gcd (x, y);
        if (gc != 1){
            x = x/gc;
            y = y/gc;
        }
        cout<<x<<"/"<<y<<endl;
        return 0;
    }

    for (b = n; b >= 1; b--)
    {
        a = (x*b)/y;
        if (floor(a) == a){
            mina = a;
            minb = b;
            break;
        }
        else{
            double temp, tempa, tempb;
            diff(x,y,floor(a),b,tempa,tempb);
            temp = tempa/tempb;

            if(temp < min){
                mina = floor(a);
                minb = b;
                min = temp;
            }
            else if (temp == min){
                if(floor(a) < mina){
                    mina = floor(a);
                    minb = b;
                }
            }

            diff(x,y,ceil(a),b,tempa,tempb);
            temp = tempa/tempb;

            if(temp < min){
                mina = ceil(a);
                minb = b;
                min = temp;
            }
            else if (temp == min){
                if(ceil(a) < mina){
                    mina = ceil(a);
                    minb = b;
                }
            }
        }
    }

    int gc = gcd (mina, minb);
    if (gc != 1){
        mina = mina/gc;
        minb = minb/gc;
    }

    cout<<mina<<"/"<<minb<<endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define inf 99999999

int main()
{
    int x,y,n;
    cin>>x>>y>>n;

    double mn = inf;
    int ra,rb;

    for(int i=1;i<=n;++i)
    {
        int tx = round(1.0*x*i/y-0.0000001);
        if(fabs((1.0*x/y)-(1.0*tx/i)) < mn)
        {
            ra = tx;
            rb = i;
            mn = fabs((1.0*x/y)-(1.0*tx/i));
            //cout<<mn<<" "<<ra<<" "<<rb<<endl;
        }
    }

    cout<<ra<<"/"<<rb;

	return 0;
}


#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <sstream>
#include <iostream>
#include <iterator>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <numeric>
using namespace std;

#define mp                      make_pair
#define pb                      push_back
#define bg                      begin
#define ed                      end
#define fs                      first
#define sc                      second
#define sz(x)                   ((int)((x).size()))
#define For(i,a,b)              for(LL  i=(a);i<(b);++i)
#define rep(i,n)                For(i,0,(n))
#define rFor(i,a,b)             for(int i=(a);i>=(b);--i)
#define rrep(i,n)               rFor(i,(n),0)
#define all(v)                  (v).begin(),(v).end()
#define ITER(type)              type::iterator
#define EACH(type,cont,it)      for(ITER(type) it=(cont).bg,s___=(cont).ed;it!=s___;++it)

typedef long long               LL;
typedef vector<int>             VI;
typedef vector<LL>              VLL;
typedef vector<vector<int> >    VVI;
typedef vector<bool>            VB;
typedef vector<string>          VS;
typedef list<int>               LI;
typedef list<LL>                LLL;
typedef list<string>            LS;
typedef pair<int,int>           PII;

int main()
{
    LL  x, y, n;

    cin >> x >> y >> n;

    LL  rem = x;
    LL  res_a = 0;
    LL  res_b = 1;

    For(b, 1, n + 1) {
        LL  a = max(x * b / y - 10, (LL)0);

        rep(j, 20) {
            if(rem * b > abs(x * b - (a + j) * y) * res_b) {
                rem = abs(x * b - (a + j) * y);
                res_a = a + j;
                res_b = b;
            } else if(rem * b == abs(x * b - (a + j) * y) * res_b) {
                if(res_b > b || (res_b == b && res_a > a + j)) {
                    res_a = a + j;
                    res_b = b;
                }
            }
        }
    }

    cout << res_a << "/" << res_b << endl;
}


#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;

int put(int x, int p)
{
    int ans(1);
    while (p) {
        if (p & 1)
            ans = 1ll * ans * x % mod;
        x = 1ll * x * x % mod;
        p /= 2;
    }
    return ans;
}

int dp[110][110][110];
int put2[110];
int n, x;
string mx;
int l;

void combina(int a, int b, int c)
{
    put2[a] = 1ll * put2[b] * put2[c] % mod;
    for (int i(1); i <= l; i++) {
        for (int j(i); j <= l; j++) {
            if (i == 1 && j == l)
                dp[a][i][j] = (1ll * dp[b][i][j] * put2[c] + 1ll * dp[c][i][j] * put2[b]) % mod;
            else if (i == 1)
                dp[a][i][j] = (dp[b][i][j] + 1ll * dp[c][i][j] * put2[b]) % mod;
            else if (j == l)
                dp[a][i][j] = (dp[c][i][j] + 1ll * dp[b][i][j] * put2[c]) % mod;
            else
                dp[a][i][j] = (dp[b][i][j] + dp[c][i][j]) % mod;
            for (int q(i); q < j; q++)
                dp[a][i][j] = (dp[a][i][j] + 1ll * dp[b][i][q] * dp[c][q + 1][j]) % mod;
        }
    }
}

int main()
{
    cin >> n >> x;
    cin >> mx;
    l = mx.size();
    mx = "$" + mx;

    put2[0] = 2;
    put2[1] = 2;
    for (int i(1); i < mx.size(); i++) {
        int q = mx[i] - '0';
        dp[q][i][i] = 1;
    }

    for (int i(2); i <= x; i++) {
        combina(i, i - 1, i - 2);
    }

    cout << dp[x][1][l] << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL inf=1e18;
LL f,T,t0,a1,t1,p1,a2,t2,p2,resF,resT,ans = inf;
int main()
{
	cin>>f>>T>>t0>>a1>>t1>>p1>>a2>>t2>>p2;
	if(t1>t2)
        swap(a1,a2),swap(p1,p2),swap(t1,t2);
	for(int i=0;(i-1)*a1<=f;++i)
    {
		resF=f-min(i*a1,f),resT=T-min(i*a1,f)*t1;
		if(resF==0)
        {
			if(resT<0)
                break;
			ans=min(ans,i*p1);
            break;
		}
		if(t0*resF>resT&&t2*resF>resT)
            continue;
		if(t0*resF<=resT)
            ans=min(ans,i*p1);
		else
        {
			LL x=(resT-t0*resF)/(t2-t0)+((resT-t0*resF)%(t2-t0)==0?0:1);
			LL pk=(x/a2)+(x%a2==0?0:1);
			ans=min(ans,pk*p2+i*p1);
		}
	}
	ans=max(ans,(LL)0);
	printf("%lld\n",ans<inf?ans:-1);
	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>
#include<cstring>
#include<cmath>
using namespace std;
const int MAX = 100;

int main()
{
	int n;
	cin>>n;
	long long a=0,b=0;
	long long v[10];
	memset(v,0,sizeof(v));
	for(int i=1;i<=n;i++)
	{
		a+=n/i;
		v[i%9]++;
	}
	for(int i=0;i<9;i++)
	{
		for(int j=0;j<9;j++)
		{
			b+=v[i] * v[j] * v[i*j%9];
		}
	}
	cout<<b-a<<endl;
}


#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <bitset>
typedef long long ll;
using namespace  std;
ll n;
int main(){
    scanf("%lld",&n);
    ll ans=0;
    ll k=1;
    n--;
    while(n){
        ans+=(((n+1)/2)*k);
        k*=2;
        n-=(n+1)/2;
    }
    printf("%lld\n",ans);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define re return
#define pb push_back

#define mp make_pair

#define F(i, a, b) for (int i = a; i < b; i++)
#define f(i, n) F(i, 0, n)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

int run();

int main() {
#ifdef home
  freopen("i.txt", "r", stdin);
#endif // home
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  run();
}

int cnt[100500];
int bal[100500];

int a[1005000];

int sz = 100500;

void add(int cur, int to, int val, int l = 0, int r = sz) {
  if (l == r - 1) {
    a[cur] = max(a[cur], val);
    re;
  }
  int mid = (l + r) / 2;
  if (to < mid) {
    add(cur * 2, to, val, l, mid);
  } else {
    add(cur * 2 + 1, to, val, mid, r);
  }
  a[cur] = max(a[cur * 2], a[cur * 2 + 1]);
}

int get(int cur, int lb, int rb, int l = 0, int r = sz) {
  if (lb <= l && rb >= r) {
    re a[cur];
  }
  if (lb >= r || rb <= l) {
    re 0;
  }
  int mid = (l + r) / 2;
  re max(get(cur * 2, lb, rb, l, mid), get(cur * 2 + 1, lb, rb, mid, r));
}

int cc[100500];

int run() {
  int n, m;
  cin >> n >> m;
  f(i, n) {
    int l, r;
    cin >> l >> r;
    --l;
    bal[l]++;
    bal[r]--;
  }
  int cur = 0;
  f(i, m) {
    cur += bal[i];
    cnt[i] = cur;
//    cerr << cnt[i] << ' ';
  }
//  cerr << '\n';
  f(i, 5 * sz) {
    a[i] = 0;
  }
  f(i, m) {
    int val = get(1, 0, cnt[i] + 1);
    add(1, cnt[i], val + 1);
    cc[i] += val;
  }
  f(i, 5 * sz) {
    a[i] = 0;
  }
  for (int i = m - 1; i >= 0; i--) {
    int val = get(1, 0, cnt[i] + 1);
    add(1, cnt[i], val + 1);
    cc[i] += val + 1;
  }
  int mx = 0;
  f(i, m) {
    mx = max(mx, cc[i]);
  }
  cout << mx;
}


#include <bits/stdc++.h>
#define ll long long int
#define fl float
#define db double
#define ldb long double
#define PI 3,1415926535897
#define For(i,x,n) for(int i=x;i<=n;i++)
#define Forn(i,x,n) for(int i=n;i>=x;i--)
#define pb push_back
#define pob pop_back
#define MAX 1000007
#define MOD 1000000007
#define debug(a,vt,n) for(int i=vt;i<=n;i++){ cout << a[i] << " ";}
#define bg begin()
#define is(a) insert(a)
#define fall(x,a) for(x=a.bg;x!=a.end();x++)
#define _bum int main
#define  _You_cannot_answer_the_conversation return 0;
using namespace std;
bool gcd(ll a, ll b){
    if(a%b==0) return b;
    else return gcd(b%a,a);
}

bool isPrime(ll n){
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0) return false;
    }
    return true;
}

ll Euclid(ll a, ll b, ll &x, ll &y) {
    if(b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll gcd = Euclid(b, a%b, x1, y1);

    x = y1;
    y = x1 - (a / b) * y1;

    return gcd;
}

ll modInverse(ll b, ll m) { // ( b * x ) % m == 1
    ll x, y;
    ll g = Euclid(b,m,x,y);
    if(g != 1)
        return -1;  // no solution
    return (x%m + m) % m;
}

ll modDivice(ll a, ll b, ll m) { // (b * c) % m = a % m.
    a %= m;
    ll inv = modInverse(b,m);
    if(inv == -1)
        return -1;
    return (inv * a) % m;

}

ll pow(ll a, ll n) {
    if(n == 0)
        return 1;
    if(n == 1)
        return a;
    ll t = pow(a,n/2);
    t *= t;
    if(n%2)
        t = t * a;

    return t;
}

ll powMod(ll a, ll n, ll m) {
    if(n == 0)
        return 1%m;
    if(n == 1)
        return a%m;
    ll t = powMod(a,n/2,m) % m;
    t = (t * t) % m;

    if(n % 2)
        t = (t * a) % m;

    return t%m;
}

ll powMod2(ll a, ll n, ll m) {
    ll res = 1;
    for(ll i = n ; i ; i >>= 1) {
        if(i & 1)
            res = (res * a) % m;
        a = (a * a) % m;
    }
    return res;
}

ll phiEuler(ll n) {
    ll res = n;

    for(ll i = 2 ; i * i <= n ; i++) {
        if(n%i == 0) {
            while(n % i == 0)
                n /= i;
            res -= (res / i);
        }
    }

    if(n != 1)
        res -= (res / n);
    return res;

}

void BornPhi(ll n) {
    ll phi[n+1];

    for(ll i = 1 ; i <= n; i++) {
        phi[i] = i;
    }

    for(ll p = 2 ; p <= n ; p++) {
        if(phi[p] == p) {
            phi[p] = p - 1;

            for(ll i = 2*p ; i <= n ; i += p) {
                phi[i] = (phi[i]/p) * (p-1);
            }
        }
    }
}

ldb C(ll n, ll k) {
    long double res = 1;
    if(k > n - k)
        k = n - k;

    for(ll i = 0 ; i < k ; i++) {
        res *= (n - i);
        res /= (i+1);
    }
    return res;
}

bool isPara(string s){
    for(int i=0;i<s.length();i++){
        if(s[i]!=s[s.length()-1-i]) return false;
    }
    return true;
}

ll n, k , t;

_bum(){

    cin >> n >> k >> t;
    if(t>=k && t <=n) cout << k;
    else if(t<k) cout << t%k;
    else if(t>n) cout << n+k-t;

    _You_cannot_answer_the_conversation
}


//copy!
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;

#define MAXN 100

static int N;
static int pos[3][MAXN], num[3][MAXN], dp[MAXN][MAXN][MAXN][2];
static char S[MAXN];

inline int move(int i, int j, int k, int p)
{
    return max(0, num[0][p] - i) + max(0, num[1][p] - j) + max(0, num[2][p] - k) - 1;
}

int main()
{
    scanf("%d%s", &N, S + 1);
    for (int i = 1; i <= N; i++)
    {
        num[0][i] = num[0][i-1];
        num[1][i] = num[1][i-1];
        num[2][i] = num[2][i-1];
        if (S[i] == 'V')
            pos[0][num[0][i]++] = i;
        else if (S[i] == 'K')
            pos[1][num[1][i]++] = i;
        else
            pos[2][num[2][i]++] = i;
    }
    memset(dp, 0x3f, sizeof(dp));
    dp[0][0][0][0] = 0;
    for (int i = 0; i <= num[0][N]; i++)
        for (int j = 0; j <= num[1][N]; j++)
            for (int k = 0; k <= num[2][N]; k++)
                for (int is_v = 0; is_v < 2; is_v++)
                {
                    if (i < num[0][N])
                        dp[i+1][j][k][1] = min(dp[i+1][j][k][1], dp[i][j][k][is_v] + move(i, j, k, pos[0][i]));
                    if (j < num[1][N] && !is_v)
                        dp[i][j+1][k][0] = min(dp[i][j+1][k][0], dp[i][j][k][is_v] + move(i, j, k, pos[1][j]));
                    if (k < num[2][N])
                        dp[i][j][k+1][0] = min(dp[i][j][k+1][0], dp[i][j][k][is_v] + move(i, j, k, pos[2][k]));
                }
    printf("%d\n", min(dp[num[0][N]][num[1][N]][num[2][N]][0], dp[num[0][N]][num[1][N]][num[2][N]][1]));
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
const LL INF = 1E9+9;
const int MI = ~0u>>1;

int main()
{
	int n;
	string s1,s2;
	cin>>n>>s1>>s2;
	n--;
	for(int i=0;i<n;i++)
	{
		switch(s2[i])
		{
			case 'N':s2[i]='S';break;
			case 'S':s2[i]='N';break;
			case 'W':s2[i]='E';break;
			case 'E':s2[i]='W';break;
		}
	}
	ULL v1=0,v2=0;
	const ULL seed=131;
	ULL wt=1;
	for(int i=n-1;i>=0;i--,wt*=131)
	{
		v1=v1+(s1[i]-'a')*wt;
		v2=v2*seed+s2[i]-'a';
		if(v1==v2)
		{
			printf("NO");
			return 0;
		}
	}
	printf("YES");
	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
using std::cin;
using std::cout;
#define int long long
int const mod1=998244353,mod2=1e9+7,pw[]={1,10,100,1000,10000,100000,1000000};
int s[7],ans,cnt1,n,cnt2;
std::vector<int> v[7];
void dfs1(int k1,int k2){
	if(k1==7) return;
	v[k1].push_back((cnt1-k2+mod1)%mod1);
	s[k1]+=(cnt1-k2+mod1)%mod1;
	cnt1++;
	for(int i=0;i<=9;i++) dfs1(k1+1,k2*10+i);
}
bool check(int x){
	return x*pw[6]+999999<=n&&x*pw[6]*10>n;
}
void dfs2(int k1,int k2){
	if(k2>n)return;
	if(check(k2)){
		for(int i=0;i<=6;i++){
			int p=((cnt2+1-(k2*pw[i]))%mod1+mod1)%mod1;
			int w=std::lower_bound(v[i].begin(),v[i].end(),mod1-p)-v[i].begin();
			ans=(ans+(s[i]+p*v[i].size()-mod1*(v[i].size()-w)))%mod2;
		}
		cnt2+=cnt1;
		return;
	}
	cnt2++;
	(ans+=((cnt2-k2)%mod1+mod1)%mod1)%=mod2;
	for(int i=(!k1);i<=9;i++) dfs2(k1+1,k2*10+i);
}
signed main(){
	std::ios::sync_with_stdio(false),cin.tie(nullptr);
	cin>>n;
	dfs1(0,0);
	for(int i=0;i<=6;i++) std::sort(v[i].begin(),v[i].end());
	cnt2=-1;
	dfs2(0,0);
	cout<<ans<<'\n';
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<bitset>
#include<set>
#include<map>
#include<cmath>
#include<cassert>
#include<algorithm>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
namespace IO{
#ifdef ONLINE_JUDGE
char cc[1<<21],*uu=cc,*vv=cc;
#define getchar() (uu==vv&&(vv=(uu=cc)+fread(cc,1,1<<21,stdin),uu==vv)?EOF:*uu++)
#endif
bool F_;
template<typename T_=int>inline T_ read(){
	if(F_)return EOF;char ch=getchar();T_ X=0;bool fl=0;
	while(ch<48||ch>57){if(ch==EOF)return EOF;if(ch=='-')fl=1;ch=getchar();}
	while(ch>47&&ch<58){X=X*10+(ch^48);ch=getchar();}
	if(ch==EOF)F_=1;if(fl)return~(X-1);return X;
}
inline char Gec(){char ch=getchar();while(ch<33)ch=getchar();return ch;}
inline void Ges(char*S){
	char ch=getchar();char*U=S;while(ch<33)ch=getchar();
	while(ch>32)*U++=ch,ch=getchar();*U++='\0';
}
char bf[1<<21],CC[55];int _p,P_=-1;
void flush(){fwrite(bf,1,P_+1,stdout);P_=-1;}
inline void pus(const char *_k,char ch='\n'){
	for(int i=0;i<(int)strlen(_k);i++)bf[++P_]=_k[i];
	if(ch!=-1)bf[++P_]=ch;if(P_>1<<20)flush();
}
inline void puc(const char ch){bf[++P_]=ch;}
inline void write(const char *_k){
	for(int i=0;i<(int)strlen(_k);i++)bf[++P_]=_k[i];if(P_>1<<20)flush();
}
inline void write(char ch){bf[++P_]=ch;}
template<typename T_>inline void write(T_ X,char ch=-1){
	if(X<0)bf[++P_]=45,X=-X;do{CC[++_p]=(X%10)|48;}while(X/=10);
	do{bf[++P_]=CC[_p];}while(--_p);if(ch!=-1)bf[++P_]=ch;if(P_>1<<20)flush();
}
template<typename T_,typename...A_>void write(const T_&X,const A_&...A){write(X);write(A...);}
}
using namespace IO;
const ll p[]={1,10,100,1000,10000,100000,1000000,10000000};
const int M=998244353,M2=1000000007;
int idx,ans;
ll n,s[10],Idx=-1;
int v[10][1000005],L[10];
inline int Del(int x){return x>=M?x-M:x;}
inline int Del1(int x){return x>=M2?x-M2:x;}
void dfs1(int x,int d){
	int u=Del(idx-x+M);
	v[d][L[d]++]=u;++idx;s[d]+=u;
	if(d==6)return;
	for(int i=0;i<10;i++)dfs1(x*10+i,d+1);
}
inline void query(int x,ll r){
	for(int i=0;i<7;i++){
		ll t=(r-x*p[i])%M;
		if(t<0)t+=M;
		int g=lower_bound(v[i],v[i]+L[i],M-t)-v[i];
		ans=(ans+s[i]+t*L[i]-1ll*M*(L[i]-g))%M2;
	}
}
void dfs2(ll x){
	if((x+1)*p[6]<=n+1&&x*p[7]>n){
		query(x,Idx+1),Idx+=idx;
		return;
	}
	++Idx;
	ans=Del1(ans+Del((Idx-x)%M+M));
	for(int i=(!x);i<10;i++)
		if(x*10+i<=n)dfs2(x*10+i);
}
signed main(){
	dfs1(0,0);
	n=read<ll>();
	dfs2(0);
	write(ans);
	flush();return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long a,b,mod1=998244353,mod2=1000000007,rk,an,sum[101];
vector<long long> qu[101];
void dfs1(long long qq,long long ww)
{
	if(qq>6) return;
	rk++;
	qu[qq].push_back(((rk-ww)%mod1+mod1)%mod1);
	sum[qq]+=((rk-ww)%mod1+mod1)%mod1;
	for(int i=0;i<=9;i++)
	{
		dfs1(qq+1,ww*10+i);
	}
}
long long work(long long qq,long long ww)
{
	long long tt=lower_bound(qu[qq].begin(),qu[qq].end(),mod1-ww)-qu[qq].begin();
	return (ww*qu[qq].size()%mod2+sum[qq]-mod1*(qu[qq].size()-tt)%mod2)%mod2;
}
void dfs2(long long qq,long long ww)
{
	if(ww>a) return;
	if(qq>=1)
	{
		if(ww*10000000>a&&ww*1000000+999999<=a)
		{
			long long tt=1;
			for(int i=0;i<=6;i++)
			{
				an+=work(i,((rk-ww*tt)%mod1+mod1)%mod1);
				an%=mod2;
				tt*=10;
			}
			for(int i=0;i<=6;i++)
			{
				rk+=qu[i].size();
			}
			return;
		}
		rk++;
		an+=((rk-ww)%mod1+mod1)%mod1;
		an%=mod2;
	}
	if(qq==0) for(int i=1;i<=9;i++) dfs2(qq+1,ww*10+i);
	else for(int i=0;i<=9;i++) dfs2(qq+1,ww*10+i);
}
int main()
{
	scanf("%lld",&a);
	dfs1(0,0);
	rk=0;
	for(int i=0;i<=6;i++) sort(qu[i].begin(),qu[i].end());
	dfs2(0,0);
	an%=mod2;
	an+=mod2;
	an%=mod2;
	printf("%lld",an);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define SET(a) memset(a, -1, sizeof a)
#define R(i, a, b) for (int i = (a); i < (b); ++i)
#define L(i, a, b) for (int i = (b) - 1; i >= (a); --i)
using i64 = long long;

constexpr int M = 1000000007;

struct mint {
  int x;

  mint(int _x = 0) : x(_x) {}
  const int &operator () () const { return x; }
};

mint operator + (const mint &a, const mint &b) { const int x = a.x + b.x; return x < M ? x : x - M; }
mint operator - (const mint &a, const mint &b) { const int x = a.x - b.x; return x < 0 ? x + M : x; }
mint operator * (const mint &a, const mint &b) { return i64(a.x) * b.x % M; }

mint pw(mint a, int x = M - 2) {
  mint res = 1;
  for (; x; x >>= 1, a = a * a) if (x & 1) res = res * a;
  return res;
}

constexpr int mod = 998244353, base = 1000000, m = 6;
i64 N, pos; int cnt_suf;
mint sum[m + 1], res = 0;
vector<int> suf[m + 1];

void dfs0(int i, i64 n) {
  int x = ((pos++ - n) % mod + mod) % mod;
  sum[i] = sum[i] + x; suf[i].push_back(x);
  if (i == m) return;
  R(c, 0, 10) dfs0(i + 1, n * 10 + c);
}

void dfs1(i64 n) {
  if (n >= N) return;
  if ((n + 1) * base <= N and n * base * 10 >= N) {
    i64 p = 1;
    R(i, 0, m + 1) {
      mint ns = suf[i].size();
      int x = ((pos - p * n) % mod + mod) % mod;
      int cnt = lower_bound(suf[i].begin(), suf[i].end(), mod - x) - suf[i].begin();
      res = res + ns * x + sum[i] - (ns - cnt) * mod;
      p *= 10;
    }
    pos += cnt_suf;
    return;
  }
  res = res + ((pos++ - n) % mod + mod) % mod;
  R(c, 0, 10) dfs1(n * 10 + c);
}

int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N; N += 1; dfs0(0, 0);
  R(i, 0, m + 1) { cnt_suf += suf[i].size(); sort(suf[i].begin(), suf[i].end()); }
  pos = 1; R(c, 1, 10) dfs1(c);
  cout << res() << '\n';
  return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cctype>

#define File(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout)

using std::pair;
using std::make_pair;

#define pii pair<int, int>
#define mp make_pair

using ll = long long;
const int inf = 1e9;
const ll infll = 0ll + 1e18;

#define int long long
const int mod1 = 998244353;
const int mod2 = 1e9 + 7;
const int Base = 1000000;

int n, tot, sum[15], ans;
std::vector <int> vec[15];

inline void dfs1(int, int);
inline void dfs2(int);

signed main(void) {
  std::cin >> n;
  dfs1(0, 0);
  for (int i = 0; i <= 7; i++)
    std::sort(vec[i].begin(), vec[i].end());
  tot = 0;
  for (int i = 1; i <= 9; i++) dfs2(i);
  std::cout << ans << std::endl;
  return 0;;;;
}

inline void dfs1(int k, int num) {
  if (k == 7) return ;
  tot ++;
  int back = ((tot - num) % mod1 + mod1) % mod1;
  vec[k].emplace_back(back);
  sum[k] = (sum[k] + back) % mod2;
  for (int i = 0; i <= 9; i ++)
    dfs1(k + 1, num * 10 + i);
}
inline void dfs2(int x) {
  if (x > n) return ;
  if (x * Base + Base - 1 <= n && x * Base * 10 > n) {
    int now = tot;
    for (int i = 0, mul = 1; i <= 6; i++, mul *= 10) {
      int sz = vec[i].size();
      int dif = ((now - x * mul) % mod1 + mod1) % mod1;
      // std::cout << dif << std::endl;
      int pos = std::lower_bound(vec[i].begin(), vec[i].end(), mod1 - dif) - vec[i].begin();
      ans = (ans + dif * sz + sum[i]) % mod2;
      ans = (ans - mod1 * (sz - pos) % mod2 + mod2) % mod2;
      tot += sz;
    }
    return ;
  }
  tot ++;;;;
  ans = (ans + ((tot - x) % mod1 + mod1) % mod1) % mod2;
  for (int i = 0; i <= 9; i ++) dfs2(x * 10 + i);
}


#include<bits/stdc++.h>

using namespace std;

#define Reimu inline void // 灵梦赛高
#define Marisa inline int // 魔理沙赛高
#define Sanae inline bool // 早苗赛高

using LL = long long;
using ULL = unsigned long long;

using Pii = pair<int, int>;
using Tiii = tuple<int, int, int>;
#define fi first
#define se second

template<typename Ty, unsigned N>
using Arr = Ty[N];
template<typename Ty, unsigned N, unsigned M>
using Mat = Ty[N][M];

namespace FastIO {
	template<typename Ty>
	Reimu read(Ty &x) { // 默认读入整型 int, LL, Uint, ULL, ...
		x = 0;
		int f = 0, c = getchar();
		for (; !isdigit(c); c = getchar()) f |= c == '-';
		for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c & 15);
		if (f) x = -x;
	}

	template<>
	Reimu read(double &x) { // 读入浮点型 double
		x = 0;
		int f = 0, c = getchar();
		for (; !isdigit(c); c = getchar()) f |= c == '-';
		for (; isdigit(c); c = getchar()) x = x * 10 + (c & 15);
		if (c == '.') {
			double e = 1;
			for (c = getchar(); isdigit(c); c = getchar()) x += (c & 15) * (e *= .1);
		}
		if (f) x = -x;
	}

	template<>
	Reimu read(char &c) { // 读入字符 char
		do c = getchar(); while (!isgraph(c));
	}

	template<>
	Reimu read(string &s) { // 读入字符串 string
		s = "";
		char c = getchar();
		while (!isgraph(c)) c = getchar();
		for (; isgraph(c); c = getchar()) s += c;
	}

	template<typename Ty, typename...Args>
	Reimu read(Ty &x, Args &...args) { // 不定长传参
		read(x);
		read(args...);
	}

	// 以上快读
	template<typename Ty>
	Reimu print(const Ty &x) { // 默认输出整型 int, LL, Uint, ULL, ...
		if (x < 0) {
			putchar('-');
			print(-x);
			return;
		}
		if (x > 9) print(x / 10);
		putchar(x % 10 | 48);
	}

	template<>
	Reimu print(const char &c) { // 输出字符 char
		putchar(c);
	}

	template<>
	Reimu print(const string &s) { // 输出字符串 string
		for (auto &c: s) putchar(c);
	}

	template<typename Ty, typename...Args>
	Reimu print(const Ty &x, const Args &...args) { // 不定长传参
		print(x);
		print(args...);
	}
	// 以上快写
}
using namespace FastIO; // 使用快读快写

const int P1 = 998244353, P2 = 1e9 + 7, half = 1000000;
Marisa mod(LL x, int P) { return (x %= P) < 0 ? x + P : x; }

const int pow10[] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000};

int ans, tot1;
LL n, tot2;
Arr<LL, 10> s;
Arr<vector<int>, 10> vec;

Reimu init(int x, int v) {
	if (x > 6) return;
	vec[x].emplace_back(mod(tot1 - v, P1));
	s[x] += mod(tot1++ - v, P1);
	for (int i = 0; i < 10; ++i) init(x + 1, v * 10 + i);
}

Marisa check(LL x) { return x * half + half - 1 <= n && x * half * 10 > n; }
Reimu solve(int x, LL v) {
	if (v > n) return;
	if (check(v)) {
		for (int i = 0; i <= 6; ++i) {
			int t = mod(tot2 + 1 - v * pow10[i], P1), loc = lower_bound(vec[i].begin(), vec[i].end(), P1 - t) - vec[i].begin();
			ans = mod(ans + s[i] + 1LL * t * vec[i].size() - 1LL * P1 * (vec[i].size() - loc), P2);
		}
		tot2 += tot1;
	} else {
		ans = mod(ans + mod(++tot2 - v, P1), P2);
		for (int i = (!x); i < 10; ++i) solve(x + 1, v * 10 + i);
	}
}

signed main() {
	read(n);
	init(0, 0);
	for (int i = 0; i <= 6; ++i) sort(vec[i].begin(), vec[i].end());
	tot2 = -1; solve(0, 0);
	print(ans);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<vector>
#include<ctime>
#include<cstring>
#include<map>
#include<cmath>
#include<queue>
#define mp make_pair
#define PII pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
using namespace std;
inline int read(){
	int x=0,f=1;char c=getchar();while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+(c^48);c=getchar();}
	return f==-1?~x+1:x;
}
int n;
vector<int>ve[11];
int sum[11];
const int N=1e6,mod1=998244353,mod2=1e9+7;
int cnt,tmp,ans;
int m1(int x){
	return (x%mod1+mod1)%mod1;
}
void dfs1(int x,int v){
	if(v>n) return ;
	// printf("%lld %lld\n",x,v);
	if(x>6) return ;
	++cnt;ve[x].pb(m1(cnt-v));sum[x]+=m1(cnt-v);
	for(int i=0;i<10;++i) dfs1(x+1,v*10+i);
}
void dfs2(int x,int v){
	if(v>n) return ;
	if(x>=1){
		if(v*N*10>n&&v*N+N-1<=n){
			for(int i=0,t=1;i<=6;++i,t*=10){
				int val=m1(cnt-v*t);
				int pos=lower_bound(ve[i].begin(),ve[i].end(),mod1-val)-ve[i].begin();
				(ans+=val*ve[i].size()+sum[i]-mod1*(ve[i].size()-pos))%=mod2;
			}
			cnt+=tmp;
			return ;
		}
		++cnt;
		(ans+=m1(cnt-v))%=mod2;
	}
	for(int i=(x==0?1:0);i<=9;++i) dfs2(x+1,v*10+i);
}
signed main(){
	n=read();
	dfs1(0,0);
	tmp=cnt;
	cnt=0;
	for(int i=0;i<=6;++i) sort(ve[i].begin(),ve[i].end());
	dfs2(0,0);
	printf("%d\n",ans);
}


#include<bits/stdc++.h>
using namespace std;

constexpr long long mod1=998244353,mod2=1000000007;

long long dfn,n,nLow,nAns,pw[8];
vector<int>num[7];

void dfs1(int dig,int x)
{
	int tmp=(dfn+mod1-x)%mod1;
	num[dig].push_back(tmp);
	nLow=(nLow+tmp)%mod2;
	dfn++;
	if(dig<6)
	{
		int i;
		for(i=0;i<10;i++) dfs1(dig+1,x*10+i);
	}
}

void dfs2(int dig,long long x)
{
	if(x>n) return;
	int i;
	if(x*pw[6]+pw[6]-1<=n&&x*pw[7]>n)
	{
		for(i=0;i<=6;i++)
		{
			long long delt=(dfn+(mod1-pw[i])*x)%mod1;
			nAns=(nAns+(delt+mod2-mod1)*pw[i]+mod1*(lower_bound(num[i].begin(),num[i].end(),mod1-delt)-num[i].begin()))%mod2;
		}
		nAns=(nAns+nLow)%mod2;
		dfn+=1111111;
		return;
	}
	nAns=(nAns+(dfn+mod1-x%mod1)%mod1)%mod2;
	dfn++;
	for(i=dig?0:1;i<10;i++) dfs2(dig+1,x*10+i);
}

int main()
{
	int i;
	pw[0]=1;
	for(i=1;i<=7;i++) pw[i]=pw[i-1]*10;
	dfs1(0,0);
	for(i=1;i<=6;i++) sort(num[i].begin(),num[i].end());
	cin>>n;
	dfn=0;
	dfs2(0,0);
	cout<<nAns<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define LL long long
#define U unsigned
#define INF 0x7fffffffffffffff
#define MINF -0x8000000000000000
bool isp(LL x){
	if(x<2)return 0;
	for(LL i=2;i<=sqrt(x);i++){
		if(x%i==0) return 0;
	}
	return 1;
}
inline LL read()
{
	LL x=0,f=1;char ch=getchar();
	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
	while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
	return x*f;
}
LL gcd(LL x,LL y){
	return !y?x:gcd(y,x%y);
}
LL FPW(LL x,LL y,LL mod){
	LL res=1;
	for(;y;y>>=1){
		if(y%2)res=res*x%mod;
		x=x*x%mod;
	}
	return res;
}
using namespace std;
/*LL N,M,S,T,l,r=0x7f7f7f7f,m,h[600000],n[600000],w[600000],dt[600000],en,dis[600000];
struct node{
	LL id,dis;
	bool operator < (const node &B) const{return dis>B.dis;}
};
void dij(){
	priority_queue<node>q;
	bool vis[600000]={};
	memset(dis,0x7f7f7f7f,sizeof dis);
	dis[S]=0;
	q.push((node){S,0});
	while(q.size()){
		LL x=q.top().id;
		q.pop();
		if(vis[x])continue;
		vis[x]=1;
		for(LL j=h[x];j;j=n[j]){
			LL y=dt[j],ww=w[j];
			if(dis[y]<=dis[x]+ww)continue;
			dis[y]=dis[x]+ww;
			q.push((node){y,dis[y]});
		}
	}
    return ;
}
void add(LL x,LL y,LL z=0){
	dt[++en]=y,n[en]=h[x],w[en]=z,h[x]=en;
	return ;
}*/
#define mod1 (LL)(998244353)
#define mod2 (LL)(1e9+7)
LL N;
LL cnt;
LL firsum[7];
vector<LL>firds[7];
void dfs1(LL dep,LL now){
	if(dep>6)return ;
	firds[dep].push_back((cnt-now+mod1)%mod1);
	firsum[dep]+=(cnt-now+mod1)%mod1;
	cnt++;
	for(LL i=0;i<=9;i++){
		dfs1(dep+1,now*10+i);
	}
	return ;
}
LL cnt2=-1,ans;
void dfs2(LL dep,LL now){
	if(now>N)return ;
	if(now*1000000+999999<=N&&now*10000000>N){
		for(LL i=0;i<=6;i++){
			LL st=(cnt2+1-now*FPW(10,i,mod1)%mod1+mod1)%mod1;
			LL pos=lower_bound(firds[i].begin(),firds[i].end(),mod1-st)-firds[i].begin();
			ans+=(firsum[i]+st*firds[i].size()-mod1*(firds[i].size()-pos));
			ans%=mod2;
		}
		cnt2+=cnt;
		return ;
	}
	cnt2++;
	ans+=((cnt2-now)%mod1+mod1)%mod1;
	ans%=mod2;
	for(LL i=0;i<=9;i++){
		if(!dep&&!i)continue;
		dfs2(dep+1,now*10+i);
	}
	return ;
}
int main(){
	N=read();
	dfs1(0,0);
	for(LL i=0;i<=6;i++)sort(firds[i].begin(),firds[i].end());
	dfs2(0,0);
	cout<<ans;
    return 0;
}
//ÖÒ£¡³Ï£¡
//ÍÅ£¡½á£¡
//±Ø£¡Ê¤£¡


#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#define ll long long
#define R register
using namespace std;
const int mod1=998244353,mod2=1e9+7;
inline ll read(){
	ll a=0,b=1;
	char s=getchar();
	while(s<48||s>57){
		if(s=='-') b=-1;
		s=getchar();
	}
	while(s>=48&&s<=57)
		a=(a<<1)+(a<<3)+s-48,s=getchar();
	return a*b;
}
ll n;
ll cnt1,sum[10];
vector<int> v[10];
void dfs1(int len,int val){
	if(len>6) return;
	v[len].push_back((cnt1-val+mod1)%mod1);
	sum[len]+=(cnt1-val+mod1)%mod1;
	++cnt1;
	for(R int i=0;i<=9;i=-~i) dfs1(len+1,val*10+i);
}
ll cnt2,ans;
inline bool check(ll x){return x*1000000+999999<=n&&x*10000000>n;}
int pw[7]={1,10,100,1000,10000,100000,1000000};
void dfs2(int len,ll val){
	if(val>n) return;
	if(check(val)){
		for(R int i=0;i<=6;i=-~i){
			ll v1=((cnt2+1-val*pw[i])%mod1+mod1)%mod1;
			int num=lower_bound(v[i].begin(),v[i].end(),mod1-v1)-v[i].begin();
			ans=(ans+(sum[i]+v[i].size()*v1-1LL*mod1*(v[i].size()-num)))%mod2;
		}
		cnt2+=cnt1;
	}
	else{
		if(len) ++cnt2;
		ans=(ans+((cnt2-val)%mod1+mod1)%mod1)%mod2;
		for(R int i=(!len);i<=9;i=-~i) dfs2(len+1,val*10+i);
	}
}
int main(){
	n=read();
	dfs1(0,0);
	for(R int i=0;i<=6;i=-~i) sort(v[i].begin(),v[i].end());
	dfs2(0,0);
	printf("%lld\n",ans);
	return 0;
}


// LUOGU_RID: 95322299
#include<bits/stdc++.h>
#define reg register
#define int long long
using namespace std;
inline int read(){
	reg int k=1,x=0;char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-') k=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-48,ch=getchar();
	return k*x;
}
inline int cmin(reg int x,reg int y){return x<y?x:y;}
inline int cmax(reg int x,reg int y){return x>y?x:y;}
const int N=2e6+10,Mod=1e9+7,mod=998244353,B=1000000;
int n,idx,ans,sum[10];
vector<int> v[10];
inline int MOD(reg int x){return (x%mod+mod)%mod;}
inline void dfs1(reg int x,reg int len){
	++idx,v[len].push_back(MOD(idx-x)); (sum[len]+=v[len].back())%=Mod;
	if (len==6) return; for (reg int i=0;i<10;i++) dfs1(x*10+i,len+1);
}
inline void dfs2(reg int x){ if (x>n) return;
	if (x*B+(B-1)<=n&&x*B*10>n){ reg int now=idx;
		for (reg int i=0,mul=1;i<=6;i++,mul=mul*10){ reg int sz=v[i].size();
			reg int d=MOD(now-x*mul),pos=lower_bound(v[i].begin(),v[i].end(),mod-d)-v[i].begin();
			ans=(ans+d*sz+sum[i]-mod*(sz-pos))%Mod; idx+=sz;
		} return;
	}idx++;ans=(ans+MOD(idx-x))%Mod;
	for (reg int i=0;i<10;i++) dfs2(x*10+i);
}
signed main(){
	n=read(); dfs1(0,0); for (reg int i=0;i<=6;i++) sort(v[i].begin(),v[i].end());
	idx=0; for (reg int i=1;i<=9;i++) dfs2(i); printf("%lld",(ans+Mod)%Mod);
	return 0;
}


#include<iostream>
#include<cstring>
#include<map>
#include<assert.h>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<vector>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
using namespace std;
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}());
const ll mod=1000000007;
const ll mod2=998244353;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

VI pos[10];
int cnt;
ll pw[15],s[15];
ll cnt2,n;
int ans;
int query(int fixpre,ll val) {
	ll ans=0;
	rep(d,0,7) {
		ll offset=(val-fixpre*pw[d])%mod2;
		if (offset<0) offset+=mod2;
		int p=lower_bound(all(pos[d]),mod2-offset)-pos[d].begin();
		ans=(ans+s[d]+offset*SZ(pos[d])-mod2*(SZ(pos[d])-p))%mod;
	}
	return ans;
}

void dfs(int val,int d) {
	int x=(cnt-val+mod2)%mod2;
	pos[d].pb(x); cnt++;
	s[d]+=x;
	if (d==6) return;
	rep(i,0,10) dfs(val*10+i,d+1);
}

void dfs2(ll val) {
	if (val*1000000+999999<=n&&val*10000000>n) {
		ans=(ans+query(val,cnt2+1))%mod;
		cnt2+=cnt;
	} else {
		cnt2++;
		ans=(ans+((cnt2-val)%mod2+mod2)%mod2)%mod;
		rep(i,val?0:1,10) {
			if (val*10+i<=n) dfs2(val*10+i);
		}
	}
}

int main() {
	dfs(0,0);
	rep(i,0,7) sort(all(pos[i]));
	pw[0]=1;
	rep(i,1,13) pw[i]=pw[i-1]*10;
	scanf("%lld",&n);
	cnt2=-1;
	dfs2(0);
	printf("%d\n",ans);
}


//QwQcOrZ yyds!!!
#include<bits/stdc++.h>
#pragma GCC optimize(2, 3, "Ofast")
#include<windows.h>
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define pa pair < int,int >
#define fi first
#define se second
#define inf 1e18
#define mod 1000000007
#define mod1 998244353
#define int ll
#define N 25
using namespace std;
inline char gc(){static char buf[1000000],*p1=buf,*p2=buf;return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;}
#define gc getchar
inline ll read(){char c=gc();ll su=0,f=1;for (;c<'0'||c>'9';c=gc()) if (c=='-') f=-1;for (;c>='0'&&c<='9';c=gc()) su=su*10+c-'0';return su*f;}
inline void write(ll x){if (x<0){putchar('-');write(-x);return;}if (x>=10) write(x/10);putchar(x%10+'0');}
inline void writesp(ll x){write(x),putchar(' ');}
inline void writeln(ll x){write(x);putchar('\n');}
vector<int>G[N];
int sm[N];
int pow10[N];
int B=1000000;
int n,ans;
int cnt;
void dfs(int dp,int val)
{
	++cnt;
	int xx=(cnt-val+mod1)%mod1;xx=(xx+mod1)%mod1;
	G[dp-1].push_back(xx);
	sm[dp-1]=(sm[dp-1]+xx)%mod;
	if (dp==7)
	{
		return;
	}
	for (int i=0;i<=9;i++) dfs(dp+1,val*10+i);
}
void dfs2(int dp,int val)
{
	if (val>n) return;
	if (val*B*10>n&&(val+1)*B-1<=n)
	{
		if (dp!=1)
		{
			for (int i=0;i<=6;i++)
			{
				int x=(cnt-(pow10[i]*val)%mod1+mod1)%mod1;
//				cout<<"?"<<x<<endl;
				int y=lower_bound(G[i].begin(),G[i].end(),(mod1-x))-G[i].begin();
				ans=(ans-(G[i].size()-y)*mod1%mod+x*G[i].size()%mod+sm[i]%mod+mod)%mod;
				ans=ans+mod,ans%=mod;
//				ans=(ans+sm[i])%mod;
			}
			for (int i=0;i<=6;i++) cnt+=G[i].size();
//			cout<<"?"<<ans<<" "<<val<<endl;
//			Sleep(1000);
			return;
		}
	}
	if (dp!=1)
	{
		++cnt;
		int xx=(cnt-val+mod1)%mod1;
		xx=(xx+mod1)%mod1;
		ans=(ans+xx)%mod;
	}
	for (int i=(dp==1);i<=9;i++)
		dfs2(dp+1,val*10+i);
}
signed main()
{
	pow10[0]=1;
	for (int i=1;i<=13;i++) pow10[i]=pow10[i-1]*10%mod1;
	n=read();
	dfs(1,0);
//	return 0;
	for (int i=0;i<=6;i++) sort(G[i].begin(),G[i].end());
	cnt=0;
	dfs2(1,0);
	writeln(ans);
}
/*

*/


#include <bits/stdc++.h>
#define ll long long
#define F(i, l, r) for (int i = l; i <= r; i++)
using namespace std;
const int P = 998244353, mod = 1e9 + 7, B = 1e6;
int m(ll d) { return (d % P + P) % P; }
ll n, cnt, s[7];
int ans;
vector<int> p[7];
void dfs0(int d, ll v) {
	cnt++, p[d].push_back(m(cnt - v));
	if (d < 6) F(i, 0, 9) dfs0(d + 1, v * 10 + i);
}
int calc(int id, int f) {
	int ps = lower_bound(p[id].begin(), p[id].end(), P - f) - p[id].begin();
	return ((ll)f * p[id].size() + s[id] - (ll)P * (p[id].size() - ps)) % mod;
}
void dfs1(int d, ll v) {
	if (v > n) return;
	if (d >= 1) {
		if (v * B > n / 10 && v * B + B - 1 <= n) {
			int t = 1;
			F(i, 0, 6) (ans += calc(i, m(cnt - v * t))) %= mod, t *= 10;
			F(i, 0, 6) cnt += p[i].size();
			return;
		}
		(ans += m(++cnt - v)) %= mod;
	}
	F(i, !d, 9) dfs1(d + 1, v * 10 + i);
}
int main() {
	scanf("%lld", &n), dfs0(0, 0);
	F(i, 0, 6) {
		sort(p[i].begin(), p[i].end());
		F(j, 0, p[i].size() - 1) s[i] += p[i][j];
	}
	cnt = 0, dfs1(0, 0), printf("%d\n", ans);
	return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cctype>

#define File(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout)

using std::pair;
using std::make_pair;

#define pii pair<int, int>
#define mp make_pair

using ll = long long;
const int inf = 1e9;
const ll infll = 0ll + 1e18;

#define int long long
const int mod1 = 998244353;
const int mod2 = 1e9 + 7;
const int Base = 1000000;

int n, tot, sum[15], ans;
std::vector <int> vec[15];

inline void dfs1(int, int);
inline void dfs2(int);

signed main(void) {
  std::cin >> n;
  dfs1(0, 0);
  for (int i = 0; i <= 7; i++)
    std::sort(vec[i].begin(), vec[i].end());
  tot = 0;
  for (int i = 1; i <= 9; i++) dfs2(i);
  std::cout << ans << std::endl;
  return 0;
}

inline void dfs1(int k, int num) {
  if (k == 7) return ;
  tot ++;
  int back = ((tot - num) % mod1 + mod1) % mod1;
  vec[k].emplace_back(back);
  sum[k] = (sum[k] + back) % mod2;
  for (int i = 0; i <= 9; i ++)
    dfs1(k + 1, num * 10 + i);
}
inline void dfs2(int x) {
  if (x > n) return ;
  if (x * Base + Base - 1 <= n && x * Base * 10 > n) {
    int now = tot;
    for (int i = 0, mul = 1; i <= 6; i++, mul *= 10) {
      int sz = vec[i].size();
      int dif = ((now - x * mul) % mod1 + mod1) % mod1;
      // std::cout << dif << std::endl;
      int pos = std::lower_bound(vec[i].begin(), vec[i].end(), mod1 - dif) - vec[i].begin();
      ans = (ans + dif * sz + sum[i]) % mod2;
      ans = (ans - mod1 * (sz - pos) % mod2 + mod2) % mod2;
      tot += sz;
    }
    return ;
  }
  tot ++;
  ans = (ans + ((tot - x) % mod1 + mod1) % mod1) % mod2;
  for (int i = 0; i <= 9; i ++) dfs2(x * 10 + i);
}


#include <bits/stdc++.h>

using namespace std;

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define RepG(i,u) for(int i=head[u];~i;i=e[i].next)

const int N=1e6+5;
const int mod1=998244353;
const int mod2=1e9+7;
const int base=1000000;

typedef long long ll;
typedef double db;

# define chkmax(a,b) a=max(a,b)
# define chkmin(a,b) a=min(a,b)
# define PII pair<int,int>
# define mkp make_pair

template<typename T> void read(T &x){
    x=0;int f=1;
    char c=getchar();
    for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
    x*=f;
}

ll n;
vector<int> v[10];
ll gg;
int sum[10];
int ans;

void dfs1(int u,int x){
    v[u].push_back(((++gg)-x+mod1)%mod1),sum[u]+=v[u].back()%mod2,sum[u]%=mod2;
    if(u==6)return;
    Rep(i,0,9)dfs1(u+1,10*x+i);
}

void dfs2(ll x){
    if(x>n)return;
    if(x*base+base-1<=n&&x*base*10>n){
        ll rk=gg;
        for(int i=0,bit=1;i<=6;i++,bit*=10){
            int mae=((rk-x*bit)%mod1+mod1)%mod1;
            int pos=lower_bound(v[i].begin(),v[i].end(),-mae+mod1)-v[i].begin();
            // printf("%d\n",pos);
            ans+=((1ll*mae*v[i].size()%mod2+sum[i])%mod2-1ll*(v[i].size()-pos)*mod1%mod2+mod2)%mod2;
            ans%=mod2;
            // printf("%d\n",ans);
            gg+=v[i].size();
        }
        return;
    }
    ans+=(((++gg)-x)%mod1+mod1)%mod1,ans%=mod2;
    Rep(i,0,9)dfs2(x*10+i);
}

int main()
{
    # ifdef YuukiYumesaki
    freopen("testdata.in","r",stdin);
    freopen("test1.out","w",stdout);
    # endif
    read(n);
    dfs1(0,0);
    Rep(i,0,6)sort(v[i].begin(),v[i].end());
    gg=0;
    Rep(i,1,9)dfs2(i);
    printf("%d\n",ans);
    return 0;
}


#include <bits/stdc++.h>
#define lld long long
using namespace std;
const lld mod1 = 998244353;
const lld mod2 = 1e9 + 7;
lld ans;
lld n;
lld cnt1;
vector < lld > val[7];
lld sum[7];
void dfs1 (lld k1, lld k2) {
	if (k1 == 7) return;
	val[k1].push_back((cnt1 - k2 + mod1) % mod1);
	sum[k1] += (cnt1 - k2 + mod1) % mod1;
	++ cnt1;
	for (lld i = 0; i <= 9; ++ i)
		dfs1 (k1 + 1, k2 * 10 + i);
}
inline bool check(lld x) { return x * 1000000 + 999999 <= n && x * 10000000 > n; }
lld cnt2;
lld poww[7] = { 1, 10, 100, 1000, 10000, 100000, 1000000 };
void dfs2(lld k1, lld k2) {
	if (k2 > n) return;
	if (check(k2)) {
		for (lld i = 0; i <= 6; ++ i) {
			lld offset = ((cnt2 + 1 - (k2 * poww[i])) % mod1 + mod1) % mod1;
			lld pos = lower_bound(val[i].begin(), val[i].end(), mod1 - offset) - val[i].begin();
			ans = (ans + (sum[i] + offset * val[i].size() - mod1 * (val[i].size() - pos))) % mod2;
		}
		cnt2 += cnt1;
	} else {
		++ cnt2;
		ans = (ans + ((cnt2 - k2) % mod1 + mod1) % mod1) % mod2;
		for (lld i = (!k1); i <= 9; ++ i)
			dfs2(k1 + 1, k2 * 10 + i);
	}
}
int main() {
	scanf("%lld", & n);
	dfs1 (0, 0);
	for (lld i = 0; i <= 6; ++ i) sort(val[i].begin(), val[i].end());
	cnt2 = -1;
	dfs2 (0, 0);
	printf("%lld\n", ans);
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdlib>
using namespace std;
typedef long long ll;
#define fr(i,l,r) for(int i = (l);i <= (r);++i)
#define rf(i,l,r) for(int i = (l);i >= (r);--i)
#define fo(i,l,r) for(int i = (l);i < (r);++i)
#define foredge(i,u,v) for(int i = fir[u],v;v = to[i],i;i = nxt[i])
#define filein(File) freopen(File".in","r",stdin)
#define fileout(File) freopen(File".out","w",stdout)
const int MOD1 = 1e9 + 7,MOD2 = 998244353;
ll n,c1,c2,ans,pw[20],sum[10];
vector<ll> buc[10];
void query(ll p,ll s) {	fr(i,0,6) {	ll x = ((s - p * pw[i]) % MOD2 + MOD2) % MOD2;	(ans += x * buc[i].size() + sum[i]) %= MOD1;
		(ans -= 1ll * (buc[i].end() - lower_bound(buc[i].begin(),buc[i].end(),MOD2-x)) * MOD2) %= MOD1;	}}
void dfs(ll x,int d) {ll tmp = ((c1++ - x) % MOD2 + MOD2) % MOD2;(sum[d] += tmp) %= MOD1;buc[d].push_back(tmp);if(d == 6) return;fr(i,0,9) dfs(x * 10 + i,d+1);}
void dfs2(ll x) {if(x > n) return;if((x + 1) * ll(1e6) <= n+1 && x * ll(1e7) > n)query(x,c2),c2 += c1;
	else {(ans += ((c2++ - x) % MOD2 + MOD2) % MOD2) %= MOD1;fr(i,x ? 0 : 1,9) dfs2(x * 10 + i);}}
int main() {cin >> n;dfs(0,0);fr(i,1,6) sort(buc[i].begin(),buc[i].end());pw[0] = 1; fr(i,1,12) pw[i] = pw[i-1] * 10;dfs2(0);
	cout << (ans + MOD1) % MOD1 << endl;return 0;}


#include<bits/stdc++.h>
using namespace std;

namespace IO {
	template<typename T>
	inline int Read(T &n) {
		T k=0, f=1; char c=getchar();
		while (c<'0' || c>'9') { if (c == '-') f=-1; c=getchar(); }
		while (c>='0' && c<='9') { k=(k<<3)+(k<<1)+(c-'0'); c=getchar(); }
		n = k*f; return 0;
	}
	template<typename T>
	inline void Write(T x) {
		if (x < 0) { putchar('-'); x=-x; }
		if (x > 9) Write(x/10);
		putchar(x%10+'0');
	}
	template<typename T, typename ...Y>
	inline int Read(T &x, Y&... y) { return Read(x) | Read(y...); }
}

#define LL long long
#define FOR(i, a, b) for(LL i=(a); i<=(b); i++)
#define ROF(i, a, b) for(LL i=(a); i>=(b); i--)
const LL Mod1 = 998244353, Mod2 = 1e9+7;
LL ans, n, Cnt1, sum[7];
vector<LL> val[7];
inline void DFS1(LL A, LL B) {
	if (A == 7) return;
	val[A].push_back((Cnt1-B + Mod1) % Mod1);
	sum[A] += (Cnt1-B + Mod1) % Mod1; Cnt1++;
	FOR (i, 0, 9) DFS1(A+1, B*10+i);
}
inline bool check(LL x) {
	const LL Cut = 1e6;
	return x*Cut + 999999 <= n && x*Cut*10 > n;
}
LL Cnt2, Tpow[7] = {1, 10, 100, 1000, 10000, 100000, 1000000};
inline void DFS2(LL A, LL B) {
	if (B > n) return;
	if (check(B)) {
		FOR (i, 0, 6) {
			LL cur = ( (Cnt2 + 1 - (B*Tpow[i])) % Mod1 + Mod1) % Mod1;
			LL pos = lower_bound(val[i].begin(), val[i].end(), Mod1 - cur) - val[i].begin();
			(ans += sum[i] + cur*val[i].size() - Mod1*(val[i].size()-pos)) %= Mod2;
		}
		Cnt2 += Cnt1;
	} else {
		Cnt2++; (ans += ((Cnt2-B)%Mod1 + Mod1) % Mod1) %= Mod2;
		FOR (i, !A, 9) DFS2(A+1, B*10+i);
	}
}
signed main() {
	IO::Read(n); DFS1(0, 0);
	FOR (i, 0, 6) sort(val[i].begin(), val[i].end());
	Cnt2 = -1, DFS2(0, 0); IO::Write(ans);
}


#include<bits/stdc++.h>
namespace imzzy{
	#define fi first
	#define se second
	#define endl '\n'
	#define rgi register int
	using std::cerr;
	typedef unsigned int uint;
	typedef long long ll;
	typedef unsigned long long ull;
	typedef std::pair<int,int> pii;
	class fastin{public:int _c,_f;
	inline fastin&operator>>(char&_x){return _x=getchar(),*this;}
	template<typename _T>inline fastin&operator>>(_T&_x){_x=0;
	while(!isdigit(_c))_f|=(_c=='-'),_c=getchar();
	while(isdigit(_c))_x=_x*10+(_c^'0'),_c=getchar();
	if(_f)_x=-_x,_f=0;return *this;}fastin(){_c=_f=0;}
	}fin;
	class fastout{public:template<typename _T>inline void write(_T _x){
	if(_x<0)putchar('-'),_x=-_x;if(_x>9)write(_x/10);putchar(_x%10+'0');}
	inline fastout&operator<<(char _c){return putchar(_c),*this;}
	template<typename _T>inline fastout&operator<<(_T _x){return write(_x),*this;}
	}fout;
}using namespace imzzy;
// ----------------------------
// #define int ll
// using namespace std;
const ll mod1=998244353,mod2=1e9+7,inf=2e9+7;
const int maxn=1000004,maxm=204;

inline int down(ll x) {return (x%mod1+mod1)%mod1;}

ll n,ans;
std::vector<ll> val[7];
ll sum[7],cnt1,cnt2;
void dfs1(int dep,int num) {
	val[dep].push_back(down(cnt1-num)),++cnt1;
	if(dep==6) return;
	for(rgi i=0;i<10;++i) dfs1(dep+1,num*10+i);
}
const int base=1000000;
void dfs2(int dep,ll num) {
	if(num>n) return;
	if(num*base+999999<=n&&num*base*10>n) {
		for(rgi i=0,l=1,p;i<7;++i,l*=10) {
			ll tmp=down(cnt2-num*l+1);
			p=std::lower_bound(val[i].begin(),val[i].end(),mod1-tmp)-val[i].begin();
			(ans+=tmp*val[i].size()+sum[i]-mod1*(val[i].size()-p))%=mod2;
		}
		cnt2+=cnt1;
	}
	else {
		++cnt2,(ans+=down(cnt2-num))%=mod2;
		for(rgi i=!dep;i<10;++i) dfs2(dep+1,num*10+i);
	}
}
signed main() {
	// freopen("tt.in","r",stdin);
	// freopen("tt.out","w",stdout);
	fin>>n;
	dfs1(0,0);
// cerr<<"OK"<<endl;
	for(rgi i=0;i<7;++i) {
		std::sort(val[i].begin(),val[i].end());
		for(ll x:val[i]) sum[i]+=x;
	}
// cerr<<cnt1<<endl;
	cnt2=-1,dfs2(0,0);
	fout<<ans;
	return 0;
}
// ----------------------------
// by imzzy