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:
//package com.codeforces.competitions.year2016.jantomarch.manthancodefest;

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

public final class TaskC implements Runnable
{
	public static void main(String[] args) throws InterruptedException
	{
		// here, 1 << 28 (i.e., 2 ^ 28, is the new size of stack that we want.
		Thread thread = new Thread(null, new TaskC(), "TaskC", 1 << 29);

		thread.start();
		thread.join();
	}

	public TaskC()
	{
		// take the input here ..
		InputReader in = new InputReader(System.in);
		OutputWriter out = new OutputWriter(System.out);

		Solver solver = new Solver(in, out);

		solver.solve(1);

		out.flush();

		in.close();
		out.close();
	}

	@Override
	public void run()
	{
		// your code here ..

		// OR, take input from file here itself. Might work while taking input from terminal too, haven't tried yet.
	}

	static class Solver
	{
		int n, m;
		String text, words[];
//		int[][] isWord;
//		ArrayList<Integer>[] isWord;
		ArrayList<Point>[] isWord;
		boolean[] dp, dpSet;
		Node root;
		InputReader in;
		OutputWriter out;

		void solve(int testNumber)
		{
			n = in.nextInt();
			text = in.next();
			m = in.nextInt();
			words = new String[m + 1];
//			isWord = new int[n + 1][n + 1];
			isWord = new ArrayList[n + 1];
			dp = new boolean[n + 1];
			dpSet = new boolean[n + 1];
			root = new Node();

			for (int i = 1; i <= m; i++)
			{
				words[i] = in.next();
				root = insert(root, new StringBuilder(words[i].toLowerCase()).reverse().toString(), words[i].length(),
						0, i);
			}

			for (int i = 0; i <= n; i++)
				isWord[i] = new ArrayList<>();

			int doneUpto = -1;

/*			while (true)
			{
				traverse(root, text, n, doneUpto + 1, doneUpto + 1);

				for (int j = n - 1; j >= 0; j--)
				{
					int found = binarySearch(isWord[doneUpto + 1], j);

					if (found != -1)
					{
						String match = words[found];

						doneUpto += match.length();
					}

					if (doneUpto == n - 1)
						break;
				}

				if (doneUpto == n - 1)
					break;
			}

			dfs(0);*/

//			System.out.println(dfs2(0));

/*			System.out.println("isWord : ");

			for (int i = 0; i <= n; i++, System.out.println())
			{
				System.out.print("from " + i + " : ");
				for (int j = 0; j < isWord[i].size(); j++)
					System.out.print(isWord[i].get(j) + " ");
			}*/

//			System.out.println("does trie contain aaaaa? " + contains(root, "aaaaa", 5, 0));

			if (dfs2(-1))
			{
				int size = answer.size();

//				out.println("******" + size + "****");
				for (int i = size - 1; i >= 0; i--)
					out.print(answer.get(i) + " ");
			}
			else
			{
//				out.println("not possible");

				int[] count = new int[26];

				for (int i = 0; i < n; i++)
					count[text.charAt(i) - 'a']++;

				for (int i = 0; i < 26; i++)
				{
					if (count[i] > 0)
						System.out.print((char) (i + 'a') + " : " + count[i] + ", ");
				}

				System.out.println("m : " + m);

				Set<String> wordSet = new HashSet<>();

				for (int i = 1; i <= m; i++)
					wordSet.add(words[i]);

				System.out.println("wordSet.size : " + wordSet.size() + ", wordSet : " + wordSet.toString());
			}
		}

		ArrayList<String> answer = new ArrayList<>();

		boolean dfs2(int doneUpto)
		{
/*			System.out.println("doneUpto : " + doneUpto + ", will traverse root from " + (doneUpto + 1) + ", with "
					+ "startIndex : " + (doneUpto + 1));*/
			traverse(root, text, n, doneUpto + 1, doneUpto + 1);
/*			System.out.println("words from " + (doneUpto + 1) + " => ");

			for (int i = 0; i < isWord[doneUpto + 1].size(); i++)
			{
				Point p = isWord[doneUpto + 1].get(i);
				String w = words[p.y];

				System.out.println("\t" + p.x + ", " + w);
			}*/

			int size = isWord[doneUpto + 1].size();

			for (int i = 0; i < size; i++)
			{
				String currWord = words[isWord[doneUpto + 1].get(i).y];
				int temp = doneUpto + currWord.length();
//				System.out.println("index : " + index + ", i : " + i + ", word : " + words[isWord[index].get(i).y]);

/*				if (doneUpto == -1)
					System.out.println("\t\t&&&&will check for word : " + currWord);*/

				if (temp == n - 1)
				{
					answer.add(currWord);

					return true;
				}

				if (dpSet[temp])
				{
					continue;
/*					if (doneUpto == -1)
						System.out.println("^^^^^^^^ I'm going back, motherfuckers!!!! when temp : " + temp);

					return dp[temp];*/
				}

				if (dfs2(temp))
				{
					answer.add(currWord);

					return true;
				}
				else
				{
					dpSet[temp] = true;
					dp[temp] = false;
				}
			}

			return false;
		}

