import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); String s = sc.next(); String t = sc.next(); StringBuilder sb = new StringBuilder(); while (n-- > 0) { int x = sc.nextInt(); for (int i = x / s.length(); i >= 0; i--) { if ((x - s.length() * i) % t.length() == 0) { sb.append(getLine(s, t, i, (x - s.length() * i) / t.length())).append("\n"); break; } } } System.out.print(sb); } static String getLine(String s, String t, int a, int b) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < a; i++) { if (sb.length() != 0) { sb.append(" "); } sb.append(s); } for (int i = 0; i < b; i++) { if (sb.length() != 0) { sb.append(" "); } sb.append(t); } return sb.toString(); } } class Scanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); public Scanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String next() { try { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } finally { return st.nextToken(); } } }