import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class _GlobalRound1H {

	static int wordLength;
	static PrintWriter out=new PrintWriter(System.out);

	public static void main(String[] args) {
		FastScanner fs=new FastScanner();
		char[] lLine=fs.next().toCharArray(), rLine=fs.next().toCharArray();
		wordLength=fs.nextInt();
		int lLen=lLine.length, rLen=rLine.length;
		int[] L=new int[lLen], R=new int[rLen];
		for (int i=0; i<lLen; i++) L[i]=lLine[i]-'0';
		for (int i=0; i<rLen; i++) R[i]=rLine[i]-'0';

		ArrayList<Word> words=new ArrayList<>();
		if (lLen==rLen) {
			//then there is some LCP which need to be in everything
			ArrayList<Integer> lcpList=new ArrayList<>();
			for (int i=0; lcpList.size()<lLen && L[i]==R[i]; i++)
				lcpList.add(L[i]);
			if (lcpList.size()==lLen) {
				words.add(new Word(lcpList));
			}
			else {
				//after the LCP there is one digit bounded by both
				for (int toPlace=L[lcpList.size()]+1; toPlace<R[lcpList.size()]; toPlace++) {
					int suffLen=lLen-1-lcpList.size();
					words.add(new Word(lcpList, toPlace, suffLen));
				}

				//after that one digit, each is only bounded by one
				ArrayList<Integer> leftPref=(ArrayList<Integer>) lcpList.clone(), rightPref=lcpList;
				leftPref.add(L[lcpList.size()]);
				rightPref.add(R[lcpList.size()]);
				for (int i=lcpList.size(); i<lLen; i++) {
					int suffLen=lLen-1-i;
					for (int toPlace=L[i]+1; toPlace<=9; toPlace++)
						words.add(new Word(leftPref, toPlace, suffLen));
					leftPref.add(L[i]);
				}
				words.add(new Word(leftPref));
				for (int i=lcpList.size(); i<rLen; i++) {
					int suffLen=rLen-1-i;
					for (int toPlace=R[i]-1; toPlace>0; toPlace--)
						words.add(new Word(rightPref, toPlace, suffLen));
					rightPref.add(R[i]);
				}
				words.add(new Word(rightPref));
			}
		}
		else {
			ArrayList<Integer> pref=new ArrayList<>();
			for (int i=0; i<lLen; i++) {
				int suffLen=lLen-1-i;
				for (int toPlace=L[i]+1; toPlace<=9; toPlace++)
					words.add(new Word(pref, toPlace, suffLen));
				pref.add(L[i]);
			}
			words.add(new Word(L));
			pref.clear();
			for (int i=0; i<rLen; i++) {
				int suffLen=rLen-1-i;
				for (int toPlace=R[i]-1; toPlace>0; toPlace--)
					words.add(new Word(pref, toPlace, suffLen));
				pref.add(R[i]);
			}
			words.add(new Word(R));
			for (int length=lLen+1; length<rLen; length++) {
				ArrayList<Integer> empty=new ArrayList<>();
				for (int toPlace=1; toPlace<=9; toPlace++)
					words.add(new Word(empty, toPlace, length-1));
			}

		}

		AhoNode aho=new AhoNode();
		for (Word w:words) aho.addWord(w, 0);

		AhoNode.buildAho(aho);
		int answer=aho.go(0);

		out.println(answer);
		aho.buildback(0);
		out.println();
		out.close();
	}

	static class Word {
		int[] req;
		int suffLen;

		public Word(int[] req) {
			this.suffLen=0;
			this.req=req.clone();
		}

		public Word(ArrayList<Integer> reqList) {
			this.suffLen=0;
			req=new int[reqList.size()];
			for (int i=0; i<req.length; i++)
				req[i]=reqList.get(i);
		}

		public Word(ArrayList<Integer> pref, int nextLetter, int suffLen) {
			this.suffLen=suffLen;
			req=new int[pref.size()+1];
			for (int i=0; i+1<req.length; i++) req[i]=pref.get(i);
			req[pref.size()]=nextLetter;
		}

		public String toString() {
			return Arrays.toString(req)+" * "+suffLen;
		}
	}

	static class AhoNode {
		AhoNode[] transition=new AhoNode[10];
		AhoNode[] children=new AhoNode[10];
		AhoNode suffixLink=null;

		int[] tailLengths=new int[801];
		int[] csTailLengths=new int[802];

		int[] dp=new int[2002];

		public AhoNode() {
			Arrays.fill(dp, -1);
		}

		public void addWord(Word w, int index) {
			if (index==w.req.length) {
				tailLengths[w.suffLen]++;
				return;
			}

			if (children[w.req[index]]==null) children[w.req[index]]=new AhoNode();
			children[w.req[index]].addWord(w, index+1);
		}

		static void buildAho(AhoNode root) {
			ArrayDeque<AhoNode> bfs=new ArrayDeque<>();
			bfs.add(root);
			root.suffixLink=root;
			Arrays.fill(root.transition, root);
			while (!bfs.isEmpty()) {
				AhoNode node=bfs.remove(), suffLink=node.suffixLink;
				//TODO: update tailLengths
				if (node!=root) {
					for (int i=0; i<node.tailLengths.length; i++)
						node.tailLengths[i]+=suffLink.tailLengths[i];
				}
				for (int i=1; i<node.csTailLengths.length; i++)
					node.csTailLengths[i]=node.csTailLengths[i-1]+node.tailLengths[i-1];

				for (int kid=0; kid<10; kid++) {
					if (node.children[kid]!=null) {
						node.transition[kid]=node.children[kid];
						bfs.add(node.children[kid]);
						node.children[kid].suffixLink=(node==root?node:suffLink.transition[kid]);
					}
					else {
						node.transition[kid]=suffLink.transition[kid];
					}
				}
			}
		}

		int go(int curLength) {
			if (dp[curLength]!=-1) return dp[curLength];
			if (curLength==wordLength) return dp[curLength]=tailLengths[0];
			//otherwise brute force what to place

			int spaceLeft=Math.min(wordLength-curLength, 800);
			int getFree=csTailLengths[spaceLeft+1];
			int best=getFree;
			for (int toPlace=0; toPlace<10; toPlace++) {
				best=Math.max(best, getFree+transition[toPlace].go(curLength+1));
			}
			return dp[curLength]=best;
		}

		void buildback(int curLength) {
			if (curLength==wordLength) return;
			//otherwise brute force what to place

			int spaceLeft=Math.min(wordLength-curLength, 800);
			int getFree=csTailLengths[spaceLeft+1];
			for (int toPlace=0; toPlace<10; toPlace++) {
				if (getFree+transition[toPlace].go(curLength+1) == go(curLength)) {
					out.print(toPlace);
					transition[toPlace].buildback(curLength+1);
					return;
				}
			}
		}
	}

	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");

		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) {
				a[i]=nextInt();
			}
			return a;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

	}

}

//package globalround1;
import java.util.*;

public class ProblemH {
    public static void main(String[] args) {
        new ProblemH().solve();
    }

    Scanner in = new Scanner(System.in);
    int N = 810, M=21000, n, nl, nr, rt, tot, fr, rr;
    char[] l = new char[N];
    char[] r = new char[N];
    int[] q = new int[M];
    int[] fail = new int[M];
    int[][] wild = new int[M][N];
    int[][] go = new int[M][10];
    int[][] dp = new int[2100][M];

    void solve(){
        String tl = in.next();
        String tr = in.next();
        n = in.nextInt();
        nl = tl.length();
        nr = tr.length();
        for(int i = 0 ; i < nl ; i++){
            l[i] = tl.charAt(i);
        }
        for(int i = 0 ; i < nr ; i++){
            r[i] = tr.charAt(i);
        }
        rt = ++tot;
        insert(l);
        insert(r);
        if(nl == nr){
            int k1 = rt, k2 = rt;
            for(int i = 0 ; i < nl ; i++){
                if(k1 == k2 && l[i] != r[i]){
                    for(int c = l[i]+1 ; c < r[i] ; c++){
                        if(go[k1][c-'0'] == 0){
                            go[k1][c-'0'] = ++tot;
                        }
                        wild[go[k1][c-'0']][nl-i-1]++;
                    }
                }
                else if(k1 != k2){
                    for(int c = l[i]+1 ; c < '0'+10 ; c++){
                        if(go[k1][c-'0'] == 0){
                            go[k1][c-'0'] = ++tot;
                        }
                        wild[go[k1][c-'0']][nl-i-1]++;
                    }
                    for(int c = '0'+ (i == 0 ? 1 : 0) ; c < r[i] ; c++){
                        if(go[k2][c-'0'] == 0){
                            go[k2][c-'0'] = ++tot;
                        }
                        wild[go[k2][c-'0']][nl-i-1]++;
                    }
                }
                k1 = go[k1][l[i]-'0'];
                k2 = go[k2][r[i]-'0'];
            }
            wild[k1][0]++;
            if(k1 != k2){
                wild[k2][0]++;
            }
        }
        else{
            int k1 = rt,k2 = rt;
            for(int i = 0 ; i < nl ; i++){
                for(int c = l[i]+1 ; c < '0'+10 ; c++){
                    if(go[k1][c-'0'] == 0){
                        go[k1][c-'0'] = ++tot;
                    }
                    wild[go[k1][c-'0']][nl-i-1]++;
                }
                k1 = go[k1][l[i]-'0'];
            }
            for(int i = 0 ; i < nr ; i++){
                for(int c = '0'+ (i == 0 ? 1 : 0) ; c < r[i] ; c++){
                    if(go[k2][c-'0'] == 0){
                        go[k2][c-'0'] = ++tot;
                    }
                    wild[go[k2][c-'0']][nr-i-1]++;
                }
                k2 = go[k2][r[i]-'0'];
            }
            wild[k1][0]++;
            wild[k2][0]++;
            for(int i = 1 ; i < 10 ; i++){
                if(go[rt][i] == 0){
                    go[rt][i] = ++tot;
                }
                for(int j = nl+1 ; j < nr ; j++){
                    wild[go[rt][i]][j-1]++;
                }
            }
        }
        build();
        for(int i = 1 ; i < rr ; i++){
            int x = q[i];
            for(int j = 0 ; j < nr ; j++){
                wild[x][j] += wild[fail[x]][j];
            }
        }
        for(int i = 1 ; i <= tot ; i++){
            for(int j = 1 ; j < nr ; j++){
                wild[i][j] += wild[i][j-1];
            }
        }
        DP();
        in.close();
    }