		Node insert(Node node, String word, int length, int index, int wordIndex)
		{
			int pos = word.charAt(index) - 'a';
			Node temp = node.next[pos];

			if (temp == null)
				temp = new Node();

			if (index == length - 1)
			{
				temp.wordIndex = wordIndex;
				temp.isWord = true;
			}
			else
				temp = insert(temp, word, length, index + 1, wordIndex);

			node.next[pos] = temp;

			return node;
		}

		void traverse(Node node, String word, int length, int from, int index)
		{
/*			if (from == 6)
				System.out.println("\t\t****word : " + word + ", len : " + length + ", from : " + from + ", index : " +
						index);*/
			int pos = word.charAt(index) - 'a';
			Node temp = node.next[pos];

			if (temp == null)
				return;
/*			else
				System.out.print(word.charAt(index));*/

			if (temp.isWord)
				isWord[from].add(new Point(index, temp.wordIndex));
//				isWord[from][wordIndex] = temp.wordIndex;

			if (index == length - 1)
				return;

			traverse(temp, word, length, from, index + 1);
		}

		int binarySearch(ArrayList<Point> list, int num)
		{
			int first, last, mid;

			first = 0;
			last = list.size() - 1;

			while (first <= last)
			{
				mid = first + ((last - first) >> 1);
				Point temp = list.get(mid);

				if (temp.x == num)
					return temp.y;
				else if (temp.x < num)
					first = mid + 1;
				else
					last = mid - 1;
			}

			return -1;
		}

		boolean dfs(int index)
		{
			if (index == n)
				return true;

			for (int i = index + 1; i < n; i++)
			{
				int found = binarySearch(isWord[index], i);

				if (found != -1)
				{
					if (dpSet[index])
						return dp[index];

//					boolean result = dfs(index + words[isWord[index][i]].length());
					boolean result = dfs(index + words[found].length());

					if (result)
					{
						answer.add(words[found]);

						return true;
					}
				}
			}

			dpSet[index] = true;

			return false;
		}

		boolean contains(Node node, String word, int length, int index)
		{
			int pos = word.charAt(index) - 'a';
			Node temp = node.next[pos];

			if (temp == null)
				return false;

			if (index == length - 1)
				return temp.isWord;
			else
				return contains(temp, word, length, index + 1);
		}

		class Node
		{
			Node[] next;
			int wordIndex;
			boolean isWord;

			public Node()
			{
				wordIndex = -1;
				next = new Node[26];
			}

		}

		public Solver(InputReader in, OutputWriter out)
		{
			this.in = in;
			this.out = out;
		}

	}

	static class InputReader
	{
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}

		public int read()
		{
			if (numChars == -1)
				throw new InputMismatchException();

			if (curChar >= numChars)
			{
				curChar = 0;
				try
				{
					numChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}

			return buf[curChar++];
		}

		public int nextInt()
		{
			int c = read();

			while (isSpaceChar(c))
				c = read();

			int sgn = 1;

			if (c == '-')
			{
				sgn = -1;
				c = read();
			}

			int res = 0;

			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();

				res *= 10;
				res += c & 15;

				c = read();
			} while (!isSpaceChar(c));

			return res * sgn;
		}

		public int[] nextIntArray(int arraySize)
		{
			int array[] = new int[arraySize];

			for (int i = 0; i < arraySize; i++)
				array[i] = nextInt();

			return array;
		}

		public long nextLong()
		{
			int c = read();

			while (isSpaceChar(c))
				c = read();

			int sign = 1;

			if (c == '-')
			{
				sign = -1;

				c = read();
			}

			long result = 0;

			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();

				result *= 10;
				result += c & 15;

				c = read();
			} while (!isSpaceChar(c));

