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

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

/**
 * Solution, that uses Prefix function. Time complexity is O(|T| * |A|)
 * 
 * @author Niyaz Nigmatullin
 * 
 */
public class cards_nn_prefix {

	static final int ALPHABET = 26;

	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) {
		for (String e : a) {
			if (containsSubstring(e, t)) {
				return new Answer(1, e);
			}
		}
		Entry[][] ends = getWhatEndsHere(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| * |A|).
	 * 
	 * @param t
	 * @param a
	 * @return
	 */
	static Entry[][] getWhatEndsHere(String t, String[] a) {
		List<Entry>[] ret = new List[t.length()];
		for (int i = 0; i < ret.length; i++) {
			ret[i] = new ArrayList<Entry>();
		}
		int[][] prefixes = new int[a.length][];
		for (int i = 0; i < a.length; i++) {
			prefixes[i] = getPrefixFunction(a[i]);
		}
		int[] pT = getPrefixFunction(t);
		// Here we add all entries as suffix of A_i equals to prefix of T
		for (int i = 0; i < a.length; i++) {
			int k = -1;
			int[] p = pT;
			for (int j = 0; j < a[i].length(); j++) {
				while (k > -1
						&& (k + 1 >= t.length() || a[i].charAt(j) != t
								.charAt(k + 1))) {
					k = p[k];
				}
				if (k + 1 < t.length() && a[i].charAt(j) == t.charAt(k + 1)) {
					k++;
				}
			}
			while (k > -1) {
				ret[k].add(new Entry(a[i], k + 1));
				k = p[k];
			}
		}
		// Here we add all entries as suffix of T equals to prefix of A_i
		// and A_i is substring of T
		for (int i = 0; i < a.length; i++) {
			int k = -1;
			int[] p = prefixes[i];
			for (int j = 0; j < t.length(); j++) {
				while (k > -1
						&& (k + 1 >= a[i].length() || a[i].charAt(k + 1) != t
								.charAt(j))) {
					k = p[k];
				}
				if (k + 1 < a[i].length() && t.charAt(j) == a[i].charAt(k + 1)) {
					k++;
				}
				if (k + 1 == a[i].length()) {
					ret[j].add(new Entry(a[i], a[i].length()));
				}
			}
			while (k > -1) {
				ret[t.length() - 1].add(new Entry(a[i], k + 1));
				k = p[k];
			}
		}
		Entry[][] ans = new Entry[ret.length][];
		for (int i = 0; i < ans.length; i++) {
			ans[i] = ret[i].toArray(new Entry[ret[i].size()]);
		}
		return ans;
	}

	static int[] getPrefixFunction(String text) {
		int[] p = new int[text.length()];
		int k = -1;
		p[0] = -1;
		for (int i = 1; i < p.length; i++) {
			while (k > -1 && text.charAt(k + 1) != text.charAt(i)) {
				k = p[k];
			}
			if (text.charAt(k + 1) == text.charAt(i)) {
				k++;
			}
			p[i] = k;
		}
		return p;
	}

	static boolean containsSubstring(String text, String word) {
		int[] p = getPrefixFunction(text);
		int k = -1;
		for (int i = 0; i < text.length(); i++) {
			char c = text.charAt(i);
			while (k > -1
					&& (k + 1 >= word.length() || word.charAt(k + 1) != c)) {
				k = p[k];
			}
			if (k + 1 < word.length() && word.charAt(k + 1) == c) {
				k++;
			}
			if (k == word.length() - 1) {
				return true;
			}
		}
		return false;
	}

	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);
		}
	}
}