    void insert(char s[]){
        int cur = rt;
        for(int i = 0 ; s[i] != 0  ; i++){
            if(go[cur][s[i]-'0'] == 0){
                go[cur][s[i]-'0'] = ++tot;
            }
            cur = go[cur][s[i]-'0'];
        }
    }

    void build(){
        fr = rr = 0;
        q[rr++] = rt;
        for(; fr < rr ; fr++){
            int x = q[fr];
            for(int i = 0 ; i < 10 ; i++){
                if(go[x][i] != 0){
                    if(x == rt){
                        fail[go[x][i]] = x;
                    }
                    else{
                        fail[go[x][i]] = fail[x];
                        while(fail[go[x][i]] != rt && go[fail[go[x][i]]][i] == 0){
                            fail[go[x][i]] = fail[fail[go[x][i]]];
                        }
                        if(go[fail[go[x][i]]][i] != 0){
                            fail[go[x][i]] = go[fail[go[x][i]]][i];
                        }
                    }
                    q[rr++] = go[x][i];
                }
            }
        }
        for(int i = 0 ; i < 10 ; i++){
            if(go[rt][i] == 0){
                go[rt][i] = rt;
            }
        }
        for(int j = 1 ; j < rr ; j++){
            int x = q[j];
            for(int i = 0 ; i < 10 ; i++){
                if(go[x][i] == 0){
                    go[x][i] = go[fail[x]][i];
                }
            }
        }
    }

    void DP(){
        for(int i = 1 ; i <= tot ; i++){
            dp[0][i] = wild[i][0];
        }
        for(int i = 1 ; i <= n ; i++){
            for(int j = 1 ; j <= tot ; j++){
                for(int k = 0 ; k < 10 ; k++){
                    dp[i][j] = Math.max(dp[i][j], dp[i-1][go[j][k]]);
                }
                dp[i][j] += wild[j][Math.min(i, nr-1)];
            }
        }
        System.out.println(dp[n][rt]);
        int cur = rt;
        for(int i = n ; i >= 1 ; i--){
            int val = dp[i][cur]-wild[cur][Math.min(i, nr-1)];
            for(int next = 0 ; next < 10 ; next++){
                if(dp[i-1][go[cur][next]]==val){
                    System.out.print(next);
                    cur = go[cur][next];
                    break;
                }
            }
        }
    }
}

//package subestaçõesmodestas;

/**
 *
 * @author Eduardo M
 */
import java.util.Scanner;

public class SubestacoesModestas {
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
    public static void main(String[] args) {
        new SubestacoesModestas().solucao();
    }

    Scanner sc = new Scanner(System.in);
    int l, y, n, cont, tt, aux, cont1,i,j,k;
    char[] vet = new char[810];
    char[] vet1 = new char[810];
    int[] vet2 = new int[21000];
    int[] vet3 = new int[21000];
    int[][] mat = new int[21000][810];
    int[][] mat1 = new int[21000][10];
    int[][] met2 = new int[2100][21000];

    void solucao(){
        String ent= sc.next();
        String ent1 = sc.next();
        l= sc.nextInt();
        y = ent.length();
        n = ent1.length();
        for( i = 0 ; i < y ; i++){
            vet[i] = ent.charAt(i);
        }
        for( i = 0 ; i < n ; i++){
            vet1[i] = ent1.charAt(i);
        }
        cont = ++tt;
        add(vet);
        add(vet1);
        if(y == n){
            int veri = cont, veri1 = cont;
            for( i = 0 ; i < y ; i++){
                if(veri == veri1 && vet[i] != vet1[i]){
                    for(int c = vet[i]+1 ; c < vet1[i] ; c++){
                        if(mat1[veri][c-'0'] == 0){
                            mat1[veri][c-'0'] = ++tt;
                        }
                        mat[mat1[veri][c-'0']][y-i-1]++;
                    }
                }
                else if(veri != veri1){
                    for(int temp = vet[i]+1 ; temp < '0'+10 ; temp++){
                        if(mat1[veri][temp-'0'] == 0){
                            mat1[veri][temp-'0'] = ++tt;
                        }
                        mat[mat1[veri][temp-'0']][y-i-1]++;
                    }
                    for(int temp = '0'+ (i == 0 ? 1 : 0) ; temp < vet1[i] ; temp++){
                        if(mat1[veri1][temp-'0'] == 0){
                            mat1[veri1][temp-'0'] = ++tt;
                        }
                        mat[mat1[veri1][temp-'0']][y-i-1]++;
                    }
                }
                veri = mat1[veri][vet[i]-'0'];
                veri1 = mat1[veri1][vet1[i]-'0'];
            }
            mat[veri][0]++;
            if(veri != veri1){
                mat[veri1][0]++;
            }
        }
        else{
            int veri = cont,veri1 = cont;
            for(i = 0 ; i < y ; i++){
                for(int temp = vet[i]+1 ; temp < '0'+10 ; temp++){
                    if(mat1[veri][temp-'0'] == 0){
                        mat1[veri][temp-'0'] = ++tt;
                    }
                    mat[mat1[veri][temp-'0']][y-i-1]++;
                }
                veri = mat1[veri][vet[i]-'0'];
            }
            for(i = 0 ; i < n ; i++){
                for(int temp = '0'+ (i == 0 ? 1 : 0) ; temp < vet1[i] ; temp++){
                    if(mat1[veri1][temp-'0'] == 0){
                        mat1[veri1][temp-'0'] = ++tt;
                    }
                    mat[mat1[veri1][temp-'0']][n-i-1]++;
                }
                veri1 = mat1[veri1][vet1[i]-'0'];
            }
            mat[veri][0]++;
            mat[veri1][0]++;
            for( i = 1 ; i < 10 ; i++){
                if(mat1[cont][i] == 0){
                    mat1[cont][i] = ++tt;
                }
                for( j = y+1 ; j < n ; j++){
                    mat[mat1[cont][i]][j-1]++;
                }
            }
        }
        resolver();
        for( i = 1 ; i < cont1 ; i++){
             int x = vet2[i];
            for( j = 0 ; j < n ; j++){
                mat[x][j] += mat[vet3[x]][j];
            }
        }
        for( i = 1 ; i <= tt ; i++){
            for( j = 1 ; j < n ; j++){
                mat[i][j] += mat[i][j-1];
            }
        }
        Resultado();
        sc.close();
    }

    void add(char g[]){
        int tempAdd = cont;
        for( i = 0 ; g[i] != 0  ; i++){
            if(mat1[tempAdd][g[i]-'0'] == 0){
                mat1[tempAdd][g[i]-'0'] = ++tt;
            }
            tempAdd = mat1[tempAdd][g[i]-'0'];
        }
    }

    void resolver(){
        aux = cont1 = 0;
        vet2[cont1++] = cont;
        for(; aux < cont1 ; aux++){
            int x = vet2[aux];
            for( i = 0 ; i < 10 ; i++){
                if(mat1[x][i] != 0){
                    if(x == cont){
                        vet3[mat1[x][i]] = x;
                    }
                    else{
                        vet3[mat1[x][i]] = vet3[x];
                        while(vet3[mat1[x][i]] != cont && mat1[vet3[mat1[x][i]]][i] == 0){
                            vet3[mat1[x][i]] = vet3[vet3[mat1[x][i]]];
                        }
                        if(mat1[vet3[mat1[x][i]]][i] != 0){
                            vet3[mat1[x][i]] = mat1[vet3[mat1[x][i]]][i];
                        }
                    }
                    vet2[cont1++] = mat1[x][i];
                }
            }
        }
        for( i = 0 ; i < 10 ; i++){
            if(mat1[cont][i] == 0){
                mat1[cont][i] = cont;
            }
        }
        for( j = 1 ; j < cont1 ; j++){
            int  x = vet2[j];
            for( i = 0 ; i < 10 ; i++){
                if(mat1[x][i] == 0){
                    mat1[x][i] = mat1[vet3[x]][i];
                }
            }
        }
    }