			return result * sign;
		}

		public long[] nextLongArray(int arraySize)
		{
			long array[] = new long[arraySize];

			for (int i = 0; i < arraySize; i++)
				array[i] = nextLong();

			return array;
		}

		public float nextFloat() // problematic
		{
			float result, div;
			byte c;

			result = 0;
			div = 1;
			c = (byte) read();

			while (c <= ' ')
				c = (byte) read();

			boolean isNegative = (c == '-');

			if (isNegative)
				c = (byte) read();

			do
			{
				result = result * 10 + c - '0';
			} while ((c = (byte) read()) >= '0' && c <= '9');

			if (c == '.')
				while ((c = (byte) read()) >= '0' && c <= '9')
					result += (c - '0') / (div *= 10);

			if (isNegative)
				return -result;

			return result;
		}

		public double nextDouble() // not completely accurate
		{
			double ret = 0, div = 1;
			byte c = (byte) read();

			while (c <= ' ')
				c = (byte) read();

			boolean neg = (c == '-');

			if (neg)
				c = (byte) read();

			do
			{
				ret = ret * 10 + c - '0';
			} while ((c = (byte) read()) >= '0' && c <= '9');

			if (c == '.')
				while ((c = (byte) read()) >= '0' && c <= '9')
					ret += (c - '0') / (div *= 10);

			if (neg)
				return -ret;

			return ret;
		}

		public String next()
		{
			int c = read();

			while (isSpaceChar(c))
				c = read();

			StringBuilder res = new StringBuilder();

			do
			{
				res.appendCodePoint(c);

				c = read();
			} while (!isSpaceChar(c));

			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public String nextLine()
		{
			int c = read();

			StringBuilder result = new StringBuilder();

			do
			{
				result.appendCodePoint(c);

				c = read();
			} while (!isNewLine(c));

			return result.toString();
		}

		public boolean isNewLine(int c)
		{
			return c == '\n';
		}

		public void close()
		{
			try
			{
				stream.close();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
		}

	}

	static class OutputWriter
	{
		private PrintWriter writer;

		public OutputWriter(OutputStream stream)
		{
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
					stream)));
		}

		public OutputWriter(Writer writer)
		{
			this.writer = new PrintWriter(writer);
		}

		public void println(int x)
		{
			writer.println(x);
		}

		public void print(int x)
		{
			writer.print(x);
		}

		public void println(int array[], int size)
		{
			for (int i = 0; i < size; i++)
				println(array[i]);
		}

		public void print(int array[], int size)
		{
			for (int i = 0; i < size; i++)
				print(array[i] + " ");
		}

		public void println(long x)
		{
			writer.println(x);
		}

		public void print(long x)
		{
			writer.print(x);
		}

		public void println(long array[], int size)
		{
			for (int i = 0; i < size; i++)
				println(array[i]);
		}

		public void print(long array[], int size)
		{
			for (int i = 0; i < size; i++)
				print(array[i]);
		}

		public void println(float num)
		{
			writer.println(num);
		}

		public void print(float num)
		{
			writer.print(num);
		}

		public void println(double num)
		{
			writer.println(num);
		}

		public void print(double num)
		{
			writer.print(num);
		}

		public void println(String s)
		{
			writer.println(s);
		}

		public void print(String s)
		{
			writer.print(s);
		}

		public void println()
		{
			writer.println();
		}

		public void printSpace()
		{
			writer.print(" ");
		}

		public void flush()
		{
			writer.flush();
		}

		public void close()
		{
			writer.close();
		}

	}

	static class CMath
	{
		static long power(long number, long power)
		{
			if (number == 1 || number == 0 || power == 0)
				return 1;

			if (power == 1)
				return number;

			if (power % 2 == 0)
				return power(number * number, power / 2);
			else
				return power(number * number, power / 2) * number;
		}

		static long modPower(long number, long power, long mod)
		{
			if (number == 1 || number == 0 || power == 0)
				return 1;

			number = mod(number, mod);

			if (power == 1)
				return number;

			long square = mod(number * number, mod);

			if (power % 2 == 0)
				return modPower(square, power / 2, mod);
			else
				return mod(modPower(square, power / 2, mod) * number, mod);
		}

		static long moduloInverse(long number, long mod)
		{
			return modPower(number, mod - 2, mod);
		}

		static long mod(long number, long mod)
		{
			return number - (number / mod) * mod;
		}

		static int gcd(int a, int b)
		{
			if (b == 0)
				return a;
			else
				return gcd(b, a % b);
		}

	}

}

/*

7
uhaluar
5
rahul
rah
ra
ahu
ul

7
uhaluar
5
rahul
rah
ahu
ul
raul

7
kirkirk
2
rik
krik

10
aaaaaaaaaa
2
a
A

10
aaaaaaaaaa
10
aaaaaaaaa
aaaaaaaaa
aaaaaaaaa
aaaaaaaaa
aaaaaaaaa
aaaaaaaaa
aaaaaaaaa
aaaaaaaaa
aaaaaaaaa
a

10
aaaaaaaaaa
3
aaaaaaaaa
aaa
aaaaa


*/