import static java.lang.Math.min;
import static java.util.Arrays.deepToString;
import static java.util.Arrays.fill;

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

/**
 * Very stupid solution. Time complexity is O(|T| * Sum(|A_i|))
 * 
 * @author Niyaz Nigmatullin
 * 
 */
public class cards_nn_slow {

	static void solve() throws Exception {
		String t = next();
		int n = nextInt();
		String[] a = new String[n];
		for (int i = 0; i < n; i++) {
			a[i] = next();
		}
		Answer ans = answer(t, a);
		out.println(ans == null ? "No solution" : ans);
	}

	static Answer answer(String t, String[] a) {
		List<Entry>[] ends = getWhatEndsHereSlow(t, a);
		int[] dp = new int[t.length() + 1];
		Entry[] lastEntryUsed = new Entry[t.length() + 1];
		fill(dp, Integer.MAX_VALUE);
		dp[0] = 0;
		for (int i = 1; i <= t.length(); i++) {
			for (Entry e : ends[i - 1]) {
				int j = e.len;
				if (dp[i - j] == Integer.MAX_VALUE) {
					continue;
				}
				if (dp[i] > dp[i - j] + 1) {
					dp[i] = dp[i - j] + 1;
					lastEntryUsed[i] = e;
				}
			}
		}
		if (dp[t.length()] == Integer.MAX_VALUE) {
			return null;
		}
		List<String> words = new ArrayList<String>();
		for (int pos = t.length(); pos > 0; pos -= lastEntryUsed[pos].len) {
			words.add(lastEntryUsed[pos].string);
		}
		Collections.reverse(words);
		StringBuilder ret = new StringBuilder();
		for (String e : words) {
			ret.append(e);
		}
		return new Answer(dp[t.length()], ret.toString());
	}

	/**
	 * Time complexity is O(|T| * Sum(|A_i|)).
	 * 
	 * @param t
	 * @param a
	 * @return
	 */
	static List<Entry>[] getWhatEndsHereSlow(String t, String[] a) {
		List<Entry>[] ret = new List[t.length()];
		for (int i = 0; i < ret.length; i++) {
			ret[i] = new ArrayList<Entry>();
		}
		for (String e : a) {
			all: for (int p = 0; p - e.length() + 1 < t.length(); p++) {
				int count = 0;
				for (int j = 0; j < e.length(); j++) {
					int pos = p - e.length() + j + 1;
					if (pos < 0 || pos >= t.length()) {
						continue;
					}
					if (e.charAt(j) != t.charAt(pos)) {
						continue all;
					}
					count++;
				}
				ret[min(p, t.length() - 1)].add(new Entry(e, count));
			}
		}
		return ret;
	}

	static class Answer {
		int countWords;
		String text;

		public Answer(int countWords, String text) {
			this.countWords = countWords;
			this.text = text;
		}

		@Override
		public String toString() {
			return countWords + "\n" + text;
		}
	}

	static class Entry {
		String string;
		int len;

		public Entry(String string, int len) {
			this.string = string;
			this.len = len;
		}

	}

	static BufferedReader br;
	static StringTokenizer st;
	static PrintWriter out;

	static void debug(Object... a) {
		System.err.println(deepToString(a));
	}

	static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	static String next() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String line = br.readLine();
			if (line == null) {
				return null;
			}
			st = new StringTokenizer(line);
		}
		return st.nextToken();
	}

	static long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	static double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public static void main(String[] args) {
		try {
			File file = new File("cards.in");
			InputStream input = System.in;
			OutputStream output = System.out;
			if (file.canRead()) {
				input = (new FileInputStream(file));
				output = (new PrintStream("cards.out"));
			}
			br = new BufferedReader(new InputStreamReader(input));
			out = new PrintWriter(output);
			solve();
			out.close();
			br.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
}