    void Resultado(){
        for(i = 1 ; i <= tt ; i++){
            met2[0][i] = mat[i][0];
        }
        for( i = 1 ; i <= l; i++){
            for( j = 1 ; j <= tt ; j++){
                for( k = 0 ; k < 10 ; k++){
                    met2[i][j] = Math.max(met2[i][j], met2[i-1][mat1[j][k]]);
                }
                met2[i][j] += mat[j][Math.min(i, n-1)];
            }
        }
        System.out.println(met2[l][cont]);
        int TempResu = cont;
        for( i = l; i >= 1 ; i--){
            int val = met2[i][TempResu]-mat[TempResu][Math.min(i, n-1)];
            for(int lext = 0 ; lext < 10 ; lext++){
                if(met2[i-1][mat1[TempResu][lext]]==val){
                    System.out.print(lext);
                    TempResu = mat1[TempResu][lext];
                    break;
                }
            }
        }
    }
}

import java.util.Scanner;
/**
 *
 * @author Eduardo M
 */
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l, y, n, cont = 0, tt = 0, aux, cont1, i, j, k, tempAdd = 1;
        char[] vet = new char[810];
        char[] vet1 = new char[810];
        int[] vet2 = new int[21000];
        int[] vet3 = new int[21000];
        int[][] mat = new int[21000][810];
        int[][] mat1 = new int[21000][10];
        int[][] met2 = new int[2100][21000];
        String ent = sc.next();
        String ent1 = sc.next();
        l = sc.nextInt();
        y = ent.length();
        n = ent1.length();
        for (i = 0; i < y; i++) {
            vet[i] = ent.charAt(i);
        }
        for (i = 0; i < n; i++) {
            vet1[i] = ent1.charAt(i);
        }

        cont = ++tt;
        tempAdd = 1;
        i = 0;
        //O 48 e o Valor da string = 0
        while (vet[i] != 0) {
            if (mat1[tempAdd][vet[i] - 48] == 0) {
                mat1[tempAdd][vet[i] - 48] = ++tt;
            }
            tempAdd = mat1[tempAdd][vet[i] - 48];
            i++;
        }
        tempAdd = 1;
        i = 0;
        while (vet1[i] != 0) {
            if (mat1[tempAdd][vet1[i] - 48] == 0) {
                mat1[tempAdd][vet1[i] - 48] = ++tt;
            }
            tempAdd = mat1[tempAdd][vet1[i] - 48];
            i++;
        }
        if (y == n) {
            int veri = cont, veri1 = cont;
            for (i = 0; i < y; i++) {
                if (veri == veri1 && vet[i] != vet1[i]) {
                    for (int c = vet[i] + 1; c < vet1[i]; c++) {
                        if (mat1[veri][c - 48] == 0) {
                            mat1[veri][c - 48] = ++tt;
                        }
                        mat[mat1[veri][c - 48]][y - i - 1]++;
                    }
                } else if (veri != veri1) {
                    for (int temp = vet[i] + 1; temp < 48 + 10; temp++) {
                        if (mat1[veri][temp - 48] == 0) {
                            mat1[veri][temp - 48] = ++tt;
                        }
                        mat[mat1[veri][temp - 48]][y - i - 1]++;
                    }
                    for (int temp = '0' + (i == 0 ? 1 : 0); temp < vet1[i]; temp++) {
                        if (mat1[veri1][temp - 48] == 0) {
                            mat1[veri1][temp - 48] = ++tt;
                        }
                        mat[mat1[veri1][temp - 48]][y - i - 1]++;
                    }
                }
                veri = mat1[veri][vet[i] - 48];
                veri1 = mat1[veri1][vet1[i] - 48];
            }
            mat[veri][0]++;
            if (veri != veri1) {
                mat[veri1][0]++;
            }
        } else {
            int veri = cont, veri1 = cont;
            for (i = 0; i < y; i++) {
                for (int temp = vet[i] + 1; temp < 48 + 10; temp++) {
                    if (mat1[veri][temp - 48] == 0) {
                        mat1[veri][temp - 48] = ++tt;
                    }
                    mat[mat1[veri][temp - 48]][y - i - 1]++;
                }
                veri = mat1[veri][vet[i] - 48];
            }
            for (i = 0; i < n; i++) {
                for (int temp = 48 + (i == 0 ? 1 : 0); temp < vet1[i]; temp++) {
                    if (mat1[veri1][temp - 48] == 0) {
                        mat1[veri1][temp - 48] = ++tt;
                    }
                    mat[mat1[veri1][temp - 48]][n - i - 1]++;
                }
                veri1 = mat1[veri1][vet1[i] - 48];
            }
            mat[veri][0]++;
            mat[veri1][0]++;
            for (i = 1; i < 10; i++) {
                if (mat1[cont][i] == 0) {
                    mat1[cont][i] = ++tt;
                }
                for (j = y + 1; j < n; j++) {
                    mat[mat1[cont][i]][j - 1]++;
                }
            }
        }
        aux = cont1 = 0;
        vet2[cont1++] = cont;
        for (; aux < cont1; aux++) {
            int x = vet2[aux];
            for (i = 0; i < 10; i++) {
                if (mat1[x][i] != 0) {
                    if (x == cont) {
                        vet3[mat1[x][i]] = x;
                    } else {
                        vet3[mat1[x][i]] = vet3[x];
                        while (vet3[mat1[x][i]] != cont && mat1[vet3[mat1[x][i]]][i] == 0) {
                            vet3[mat1[x][i]] = vet3[vet3[mat1[x][i]]];
                        }
                        if (mat1[vet3[mat1[x][i]]][i] != 0) {
                            vet3[mat1[x][i]] = mat1[vet3[mat1[x][i]]][i];
                        }
                    }
                    vet2[cont1++] = mat1[x][i];
                }
            }
        }
        for (i = 0; i < 10; i++) {
            if (mat1[cont][i] == 0) {
                mat1[cont][i] = cont;
            }
        }
        for (j = 1; j < cont1; j++) {
            int x = vet2[j];
            for (i = 0; i < 10; i++) {
                if (mat1[x][i] == 0) {
                    mat1[x][i] = mat1[vet3[x]][i];
                }
            }
        }

        for (i = 1; i < cont1; i++) {
            int x = vet2[i];
            for (j = 0; j < n; j++) {
                mat[x][j] += mat[vet3[x]][j];
            }
        }
        for (i = 1; i <= tt; i++) {
            for (j = 1; j < n; j++) {
                mat[i][j] += mat[i][j - 1];
            }
        }
        for (i = 1; i <= tt; i++) {
            met2[0][i] = mat[i][0];
        }
        for (i = 1; i <= l; i++) {
            for (j = 1; j <= tt; j++) {
                for (k = 0; k < 10; k++) {
                    met2[i][j] = Math.max(met2[i][j], met2[i - 1][mat1[j][k]]);
                }
                met2[i][j] += mat[j][Math.min(i, n - 1)];
            }
        }
        System.out.println(met2[l][cont]);
        int TempResu = cont;
        for (i = l; i >= 1; i--) {
            int val = met2[i][TempResu] - mat[TempResu][Math.min(i, n - 1)];
            for (int lext = 0; lext < 10; lext++) {
                if (met2[i - 1][mat1[TempResu][lext]] == val) {
                    System.out.print(lext);
                    TempResu = mat1[TempResu][lext];
                    break;
                }
            }
        }
    }
}

//package globalround1;
import java.util.*;

public class ProblemH {
    public static void main(String[] args) {
        new ProblemH().solve();
    }

    int N = 1111, M=20111;
    Scanner in = new Scanner(System.in);
    char[] l = new char[N];
    char[] r = new char[N];
    int n, nl, nr, rt, tot, fr, rr;
    int[][] go = new int[M][10];
    int[][] wild = new int[M][811];
    int[] q = new int[M];
    int[] fail = new int[M];
    int[][] dp = new int[2111][M];

