#include <iostream>
#include <vector>
#include <stdio.h>
#include <string>
#include <algorithm>

using namespace std;

string s;

int main() {
	freopen("enigmatic.in", "rt", stdin);
	freopen("enigmatic.out", "wt", stdout);
	cin >> s;
	int n = s.size(), k;
	cin >> k;
	vector<string> dict(k);
	for (int i = 0; i < k; i++) {
		cin >> dict[i];
	}
	do {
		string tmp = "";
		int ans = 0;
		while (tmp.size() < n){
			tmp += dict[ans++];
		}
		if (tmp == s){
			cout << ans << endl;
			for (int i = 0; i < ans; i++){
				cout << dict[i] << endl;
			}
			return 0;
		}
	} while (next_permutation(dict.begin(), dict.end()));
	cout << 0;
	return 0;
}
