Problem: After observing the results of Spy Syndrome, Yash realised the errors of his ways. He now believes that a super spy such as Siddhant can't use a cipher as basic and ancient as Caesar cipher. After many weeks of observation of Siddhant’s sentences, Yash determined a new cipher technique.

For a given sentence, the cipher is processed as: 

  1. Convert all letters of the sentence to lowercase. 
  2. Reverse each of the words of the sentence individually. 
  3. Remove all the spaces in the sentence. 



For example, when this cipher is applied to the sentence

Kira is childish and he hates losing

the resulting string is

ariksihsidlihcdnaehsetahgnisol

Now Yash is given some ciphered string and a list of words. Help him to find out any original sentence composed using only words from the list. Note, that any of the given words could be used in the sentence multiple times.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 10 000) — the length of the ciphered text. The second line consists of n lowercase English letters — the ciphered text t.

The third line contains a single integer m (1 ≤ m ≤ 100 000) — the number of words which will be considered while deciphering the text. Each of the next m lines contains a non-empty word wi (|wi| ≤ 1 000) consisting of uppercase and lowercase English letters only. It's guaranteed that the total length of all words doesn't exceed 1 000 000.

Output

Print one line — the original sentence. It is guaranteed that at least one solution exists. If there are multiple solutions, you may output any of those.

Examples

Input

30
ariksihsidlihcdnaehsetahgnisol
10
Kira
hates
is
he
losing
death
childish
L
and
Note


Output

Kira is childish and he hates losing 


Input

12
iherehtolleh
5
HI
Ho
there
HeLLo
hello


Output

HI there HeLLo 

Note

In sample case 2 there may be multiple accepted outputs, "HI there HeLLo" and "HI there hello" you may output any of them. 

Solution (in JAVA):

Solution:

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Manthan2016C {
	
	public static class Pair implements Comparable<Pair> {
		long x;
		long y;

		public Pair(long x, long y) {
			this.x = x;
			this.y = y;
		}

		public int compareTo(Pair x) {
			//ascending order
			if (this.x == x.x) {
				return Long.compare(this.y, x.y);
			} else {
				return Long.compare(this.x, x.x);
			}
			//descending order
			//		if(this.x==x.x) {
			//			return Long.compare(x.y, this.y);
			//		}else {
			//			return Long.compare(x.x, this.x);
			//		}
		}

		//Use it rarely because it has about 0.115% collision rate which is quite 
		//and hence it will constantly keep go into equal function and hence slow
		public int hashCode() {
			return Long.hashCode(x) ^ Long.hashCode(y);
		}

		public boolean equals(Object o) {
			if (!(o instanceof Pair)) {
				return false;
			}
			Pair x = (Pair) o;
			if (x.x == this.x && x.y == this.y) {
				return true;
			} else {
				return false;
			}
		}
	}

	public static void solve() {
		int n = s.nextInt();
		str = s.next();
		PreCompute();
//		prefix = new int[n][2];
//		Pre(str);
		int m = s.nextInt();
		Strings[] given = new Strings[m];
		helper = new HashMap<Pair, Strings>();
		for(int i = 0; i < m; i++) {
			String curr = s.next();
			given[i] = new Strings(curr);
			long has1 = hash1(given[i]);
			long has2 = hash2(given[i]);
//			helper.put(hash1(given[i]), given[i]);
			Pair hashes = new Pair(hash1(given[i]), hash2(given[i]));
			helper.put(hashes, given[i]);
		}
		dp = new int[n];
		Arrays.fill(dp, -1);
		Recur(0);
		for(Strings x: ans) {
			out.print(x.actual+" ");
		}
	}
	
	public static HashMap<Pair, Strings> helper;
	public static int[] dp;
	public static String str;
	public static final int max_ = 1001;
	public static LinkedList<Strings> ans;
	
	public static boolean Recur(int pos) {
		int n = str.length();
		if(pos == n) {
			ans = new LinkedList<>();
			return true;
		}
		if(dp[pos] != -1) {
			if(dp[pos] == 0) return false;
			else return true;
		}
		long hash1 = 0, hash2 = 0;
		for(int i = pos, j =0; i < n && j < max_; j++ , i++) {
			hash1 = hash1 + ((long)get(str.charAt(i)) * (long)pre[j][0])%m[0];
			if(hash1 >= m[0]) {
				hash1 -= m[0];
			}
			hash2 = hash2  + ((long)get(str.charAt(i)) * (long)pre[j][1])%m[1];
			if(hash2 >= m[1]) {
				hash2 -= m[1];
			}
			Pair curr = new Pair(hash1, hash2);
			if(helper.containsKey(curr)) {
				boolean poss = Recur(i + 1);
				if(poss) {
					dp[pos] = 1;
					ans.addFirst(helper.get(curr));
					return true;
				}
			}
		}
		dp[pos] = 0;
		return false;
	}
	
	public static int[] m = new int[] { (int) 1e9 + 7, (int) 982451653};
	public static int[] p = new int[] { (int) 3571, (int) 7919};
	public static int max = (int) 2e5 + 10;// reduce it to 1e5 based on inputs
	public static long[][] pre = new long[max][2];

	public static void PreCompute() {
		//creates powers for each hash
		pre[0][0] = pre[0][1] = 1;
		for (int i = 0; i < 2; i++) {
			for (int j = 1; j < max; j++) {
				pre[j][i] = (pre[j - 1][i] * p[i]) % m[i];
			}
		}
	}
	
	public static int get(char val) {
		return val - 'a' + 1;
	}
	
	public static int hash1(Strings str) {
		//generate hash1
		int n = str.reverse.length();
		long genhashes = 0;
		for(int i = 0; i < n; i++) {
			genhashes = genhashes + pre[i][0] * get(str.reverse.charAt(i));
			genhashes %= m[0];
		}
		return (int)genhashes;
	}
	
	public static int hash2(Strings str) {
		//generate hash2
		int n = str.reverse.length();
		long genhashes = 0;
		for(int i = 0; i < n; i++) {
			genhashes = genhashes + pre[i][1] * get(str.reverse.charAt(i));
			genhashes %= m[1];
		}
		return (int)genhashes;
	}
	
	public static class Strings{
		String actual;
		String lower;
		String reverse;
		public Strings(String actual) {
			this.actual = actual;
			this.lower = actual.toLowerCase();
			this.reverse = reverse();
		}
		public String reverse() {
			StringBuilder ans = new StringBuilder();
			for(int i = lower.length() - 1; i >= 0; i--) {
				ans.append(lower.charAt(i));
			}
			return ans.toString();
		}
	}

	public static void main(String[] args) {
		out = new PrintWriter(new BufferedOutputStream(System.out));
		s = new FastReader();
		solve();
		out.close();
	}

	public static FastReader s;
	public static PrintWriter out;

	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	
}