    void solve() {
        String tl = in.next();
        String tr = in.next();
        n = in.nextInt();
        nl = tl.length();
        nr = tr.length();
        for(int i = 0 ; i < nl ; i++){
            l[i] = tl.charAt(i);
        }
        for(int i = 0 ; i < nr ; i++){
            r[i] = tr.charAt(i);
        }
        rt = ++tot;
        insert(l);
        insert(r);
        if(nl == nr){
            int k1 = rt, k2 = rt;
            for(int i = 0 ; i < nl ; i++){
                if(k1 == k2 && l[i] !=r[i]){
                    for(int c = l[i]+1 ; c < r[i] ; c++){
                        if(go[k1][c-'0'] == 0){
                            go[k1][c-'0'] = ++tot;
                        }
                        wild[go[k1][c-'0']][nl-i-1]++;
                    }
                }
                else if(k1 != k2){
                    for(int c = l[i]+1 ; c < '0'+10 ; c++){
                        if(go[k1][c-'0'] == 0){
                            go[k1][c-'0'] = ++tot;
                        }
                        wild[go[k1][c-'0']][nl-i-1]++;
                    }
                    for(int c = '0'+ (i == 0 ? 1 : 0) ; c < r[i] ; c++){
                        if(go[k2][c-'0'] == 0){
                            go[k2][c-'0'] = ++tot;
                        }
                        wild[go[k2][c-'0']][nl-i-1]++;
                    }
                }
                k1 = go[k1][l[i]-'0'];
                k2 = go[k2][r[i]-'0'];
            }
            wild[k1][0]++;
            if(k1 != k2){
                wild[k2][0]++;
            }
        }
        else{
            int k1 = rt,k2 = rt;
            for(int i = 0 ; i < nl ; i++){
                for(int c = l[i]+1 ; c < '0'+10 ; c++){
                    if(go[k1][c-'0'] == 0){
                        go[k1][c-'0'] = ++tot;
                    }
                    wild[go[k1][c-'0']][nl-i-1]++;
                }
                k1 = go[k1][l[i]-'0'];
            }
            for(int i = 0 ; i < nr ; i++){
                for(int c = '0'+ (i == 0 ? 1 : 0) ; c < r[i] ; c++){
                    if(go[k2][c-'0'] == 0){
                        go[k2][c-'0'] = ++tot;
                    }
                    wild[go[k2][c-'0']][nr-i-1]++;
                }
                k2 = go[k2][r[i]-'0'];
            }
            wild[k1][0]++;
            wild[k2][0]++;
            for(int i = 1 ; i < 10 ; i++){
                if(go[rt][i] == 0){
                    go[rt][i] = ++tot;
                }
                for(int j = nl+1 ; j < nr ; j++){
                    wild[go[rt][i]][j-1]++;
                }
            }
        }
        construct();
        for(int i = 1 ; i < rr ; i++){
            int x = q[i];
            for(int j = 0 ; j < nr ; j++){
                wild[x][j] += wild[fail[x]][j];
            }
        }
        for(int i = 1 ; i <= tot ; i++){
            for(int j = 1 ; j < nr ; j++){
                wild[i][j] += wild[i][j-1];
            }
        }
        DP();
        in.close();
    }

    void insert(char s[]){
        int cur = rt;
        for(int i = 0 ; s[i] != 0  ; i++){
            if(go[cur][s[i]-'0'] == 0){
                go[cur][s[i]-'0'] = ++tot;
            }
            cur = go[cur][s[i]-'0'];
        }
    }

    void construct(){
        fr = rr = 0;
        q[rr++] = rt;
        for(; fr < rr ; fr++){
            int x = q[fr];
            for(int i = 0 ; i < 10 ; i++){
                if(go[x][i] != 0){
                    if(x == rt){
                        fail[go[x][i]] = x;
                    }
                    else{
                        fail[go[x][i]] = fail[x];
                        while(fail[go[x][i]] != rt && go[fail[go[x][i]]][i] == 0){
                            fail[go[x][i]] = fail[fail[go[x][i]]];
                        }
                        if(go[fail[go[x][i]]][i] != 0){
                            fail[go[x][i]] = go[fail[go[x][i]]][i];
                        }
                    }
                    q[rr++] = go[x][i];
                }
            }
        }
        for(int i = 0 ; i < 10 ; i++){
            if(go[rt][i] == 0){
                go[rt][i] = rt;
            }
        }
        for(int j = 1 ; j < rr ; j++){
            int x = q[j];
            for(int i = 0 ; i < 10 ; i++){
                if(go[x][i] == 0){
                    go[x][i] = go[fail[x]][i];
                }
            }
        }
    }

    void DP(){
        for(int i = 1 ; i <= tot ; i++){
            dp[0][i] = wild[i][0];
        }
        for(int i = 1 ; i <= n ; i++){
            for(int j = 1 ; j <= tot ; j++){
                for(int k = 0 ; k < 10 ; k++){
                    dp[i][j] = Math.max(dp[i][j], dp[i-1][go[j][k]]);
                }
                dp[i][j] += wild[j][Math.min(i, nr-1)];
            }
        }
        System.out.println(dp[n][rt]);
        int cur = rt;
        for(int i = n ; i >= 1 ; i--){
            int val = dp[i][cur]-wild[cur][Math.min(i, nr-1)];
            for(int next = 0 ; next < 10 ; next++){
                if(dp[i-1][go[cur][next]]==val){
                    System.out.print(next);
                    cur = go[cur][next];
                    break;
                }
            }
        }
    }
}

//package subestaçõesmodestas;

/**
 *
 * @author Eduardo M
 */
import java.util.Scanner;

public class Main {

    /*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
     */
    public static void main(String args[]) {

    Scanner sc = new Scanner(System.in);
    int l, y, n, cont, tt=0, aux, cont1, i, j, k;
    char[] vet = new char[810];
    char[] g = new char[810];
    char[] vet1 = new char[810];
    int[] vet2 = new int[21000];
    int[] vet3 = new int[21000];
    int[][] mat = new int[21000][810];
    int[][] mat1 = new int[21000][10];
    int[][] met2 = new int[2100][21000];

        String ent = sc.next();
        String ent1 = sc.next();
        l = sc.nextInt();
        y = ent.length();
        n = ent1.length();
        for (i = 0; i < y; i++) {
            vet[i] = ent.charAt(i);
        }
        for (i = 0; i < n; i++) {
            vet1[i] = ent1.charAt(i);
        }
        cont = ++tt;
        g = vet;
        int tempAdd = cont;
        for (i = 0; g[i] != 0; i++) {
            if (mat1[tempAdd][g[i] - '0'] == 0) {
                mat1[tempAdd][g[i] - '0'] = ++tt;
            }
            tempAdd = mat1[tempAdd][g[i] - '0'];
        }
        g = vet1;
        tempAdd = cont;
        for (i = 0; g[i] != 0; i++) {
            if (mat1[tempAdd][g[i] - '0'] == 0) {
                mat1[tempAdd][g[i] - '0'] = ++tt;
            }
            tempAdd = mat1[tempAdd][g[i] - '0'];
        }
        if (y == n) {
            int veri = cont, veri1 = cont;
            for (i = 0; i < y; i++) {
                if (veri == veri1 && vet[i] != vet1[i]) {
                    for (int c = vet[i] + 1; c < vet1[i]; c++) {
                        if (mat1[veri][c - '0'] == 0) {
                            mat1[veri][c - '0'] = ++tt;
                        }
                        mat[mat1[veri][c - '0']][y - i - 1]++;
                    }
                } else if (veri != veri1) {
                    for (int temp = vet[i] + 1; temp < '0' + 10; temp++) {
                        if (mat1[veri][temp - '0'] == 0) {
                            mat1[veri][temp - '0'] = ++tt;
                        }
                        mat[mat1[veri][temp - '0']][y - i - 1]++;
                    }
                    for (int temp = '0' + (i == 0 ? 1 : 0); temp < vet1[i]; temp++) {
                        if (mat1[veri1][temp - '0'] == 0) {
                            mat1[veri1][temp - '0'] = ++tt;
                        }
                        mat[mat1[veri1][temp - '0']][y - i - 1]++;
                    }
                }
                veri = mat1[veri][vet[i] - '0'];
                veri1 = mat1[veri1][vet1[i] - '0'];
            }
            mat[veri][0]++;
            if (veri != veri1) {
                mat[veri1][0]++;
            }
        } else {
            int veri = cont, veri1 = cont;
            for (i = 0; i < y; i++) {
                for (int temp = vet[i] + 1; temp < '0' + 10; temp++) {
                    if (mat1[veri][temp - '0'] == 0) {
                        mat1[veri][temp - '0'] = ++tt;
                    }
                    mat[mat1[veri][temp - '0']][y - i - 1]++;
                }
                veri = mat1[veri][vet[i] - '0'];
            }
            for (i = 0; i < n; i++) {
                for (int temp = '0' + (i == 0 ? 1 : 0); temp < vet1[i]; temp++) {
                    if (mat1[veri1][temp - '0'] == 0) {
                        mat1[veri1][temp - '0'] = ++tt;
                    }
                    mat[mat1[veri1][temp - '0']][n - i - 1]++;
                }
                veri1 = mat1[veri1][vet1[i] - '0'];
            }
            mat[veri][0]++;
            mat[veri1][0]++;
            for (i = 1; i < 10; i++) {
                if (mat1[cont][i] == 0) {
                    mat1[cont][i] = ++tt;
                }
                for (j = y + 1; j < n; j++) {
                    mat[mat1[cont][i]][j - 1]++;
                }
            }
        }
        aux = cont1 = 0;
        vet2[cont1++] = cont;
        for (; aux < cont1; aux++) {
            int x = vet2[aux];
            for (i = 0; i < 10; i++) {
                if (mat1[x][i] != 0) {
                    if (x == cont) {
                        vet3[mat1[x][i]] = x;
                    } else {
                        vet3[mat1[x][i]] = vet3[x];
                        while (vet3[mat1[x][i]] != cont && mat1[vet3[mat1[x][i]]][i] == 0) {
                            vet3[mat1[x][i]] = vet3[vet3[mat1[x][i]]];
                        }
                        if (mat1[vet3[mat1[x][i]]][i] != 0) {
                            vet3[mat1[x][i]] = mat1[vet3[mat1[x][i]]][i];
                        }
                    }
                    vet2[cont1++] = mat1[x][i];
                }
            }
        }
        for (i = 1; i < cont1; i++) {
            int x = vet2[i];
            for (j = 0; j < n; j++) {
                mat[x][j] += mat[vet3[x]][j];
            }
        }
        for (i = 1; i <= tt; i++) {
            for (j = 1; j < n; j++) {
                mat[i][j] += mat[i][j - 1];
            }
        }
         for (i = 1; i <= tt; i++) {
            met2[0][i] = mat[i][0];
        }
        for (i = 1; i <= l; i++) {
            for (j = 1; j <= tt; j++) {
                for (k = 0; k < 10; k++) {
                    met2[i][j] = Math.max(met2[i][j], met2[i - 1][mat1[j][k]]);
                }
                met2[i][j] += mat[j][Math.min(i, n - 1)];
            }
        }
        System.out.println(met2[l][cont]);
        int TempResu = cont;
        for (i = l; i >= 1; i--) {
            int val = met2[i][TempResu] - mat[TempResu][Math.min(i, n - 1)];
            for (int lext = 0; lext < 10; lext++) {
                if (met2[i - 1][mat1[TempResu][lext]] == val) {
                    System.out.print(lext);
                    TempResu = mat1[TempResu][lext];
                    break;
                }
            }
        }
    }
}

