#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6+5;
int n, cnt[200];
char temp[200][100];
struct node{
int nex[maxn][26], val[maxn], f[maxn], last[maxn];
int root, L;
int newnode() {
for(int i = 0; i < 26; i++) nex[L][i] = 0;
val[L] = 0;
return L++;
}
void init() {
L = 0;
root = newnode();
memset(cnt, 0, sizeof(cnt));
}
void insert(char *s, int x) {
int len = strlen(s), u = root;
for(int i = 0; i < len; i++) {
int c = s[i] - 'a';
if(!nex[u][c]) nex[u][c] = newnode();
u = nex[u][c];
}
val[u] = x;
}
void getfail() {
queue<int>Q;
Q.push(root);
while(!Q.empty()) {
int u = Q.front(), k = f[u];Q.pop();
for(int i = 0; i < 26; i++) {
int v = nex[u][i];
if(!v){nex[u][i] = nex[k][i]; continue;}
Q.push(v);
f[v] = u?nex[k][i]:0;
last[v] = val[f[v]]?f[v]:last[f[v]];
}
}
}
void query(char *s) {
int len = strlen(s), u = root, res = 0;
for(int i = 0; i < len; i++) {
int c = s[i] - 'a';
u = nex[u][c];
if(val[u]) cnt[val[u]]++;
int v = last[u];
while(v) {
if(val[v]) cnt[val[v]]++;
v = last[v];
}
}
for(int i = 1; i <= n; i++) res = max(res, cnt[i]);
printf("%d\n", res);
for(int i = 1; i <= n; i++)if(cnt[i] == res) printf("%s\n", temp[i]);
}
}ac;
char s[maxn];
void solve() {
ac.init();
for(int i = 1; i <= n; i++) {
scanf("%s", temp[i]);
ac.insert(temp[i], i);
}
ac.getfail();
scanf("%s", s);
ac.query(s);
return;
}
int main() {
while(scanf("%d", &n) == 1 && n) {
solve();
}
return 0;
}