#include <bits/stdc++.h>   using namespace std;   int main() {     do {       ios::sync_with_stdio(false);       cin.tie(nullptr);       cout.tie(nullptr);     } while (false);     string L, R;     cin >> L >> R;     reverse(L.begin(), L.end());     L.resize(R.size(),  0 );     reverse(L.begin(), L.end());     int n, m = 0;     cin >> n;     const int sigma = 10, M = 3 * R.size() * sigma + 100;     vector<vector<int> > son(M, vector<int>(sigma)),         sum(M, vector<int>(R.size()));     function<void(int, int, bool, bool, bool)> gen = [&](int idx, int u, bool big,                                                          bool small, bool start) {       if (idx >= R.size() || (big && small)) {         sum[u][R.size() - idx]++;       } else {         for (int i = (big ? 0 : L[idx] -  0 ); i <= (small ? 9 : R[idx] -  0 );              i++) {           int v = u;           if (start || i) {             if (!son[u][i]) {               son[u][i] = m++;             }             v = son[u][i];           }           gen(idx + 1, v, big || L[idx] -  0  < i, small || R[idx] -  0  > i,               start || i);         }       }     };     gen(0, m++, false, false, false);     vector<int> fail(m);     auto build = [&]() {       queue<int> que;       que.push(0);       while (!que.empty()) {         int u = que.front();         que.pop();         for (int i = 0; i < sigma; i++) {           if (!son[u][i]) {             son[u][i] = son[fail[u]][i];           } else {             int v = fail[u];             while (v && !son[v][i]) {               v = fail[v];             }             if (son[v][i] && son[v][i] != son[u][i]) {               fail[son[u][i]] = son[v][i];               for (int j = 0; j < R.size(); j++) {                 sum[son[u][i]][j] += sum[son[v][i]][j];               }             }             que.push(son[u][i]);           }         }       }     };     build();     vector<vector<int> > trans(m, vector<int>(sigma));     for (int u = 0; u < m; u++) {       for (int i = 1; i < R.size(); i++) {         sum[u][i] += sum[u][i - 1];       }       for (int i = 0; i < sigma; i++) {         int v = u;         while (v && !son[v][i]) {           v = fail[v];         }         trans[u][i] = son[v][i];       }     }     vector<vector<int> > dp(n + 1, vector<int>(m, -1e9));     dp[0][0] = 0;     for (int i = 0; i < n; i++) {       for (int u = 0; u < m; u++) {         if (dp[i][u] >= 0) {           for (int j = 0; j < sigma; j++) {             int v = trans[u][j];             dp[i + 1][v] = max(dp[i + 1][v],                                dp[i][u] + sum[v][min((int)R.size(), n - i) - 1]);           }         }       }     }     int goal = *max_element(dp[n].begin(), dp[n].end());     cout << goal << endl;     vector<vector<bool> > on(n + 1, vector<bool>(m));     for (int i = 0; i < m; i++) {       on[n][i] = dp[n][i] == goal;     }     for (int i = n - 1; i >= 0; i--) {       for (int u = 0; u < m; u++) {         if (dp[i][u] >= 0) {           bool ok = false;           for (int j = 0; j < sigma; j++) {             int v = trans[u][j];             ok |=                 on[i + 1][v] &&                 dp[i][u] + sum[v][min((int)R.size(), n - i) - 1] == dp[i + 1][v];           }           on[i][u] = ok;         }       }     }     int u = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < sigma; j++) {         int v = trans[u][j];         if (on[i + 1][v] &&             dp[i][u] + sum[v][min((int)R.size(), n - i) - 1] == dp[i + 1][v]) {           cout << j;           u = v;           break;         }       }     }     cout << endl;     return 0;   }