//package subestacoesmodestas;

/**
 *
 * @author Eduardo
 */
import java.util.Scanner;

public class SubestacoesModestas {

    public static void main(String[] args) {
       SubestacoesModestas d = new SubestacoesModestas();
       d.solucao();
    }

    Scanner sc = new Scanner(System.in);
    int  L, TamX, TamN, Cont, TT, aux, cont1,i,j,k, veri,veri2,AuxD;
    char[] vet = new char[810];
    char[] vet1 = new char[810];
    int[] vet2 = new int[21000];
    int[] vet3 = new int[21000];
    int[][] mat1 = new int[21000][810];
    int[][] mat2 = new int[21000][10];
    int[][] mat = new int[2100][21000];

    void solucao(){
        String tl = sc.next();
        String tr = sc.next();
        L= sc.nextInt();
        TamX = tl.length();
        TamN = tr.length();
        for( i = 0 ; i < TamX ; i++){
            vet[i] = tl.charAt(i);
        }
        for( i = 0 ; i < TamN ; i++){
            vet1[i] = tr.charAt(i);
        }
        Cont = ++TT;
        add(vet);
        add(vet1);
        if(TamX == TamN){
            veri = Cont;
            veri2 = Cont;
            for( i = 0 ; i < TamX ; i++){
                if( vet[i] != vet1[i]){
                    for(int temp = vet[i]+1 ; temp < vet1[i] ; temp++){
                        if(mat2[veri][temp-'0'] == 0){
                            mat2[veri][temp-'0'] = ++TT;
                        }
                        mat1[mat2[veri][temp-'0']][TamX-i-1]++;
                    }
                }
                else if(veri != veri2){
                    for(int temp = vet[i]+1 ; temp < '0'+10 ; temp++){
                        if(mat2[veri][temp-'0'] == 0){
                            mat2[veri][temp-'0'] = ++TT;
                        }
                        mat1[mat2[veri][temp-'0']][TamX-i-1]++;
                    }
                    for(int temp = '0'+ (i == 0 ? 1 : 0) ; temp < vet1[i] ; temp++){
                        if(mat2[veri2][temp-'0'] == 0){
                            mat2[veri2][temp-'0'] = ++TT;
                        }
                        mat1[mat2[veri2][temp-'0']][TamX-i-1]++;
                    }
                }
                veri = mat2[veri][vet[i]-'0'];
                veri2 = mat2[veri2][vet1[i]-'0'];
            }
            mat1[veri][0]++;
            if(veri != veri2){
                mat1[veri2][0]++;
            }
        }
        else{
            veri = Cont;
            veri2 = Cont;
            for( i = 0 ; i < TamX ; i++){
                for(int temp = vet[i]+1 ; temp < '0'+10 ; temp++){
                    if(mat2[veri][temp-'0'] == 0){
                        mat2[veri][temp-'0'] = ++TT;
                    }
                    mat1[mat2[veri][temp-'0']][TamX-i-1]++;
                }
                veri = mat2[veri][vet[i]-'0'];
            }
            for( i = 0 ; i < TamN ; i++){
                for(int temp = '0'+ (i == 0 ? 1 : 0) ; temp < vet1[i] ; temp++){
                    if(mat2[veri2][temp-'0'] == 0){
                        mat2[veri2][temp-'0'] = ++TT;
                    }
                    mat1[mat2[veri2][temp-'0']][TamN-i-1]++;
                }
                veri2 = mat2[veri2][vet1[i]-'0'];
            }
            mat1[veri][0]++;
            mat1[veri2][0]++;
            for( i = 1 ; i < 10 ; i++){
                if(mat2[Cont][i] == 0){
                    mat2[Cont][i] = ++TT;
                }
                for( j = TamX+1 ; j < TamN ; j++){
                    mat1[mat2[Cont][i]][j-1]++;
                }
            }
        }
        resolver();
        for( i = 1 ; i < cont1 ; i++){
             AuxD = vet2[i];
            for( j = 0 ; j < TamN ; j++){
                mat1[AuxD][j] += mat1[vet3[AuxD]][j];
            }
        }
        for( i = 1 ; i <= TT ; i++){
            for( j = 1 ; j < TamN ; j++){
                mat1[i][j] += mat1[i][j-1];
            }
        }
        resultado();
        sc.close();
    }
    void resultado(){
        for( i = 1 ; i <= TT ; i++){
            mat[0][i] = mat1[i][0];
        }
        for( i = 1 ; i <= L; i++){
            for( j = 1 ; j <= TT ; j++){
                for( k = 0 ; k < 10 ; k++){
                    mat[i][j] = Math.max(mat[i][j], mat[i-1][mat2[j][k]]);
                }
                mat[i][j] += mat1[j][Math.min(i, TamN-1)];
            }
        }
        System.out.println(mat[L][Cont]);
        AuxD = Cont;
        for( i = L; i >= 1 ; i--){
            int val = mat[i][AuxD]-mat1[AuxD][Math.min(i, TamN-1)];
            for(int next = 0 ; next < 10 ; next++){
                if(mat[i-1][mat2[AuxD][next]]==val){
                    System.out.print(next);
                    AuxD = mat2[AuxD][next];
                    break;
                }
            }
        }
    }
    void resolver(){
	aux=cont1;
       	cont1 = 0;
        vet2[cont1++] = Cont;
        for(; aux < cont1 ; aux++){
            AuxD = vet2[aux];
            for( i = 0 ; i < 10 ; i++){
                if(mat2[AuxD][i] != 0){
                    if(AuxD == Cont){
                        vet3[mat2[AuxD][i]] = AuxD;
                    }
                    else{
                        vet3[mat2[AuxD][i]] = vet3[AuxD];
                        while(vet3[mat2[AuxD][i]] != Cont && mat2[vet3[mat2[AuxD][i]]][i] == 0){
                            vet3[mat2[AuxD][i]] = vet3[vet3[mat2[AuxD][i]]];
                        }
                        if(mat2[vet3[mat2[AuxD][i]]][i] != 0){
                            vet3[mat2[AuxD][i]] = mat2[vet3[mat2[AuxD][i]]][i];
                        }
                    }
                    vet2[cont1++] = mat2[AuxD][i];
                }
            }
        }
        for( i = 0 ; i < 10 ; i++){
            if(mat2[Cont][i] == 0){
                mat2[Cont][i] = Cont;
            }
        }
        for( j = 1 ; j < cont1 ; j++){
            AuxD = vet2[j];
            for( i = 0 ; i < 10 ; i++){
                if(mat2[AuxD][i] == 0){
                    mat2[AuxD][i] = mat2[vet3[AuxD]][i];
                }
            }
        }
    }
    void add(char s[]){
        AuxD = Cont;
        for( i = 0 ; s[i] != 0  ; i++){
            if(mat2[AuxD][s[i]-'0'] == 0){
                mat2[AuxD][s[i]-'0'] = ++TT;
            }
            AuxD = mat2[AuxD][s[i]-'0'];
        }
    }

}

//package subestaçõesmodestas;

/**
 *
 * @author Eduardo M
 */
import java.util.Scanner;

public class SubestacoesModestas {

    public static void main(String[] args) {
        SubestacoesModestas d = new SubestacoesModestas();
        d.solucao();
    }

    Scanner sc = new Scanner(System.in);
    int L, TamX, TamN, Cont, TT, aux, cont1, i, j, k;
    char[] vet = new char[810];
    char[] vet1 = new char[810];
    int[] vet2 = new int[21000];
    int[] vet3 = new int[21000];
    int[][] mat1 = new int[21000][810];
    int[][] mat2 = new int[21000][10];
    int[][] mat = new int[2100][21000];

