import java.util.*;
import java.io.*;

public class prefix_as implements Runnable {
    String txt;
    String enc;

    Map<Character, String> code;

    int[][] numoc;

    String spaces(int x) {
        String r = "";
        for (int i = 0; i < x; i++) {
            r += " ";
        }
        return r;
    }

    boolean bt(int p, int q) {
        if (p == txt.length() && q == enc.length()) {
            return true;
        }
        if (p == txt.length() ^ q == enc.length()) {
            return false;
        }

        if (code.containsKey(txt.charAt(p))) {
            String cd = code.get(txt.charAt(p));
            int l = cd.length();
            return q + l <= enc.length() && enc.substring(q, q + l).equals(cd) && bt(p + 1, q + l);
        } else {
            search:
            for (int l = 1; q + l <= enc.length(); l++) {
                String cd = enc.substring(q, q + l);
                int cnt = findDistinct(enc, q, cd);
                if (cnt < numoc[p][txt.charAt(p) - 'a']) {
                    return false;
                }
                for (String z : code.values()) {
                    if (z.startsWith(cd) || cd.startsWith(z)) {
                        continue search;
                    }
                }

//                System.out.println(spaces(p) + "trying " + txt.charAt(p) + "=" + cd);
                code.put(txt.charAt(p), cd);
                if (bt(p + 1, q + l)) {
                    return true;
                }
                code.remove(txt.charAt(p));
//                System.out.println(spaces(p) + "abandon " + txt.charAt(p) + "=" + cd);
            }
        }
        return false;
    }

    int findDistinct(String q, int from, String text) {
        int r = 0;
        while ((from = q.indexOf(text, from)) != -1) {
            r++;
            from += text.length();
        }
        return r;
    }

    public void solve() throws IOException {
        Scanner in = new Scanner(new File("prefix.in"));
        PrintWriter out = new PrintWriter("prefix.out");

        txt = in.next();
        enc = in.next();

        numoc = new int[txt.length() + 1][26];
        for (int i = txt.length() - 1; i >= 0; i--) {
            for (int j = 0; j < 26; j++) {
                if (j == txt.charAt(i) - 'a') {
                    numoc[i][j] = numoc[i + 1][j] + 1;
                } else {
                    numoc[i][j] = numoc[i + 1][j];
                }
            }
        }

        code = new HashMap<Character, String>();

        boolean found = bt(0, 0);
        assert found;

        for (Map.Entry<Character, String> e : code.entrySet()) {
            out.println(e.getKey() + " " + e.getValue());
        }

        in.close();
        out.close();
    }

    public void run() {
        try {
            solve();
        } catch (IOException e) {
        }
    }

    public static void main(String[] arg) {
        new Thread(new prefix_as()).start();
    }
}