    void solucao() {
        String tl = sc.next();
        String tr = sc.next();
        L = sc.nextInt();
        TamX = tl.length();
        TamN = tr.length();
        for (i = 0; i < TamX; i++) {
            vet[i] = tl.charAt(i);
        }
        for (i = 0; i < TamN; i++) {
            vet1[i] = tr.charAt(i);
        }
        Cont = ++TT;
        add(vet);
        add(vet1);
        if (TamX == TamN) {
            int veri = Cont, veri2 = Cont;
            for (i = 0; i < TamX; i++) {
                if (vet[i] != vet1[i]) {
                    for (int temp = vet[i] + 1; temp < vet1[i]; temp++) {
                        if (mat2[veri][temp - '0'] == 0) {
                            mat2[veri][temp - '0'] = ++TT;
                        }
                        mat1[mat2[veri][temp - '0']][TamX - i - 1]++;
                    }
                } else if (veri != veri2) {
                    for (int temp = vet[i] + 1; temp < '0' + 10; temp++) {
                        if (mat2[veri][temp - '0'] == 0) {
                            mat2[veri][temp - '0'] = ++TT;
                        }
                        mat1[mat2[veri][temp - '0']][TamX - i - 1]++;
                    }
                    for (int temp = '0' + (i == 0 ? 1 : 0); temp < vet1[i]; temp++) {
                        if (mat2[veri2][temp - '0'] == 0) {
                            mat2[veri2][temp - '0'] = ++TT;
                        }
                        mat1[mat2[veri2][temp - '0']][TamX - i - 1]++;
                    }
                }
                veri = mat2[veri][vet[i] - '0'];
                veri2 = mat2[veri2][vet1[i] - '0'];
            }
            mat1[veri][0]++;
            if (veri != veri2) {
                mat1[veri2][0]++;
            }
        } else {
            int veri = Cont, veri2 = Cont;
            for (i = 0; i < TamX; i++) {
                for (int temp = vet[i] + 1; temp < '0' + 10; temp++) {
                    if (mat2[veri][temp - '0'] == 0) {
                        mat2[veri][temp - '0'] = ++TT;
                    }
                    mat1[mat2[veri][temp - '0']][TamX - i - 1]++;
                }
                veri = mat2[veri][vet[i] - '0'];
            }
            for (i = 0; i < TamN; i++) {
                for (int temp = '0' + (i == 0 ? 1 : 0); temp < vet1[i]; temp++) {
                    if (mat2[veri2][temp - '0'] == 0) {
                        mat2[veri2][temp - '0'] = ++TT;
                    }
                    mat1[mat2[veri2][temp - '0']][TamN - i - 1]++;
                }
                veri2 = mat2[veri2][vet1[i] - '0'];
            }
            mat1[veri][0]++;
            mat1[veri2][0]++;
            for (i = 1; i < 10; i++) {
                if (mat2[Cont][i] == 0) {
                    mat2[Cont][i] = ++TT;
                }
                for (j = TamX + 1; j < TamN; j++) {
                    mat1[mat2[Cont][i]][j - 1]++;
                }
            }
        }
        resolver();
        for (i = 1; i < cont1; i++) {
            int AuxD = vet2[i];
            for (j = 0; j < TamN; j++) {
                mat1[AuxD][j] += mat1[vet3[AuxD]][j];
            }
        }
        for (i = 1; i <= TT; i++) {
            for (j = 1; j < TamN; j++) {
                mat1[i][j] += mat1[i][j - 1];
            }
        }
        resultado();
        sc.close();
    }

    void add(char s[]) {
        int AuxD = Cont;
        for (i = 0; s[i] != 0; i++) {
            if (mat2[AuxD][s[i] - '0'] == 0) {
                mat2[AuxD][s[i] - '0'] = ++TT;
            }
            AuxD = mat2[AuxD][s[i] - '0'];
        }
    }

    void resolver() {
        aux = cont1;
        cont1 = 0;
        vet2[cont1++] = Cont;
        for (; aux < cont1; aux++) {
            int AuxD = vet2[aux];
            for (i = 0; i < 10; i++) {
                if (mat2[AuxD][i] != 0) {
                    if (AuxD == Cont) {
                        vet3[mat2[AuxD][i]] = AuxD;
                    } else {
                        vet3[mat2[AuxD][i]] = vet3[AuxD];
                        while (vet3[mat2[AuxD][i]] != Cont && mat2[vet3[mat2[AuxD][i]]][i] == 0) {
                            vet3[mat2[AuxD][i]] = vet3[vet3[mat2[AuxD][i]]];
                        }
                        if (mat2[vet3[mat2[AuxD][i]]][i] != 0) {
                            vet3[mat2[AuxD][i]] = mat2[vet3[mat2[AuxD][i]]][i];
                        }
                    }
                    vet2[cont1++] = mat2[AuxD][i];
                }
            }
        }
        for (i = 0; i < 10; i++) {
            if (mat2[Cont][i] == 0) {
                mat2[Cont][i] = Cont;
            }
        }
        for (j = 1; j < cont1; j++) {
            int AuxD = vet2[j];
            for (i = 0; i < 10; i++) {
                if (mat2[AuxD][i] == 0) {
                    mat2[AuxD][i] = mat2[vet3[AuxD]][i];
                }
            }
        }
    }

    void resultado() {
        for (i = 1; i <= TT; i++) {
            mat[0][i] = mat1[i][0];
        }
        for (i = 1; i <= L; i++) {
            for (j = 1; j <= TT; j++) {
                for (k = 0; k < 10; k++) {
                    mat[i][j] = Math.max(mat[i][j], mat[i - 1][mat2[j][k]]);
                }
                mat[i][j] += mat1[j][Math.min(i, TamN - 1)];
            }
        }
        System.out.println(mat[L][Cont]);
        int AuxD = Cont;
        for (i = L; i >= 1; i--) {
            int val = mat[i][AuxD] - mat1[AuxD][Math.min(i, TamN - 1)];
            for (int next = 0; next < 10; next++) {
                if (mat[i - 1][mat2[AuxD][next]] == val) {
                    System.out.print(next);
                    AuxD = mat2[AuxD][next];
                    break;
                }
            }
        }
    }

}

//package subesta��esmodestas;

/**
 *
 * @author Eduardo M
 */
import java.util.Scanner;

public class SubestacoesModestas {

    public static void main(String[] args) {
        SubestacoesModestas d = new SubestacoesModestas();
        d.solucao();
    }

    Scanner sc = new Scanner(System.in);
    int L, TamX, TamN, Cont, TT, aux, cont1, i, j, k;
    char[] vet = new char[810];
    char[] vet1 = new char[810];
    int[] vet2 = new int[21000];
    int[] vet3 = new int[21000];
    int[][] mat1 = new int[21000][810];
    int[][] mat2 = new int[21000][10];
    int[][] mat = new int[2100][21000];

    void solucao() {
        String tl = sc.next();
        String tr = sc.next();
        L = sc.nextInt();
        TamX = tl.length();
        TamN = tr.length();
        for (i = 0; i < TamX; i++) {
            vet[i] = tl.charAt(i);
        }
        for (i = 0; i < TamN; i++) {
            vet1[i] = tr.charAt(i);
        }
        Cont = ++TT;
        add(vet);
        add(vet1);
        if (TamX == TamN) {
            int veri = Cont, veri2 = Cont;
            for (i = 0; i < TamX; i++) {
                if (vet[i] != vet1[i]) {
                    for (int temp = vet[i] + 1; temp < vet1[i]; temp++) {
                        if (mat2[veri][temp - '0'] == 0) {
                            mat2[veri][temp - '0'] = ++TT;
                        }
                        mat1[mat2[veri][temp - '0']][TamX - i - 1]++;
                    }
                } else if (veri != veri2) {
                    for (int temp = vet[i] + 1; temp < '0' + 10; temp++) {
                        if (mat2[veri][temp - '0'] == 0) {
                            mat2[veri][temp - '0'] = ++TT;
                        }
                        mat1[mat2[veri][temp - '0']][TamX - i - 1]++;
                    }
                    for (int temp = '0' + (i == 0 ? 1 : 0); temp < vet1[i]; temp++) {
                        if (mat2[veri2][temp - '0'] == 0) {
                            mat2[veri2][temp - '0'] = ++TT;
                        }
                        mat1[mat2[veri2][temp - '0']][TamX - i - 1]++;
                    }
                }
                veri = mat2[veri][vet[i] - '0'];
                veri2 = mat2[veri2][vet1[i] - '0'];
            }
            mat1[veri][0]++;
            if (veri != veri2) {
                mat1[veri2][0]++;
            }
        } else {
            int veri = Cont, veri2 = Cont;
            for (i = 0; i < TamX; i++) {
                for (int temp = vet[i] + 1; temp < '0' + 10; temp++) {
                    if (mat2[veri][temp - '0'] == 0) {
                        mat2[veri][temp - '0'] = ++TT;
                    }
                    mat1[mat2[veri][temp - '0']][TamX - i - 1]++;
                }
                veri = mat2[veri][vet[i] - '0'];
            }
            for (i = 0; i < TamN; i++) {
                for (int temp = '0' + (i == 0 ? 1 : 0); temp < vet1[i]; temp++) {
                    if (mat2[veri2][temp - '0'] == 0) {
                        mat2[veri2][temp - '0'] = ++TT;
                    }
                    mat1[mat2[veri2][temp - '0']][TamN - i - 1]++;
                }
                veri2 = mat2[veri2][vet1[i] - '0'];
            }
            mat1[veri][0]++;
            mat1[veri2][0]++;
            for (i = 1; i < 10; i++) {
                if (mat2[Cont][i] == 0) {
                    mat2[Cont][i] = ++TT;
                }
                for (j = TamX + 1; j < TamN; j++) {
                    mat1[mat2[Cont][i]][j - 1]++;
                }
            }
        }
        resolver();
        for (i = 1; i < cont1; i++) {
            int AuxD = vet2[i];
            for (j = 0; j < TamN; j++) {
                mat1[AuxD][j] += mat1[vet3[AuxD]][j];
            }
        }
        for (i = 1; i <= TT; i++) {
            for (j = 1; j < TamN; j++) {
                mat1[i][j] += mat1[i][j - 1];
            }
        }
        resultado();
        sc.close();
    }

    void resultado() {
        for (i = 1; i <= TT; i++) {
            mat[0][i] = mat1[i][0];
        }
        for (i = 1; i <= L; i++) {
            for (j = 1; j <= TT; j++) {
                for (k = 0; k < 10; k++) {
                    mat[i][j] = Math.max(mat[i][j], mat[i - 1][mat2[j][k]]);
                }
                mat[i][j] += mat1[j][Math.min(i, TamN - 1)];
            }
        }
        System.out.println(mat[L][Cont]);
        int AuxD = Cont;
        for (i = L; i >= 1; i--) {
            int val = mat[i][AuxD] - mat1[AuxD][Math.min(i, TamN - 1)];
            for (int next = 0; next < 10; next++) {
                if (mat[i - 1][mat2[AuxD][next]] == val) {
                    System.out.print(next);
                    AuxD = mat2[AuxD][next];
                    break;
                }
            }
        }
    }

    void resolver() {
        aux = cont1;
        cont1 = 0;
        vet2[cont1++] = Cont;
        for (; aux < cont1; aux++) {
            int AuxD = vet2[aux];
            for (i = 0; i < 10; i++) {
                if (mat2[AuxD][i] != 0) {
                    if (AuxD == Cont) {
                        vet3[mat2[AuxD][i]] = AuxD;
                    } else {
                        vet3[mat2[AuxD][i]] = vet3[AuxD];
                        while (vet3[mat2[AuxD][i]] != Cont && mat2[vet3[mat2[AuxD][i]]][i] == 0) {
                            vet3[mat2[AuxD][i]] = vet3[vet3[mat2[AuxD][i]]];
                        }
                        if (mat2[vet3[mat2[AuxD][i]]][i] != 0) {
                            vet3[mat2[AuxD][i]] = mat2[vet3[mat2[AuxD][i]]][i];
                        }
                    }
                    vet2[cont1++] = mat2[AuxD][i];
                }
            }
        }
        for (i = 0; i < 10; i++) {
            if (mat2[Cont][i] == 0) {
                mat2[Cont][i] = Cont;
            }
        }
        for (j = 1; j < cont1; j++) {
            int AuxD = vet2[j];
            for (i = 0; i < 10; i++) {
                if (mat2[AuxD][i] == 0) {
                    mat2[AuxD][i] = mat2[vet3[AuxD]][i];
                }
            }
        }
    }

    void add(char s[]) {
        int AuxD = Cont;
        for (i = 0; s[i] != 0; i++) {
            if (mat2[AuxD][s[i] - '0'] == 0) {
                mat2[AuxD][s[i] - '0'] = ++TT;
            }
            AuxD = mat2[AuxD][s[i] - '0'];
        }
    }

}

//package globalround1;
import java.util.*;

public class ProblemH {
    public static void main(String[] args) {
        new ProblemH().solve();
    }

    int N = 1111, M=20111;
    Scanner in = new Scanner(System.in);
    char[] l = new char[N];
    char[] r = new char[N];
    int n, nl, nr, rt, tot, fr, rr;
    int[][] go = new int[M][10];
    int[][] wild = new int[M][811];
    int[] q = new int[M];
    int[] fail = new int[M];
    int[][] dp = new int[2111][M];

    void solve() {
        String tl = in.next();
        String tr = in.next();
        n = in.nextInt();
        nl = tl.length();
        nr = tr.length();
        for(int i = 0 ; i < nl ; i++){
            l[i] = tl.charAt(i);
        }
        for(int i = 0 ; i < nr ; i++){
            r[i] = tr.charAt(i);
        }
        rt = ++tot;
        insert(l);
        insert(r);
        if(nl == nr){
            int k1 = rt, k2 = rt;
            for(int i = 0 ; i < nl ; i++){
                if(k1 == k2 && l[i] !=r[i]){
                    for(int c = l[i]+1 ; c < r[i] ; c++){
                        if(go[k1][c-'0'] == 0){
                            go[k1][c-'0'] = ++tot;
                        }
                        wild[go[k1][c-'0']][nl-i-1]++;
                    }
                }
                else if(k1 != k2){
                    for(int c = l[i]+1 ; c < '0'+10 ; c++){
                        if(go[k1][c-'0'] == 0){
                            go[k1][c-'0'] = ++tot;
                        }
                        wild[go[k1][c-'0']][nl-i-1]++;
                    }
                    for(int c = '0'+ (i == 0 ? 1 : 0) ; c < r[i] ; c++){
                        if(go[k2][c-'0'] == 0){
                            go[k2][c-'0'] = ++tot;
                        }
                        wild[go[k2][c-'0']][nl-i-1]++;
                    }
                }
                k1 = go[k1][l[i]-'0'];
                k2 = go[k2][r[i]-'0'];
            }
            wild[k1][0]++;
            if(k1 != k2){
                wild[k2][0]++;
            }
        }
        else{
            int k1 = rt,k2 = rt;
            for(int i = 0 ; i < nl ; i++){
                for(int c = l[i]+1 ; c < '0'+10 ; c++){
                    if(go[k1][c-'0'] == 0){
                        go[k1][c-'0'] = ++tot;
                    }
                    wild[go[k1][c-'0']][nl-i-1]++;
                }
                k1 = go[k1][l[i]-'0'];
            }
            for(int i = 0 ; i < nr ; i++){
                for(int c = '0'+ (i == 0 ? 1 : 0) ; c < r[i] ; c++){
                    if(go[k2][c-'0'] == 0){
                        go[k2][c-'0'] = ++tot;
                    }
                    wild[go[k2][c-'0']][nr-i-1]++;
                }
                k2 = go[k2][r[i]-'0'];
            }
            wild[k1][0]++;
            wild[k2][0]++;
            for(int i = 1 ; i < 10 ; i++){
                if(go[rt][i] == 0){
                    go[rt][i] = ++tot;
                }
                for(int j = nl+1 ; j < nr ; j++){
                    wild[go[rt][i]][j-1]++;
                }
            }
        }
        construct();
        for(int i = 1 ; i < rr ; i++){
            int x = q[i];
            for(int j = 0 ; j < nr ; j++){
                wild[x][j] += wild[fail[x]][j];
            }
        }
        for(int i = 1 ; i < tot ; i++){
            for(int j = 1 ; j < nr ; j++){
                wild[i][j] += wild[i][j-1];
            }
        }
        DP();
        in.close();
    }

    void insert(char s[]){
        int cur = rt;
        for(int i = 0 ; s[i] != 0  ; i++){
            if(go[cur][s[i]-'0'] == 0){
                go[cur][s[i]-'0'] = ++tot;
            }
            cur = go[cur][s[i]-'0'];
        }
    }

    void construct(){
        fr = rr = 0;
        q[rr++] = rt;
        for(; fr < rr ; fr++){
            int x = q[fr];
            for(int i = 0 ; i < 10 ; i++){
                if(go[x][i] != 0){
                    if(x == rt){
                        fail[go[x][i]] = x;
                    }
                    else{
                        fail[go[x][i]] = fail[x];
                        while(fail[go[x][i]] != rt && go[fail[go[x][i]]][i] == 0){
                            fail[go[x][i]] = fail[fail[go[x][i]]];
                        }
                        if(go[fail[go[x][i]]][i] != 0){
                            fail[go[x][i]] = go[fail[go[x][i]]][i];
                        }
                    }
                    q[rr++] = go[x][i];
                }
            }
        }
        for(int i = 0 ; i < 10 ; i++){
            if(go[rt][i] == 0){
                go[rt][i] = rt;
            }
        }
        for(int j=1 ; j < rr ; j++){
            int x = q[j];
            for(int i = 0 ; i < 10 ; i++){
                if(go[x][i] == 0){
                    go[x][i] = go[fail[x]][i];
                }
            }
        }
    }

    void DP(){
        for(int i = 1 ; i <= tot ; i++){
            dp[0][i] = wild[i][0];
        }
        for(int i = 1 ; i <= n ; i++){
            for(int j = 1 ; j <= tot ; j++){
                for(int k = 0 ; k < 10 ; k++){
                    dp[i][j] = Math.max(dp[i][j], dp[i-1][go[j][k]]);
                }
            }
        }
        System.out.println(dp[n][rt]);
        int cur = rt;
        for(int i = n ; i >= 1 ; i--){
            int val = dp[i][cur]-wild[cur][Math.min(i, nr-1)];
            for(int next = 0 ; next < 10 ; next++){
                if(dp[i-1][go[cur][next]]==val){
                    System.out.print(next);
                    cur = go[cur][next];
                    break;
                }
            }
        }
    }
}

//package globalround1;
import java.util.*;

public class ProblemH {
    public static void main(String[] args) {
        new ProblemH().solve();
    }

    int N = 1111, M=20111;
    Scanner in = new Scanner(System.in);
    char[] l = new char[N];
    char[] r = new char[N];
    int n, nl, nr, rt, tot, fr, rr;
    int[][] go = new int[M][10];
    int[][] wild = new int[M][811];
    int[] q = new int[M];
    int[] fail = new int[M];
    int[][] dp = new int[2111][M];

    void solve() {
        String tl = in.next();
        String tr = in.next();
        n = in.nextInt();
        nl = tl.length();
        nr = tr.length();
        for(int i = 0 ; i < nl ; i++){
            l[i] = tl.charAt(i);
        }
        for(int i = 0 ; i < nr ; i++){
            r[i] = tr.charAt(i);
        }
        insert(l);
        insert(r);
        if(nl == nr){
            int k1 = rt, k2 = rt;
            for(int i = 0 ; i < nl ; i++){
                if(k1 == k2 && l[i] !=r[i]){
                    for(int c = l[i]+1 ; c < r[i] ; c++){
                        if(go[k1][c-'0'] == 0){
                            go[k1][c-'0'] = ++tot;
                        }
                        wild[go[k1][c-'0']][nl-i-1]++;
                    }
                }
                else if(k1 != k2){
                    for(int c = l[i]+1 ; c < '0'+10 ; c++){
                        if(go[k1][c-'0'] == 0){
                            go[k1][c-'0'] = ++tot;
                        }
                        wild[go[k1][c-'0']][nl-i-1]++;
                    }
                    for(int c = '0'+ (i == 0 ? 1 : 0) ; c < r[i] ; c++){
                        if(go[k2][c-'0'] == 0){
                            go[k2][c-'0'] = ++tot;
                        }
                        wild[go[k2][c-'0']][nl-i-1]++;
                    }
                }
                k1 = go[k1][l[i]-'0'];
                k2 = go[k2][r[i]-'0'];
            }
            wild[k1][0]++;
            if(k1 != k2){
                wild[k2][0]++;
            }
        }
        else{
            int k1 = rt,k2 = rt;
            for(int i = 0 ; i < nl ; i++){
                for(int c = l[i]+1 ; c < '0'+10 ; c++){
                    if(go[k1][c-'0'] == 0){
                        go[k1][c-'0'] = ++tot;
                    }
                    wild[go[k1][c-'0']][nl-i-1]++;
                }
                k1 = go[k1][l[i]-'0'];
            }
            for(int i = 0 ; i < nr ; i++){
                for(int c = '0'+ (i == 0 ? 1 : 0) ; c < r[i] ; c++){
                    if(go[k2][c-'0'] == 0){
                        go[k2][c-'0'] = ++tot;
                    }
                    wild[go[k2][c-'0']][nr-i-1]++;
                }
                k2 = go[k2][r[i]-'0'];
            }
            wild[k1][0]++;
            wild[k2][0]++;
            for(int i = 1 ; i < 10 ; i++){
                if(go[rt][i] == 0){
                    go[rt][i] = ++tot;
                }
                for(int j = nl+1 ; j < nr ; j++){
                    wild[go[rt][i]][j-1]++;
                }
            }
        }
        construct();
        for(int i = 1 ; i < rr ; i++){
            int x = q[i];
            for(int j = 0 ; j < nr ; j++){
                wild[x][j] += wild[fail[x]][j];
            }
        }
        for(int i = 1 ; i < tot ; i++){
            for(int j = 1 ; j < nr ; j++){
                wild[i][j] += wild[i][j-1];
            }
        }
        DP();
        in.close();
    }

    void insert(char s[]){
        int cur = rt;
        for(int i = 0 ; s[i] != 0  ; i++){
            if(go[cur][s[i]-'0'] == 0){
                go[cur][s[i]-'0'] = ++tot;
            }
            cur = go[cur][s[i]-'0'];
        }
    }

    void construct(){
        fr = rr = 0;
        q[rr++] = rt;
        for(; fr < rr ; fr++){
            int x = q[fr];
            for(int i = 0 ; i < 10 ; i++){
                if(go[x][i] != 0){
                    if(x == rt){
                        fail[go[x][i]] = x;
                    }
                    else{
                        fail[go[x][i]] = fail[x];
                        while(fail[go[x][i]] != rt && go[fail[go[x][i]]][i] == 0){
                            fail[go[x][i]] = fail[fail[go[x][i]]];
                        }
                        if(go[fail[go[x][i]]][i] != 0){
                            fail[go[x][i]] = go[fail[go[x][i]]][i];
                        }
                    }
                    q[rr++] = go[x][i];
                }
            }
        }
        for(int i = 0 ; i < 10 ; i++){
            if(go[rt][i] == 0){
                go[rt][i] = rt;
            }
        }
        for(int j=1 ; j < rr ; j++){
            int x = q[j];
            for(int i = 0 ; i < 10 ; i++){
                if(go[x][i] == 0){
                    go[x][i] = go[fail[x]][i];
                }
            }
        }
    }

    void DP(){
        for(int i = 1 ; i <= tot ; i++){
            dp[0][i] = wild[i][0];
        }
        for(int i = 1 ; i <= n ; i++){
            for(int j = 1 ; j <= tot ; j++){
                for(int k = 0 ; k < 10 ; k++){
                    dp[i][j] = Math.max(dp[i][j], dp[i-1][go[j][k]]);
                }
            }
        }
        System.out.println(dp[n][rt]);
        int cur = rt;
        for(int i = n ; i >= 1 ; i--){
            int val = dp[i][cur]-wild[cur][Math.min(i, nr-1)];
            for(int next = 0 ; next < 10 ; next++){
                if(dp[i-1][go[cur][next]]==val){
                    System.out.print(next);
                    cur = go[cur][next];
                    break;
                }
            }
        }
    }
}

//package codeforces;
import java.util.*;

public class ModestSubstrings {
    public static void main(String[] args) {
        new ModestSubstrings().solve();
    }

    Scanner in = new Scanner(System.in);
    int N = 2010, total, lenl, lenr;
    char[] l = new char[N];
    char[] r = new char[N];
    char[] sl = new char[N];
    char[] sr = new char[N];

    int[][] w = new int[20*N][N];
    int[] fail = new int[20*N];
    int[][] dp = new int[N][20*N];
    int[][] ch = new int[20*N][10];
    int[][] next = new int[N][20*N];
    int[] s = new int[N];

    void solve(){
        String lx = in.next();
        String rx = in.next();
        int n = in.nextInt();
        lenl = lx.length();
        lenr = rx.length();

        char[] tl = lx.toCharArray();
        char[] tr = rx.toCharArray();
        for(int i = 0 ; i < lenl ; i++){
            l[i+1] = tl[i];
        }
        for(int i = 0 ; i < lenr ; i++){
            r[i+1] = tr[i];
        }

        for(int i = lenl-1 ; i >=0 ; i--){
            l[i+1] = l[i];
        }
        for(int i = lenr-1 ; i >=0 ; i--){
            r[i+1] = r[i];
        }
        for(int i = lenl, j = lenr ; i > 0 ; i--, j--){
            l[j] = l[i];
        }
        for(int i = 1 ; i <= lenr-lenl ; i++){
            l[i] = '0';
        }
        for(int i = 1 ; i <= lenr ; i++){
            l[i] -= '0';
            r[i] -= '0';
        }
        DFS(1, 1, 1);
        build();
        for(int i = 1 ; i <= total ; i++){
            for(int j = 0 ; j <= n ; j++){
                w[i][j] += w[fail[i]][j];
            }
        }
        for(int i = 1 ; i <= total ; i++){
            for(int j = 1 ; j <= n ; j++){
                w[i][j] += w[i][j-1];
            }
        }
        for(int i = 0 ; i <= total ; i++){
            dp[0][i] = 0;
        }
        for(int i = 1 ; i <= n ; i++){
            for(int j = 0 ; j <= total ; j++){
                dp[i][j] = -(1<<60);
                for(int c = 0 ; i <= 9 ; i++){
                    int t = dp[i-1][ch[j][c]]+w[ch[j][c]][i-1];
                    if(t > dp[i][j]){
                        dp[i][j] = t;
                        next[i][j] = c;
                    }
                }
            }
        }
        System.out.println(dp[n][0]);
        for(int i = n, x = 0 , c ; i > 0 ; i--){
            c = next[i][x];
            System.out.print('0'+c);
            x = ch[x][c];
        }
        in.close();
    }

    void DFS(int len, int op1, int op2){
        if(len > lenr || (op1 != 0 && op2 != 0)){
            int i = 1, x = 0;
            for(; i < len && s[i] == 0 ;) {
                for(; i < len ; i++){
                    x = ins(x, s[i]);
                }
                w[x][lenr-len+1]++;
            }
            return;
        }
        int start = (op1 > 0 ? l[len] : 0);
        int end = (op2 > 0 ? r[len] : 9);
        for(int i = start ; i <= end ; i++){
            s[len] = i;
            DFS(len+1, ((op1 & i) == start ? 1 : 0), ((op2 & i) == end ? 1 : 0));
        }
    }

    int ins(int x, int c){
        if(ch[x][c] > 0){
            ch[x][c] = ++total;
        }
        return ch[x][c];
    }

    void build(){
        Queue<Integer> q = new LinkedList<>();
        for(int i = 0 ; i <=9 ; i++){
            if(ch[0][i] > 0){
                q.add(ch[0][i]);
            }
        }
        while(q.size() > 0){
            int u = q.remove();
            for(int i = 0 ; i < 9 ; i++){
                if(ch[u][i] > 0){
                    fail[ch[u][i]] = ch[fail[u]][i];
                    q.add(ch[u][i]);
                }
                else{
                    ch[u][i] = ch[fail[u]][i];
                }
            }
        }
    }
}