import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.NoSuchElementException; class Main { int N, M; int[] X, Y; public static void main(String[] args) { new Main().run(); } void run() { Scanner sc = new Scanner(); long N = sc.nextLong(); class S implements Comparable { int idx; String s; public S(int idx, String s) { this.idx = idx; this.s = s; } public int compareTo(S o) { return s.compareTo(o.s); }; } S[] s = new S[(int) N]; for (int i = 0; i < N; ++i) { s[i] = new S(i, sc.next()); } Arrays.sort(s); int[] rev = new int[(int) N]; for (int i = 0; i < N; ++i) { rev[s[i].idx] = i; } int[] A = new int[(int) N]; for (int i = 0; i + 1 < N; ++i) { int len = 0; while (len < Math.min(s[i].s.length(), s[i + 1].s.length()) && s[i].s.charAt(len) == s[i + 1].s.charAt(len)) { ++len; } A[i] = len; } SparseTable st = new SparseTable(A); long M = sc.nextLong(); long x = sc.nextLong(); long d = sc.nextLong(); long ans = 0; for (int k = 0; k < M; ++k) { int i = (int) (x / (N - 1)) + 1; int j = (int) (x % (N - 1)) + 1; if (i > j) { int tmp = i; i = j; j = tmp; } else { j = j + 1; } x = (x + d) % (N * (N - 1)); --i; --j; if (rev[i] > rev[j]) { int tmp = i; i = j; j = tmp; } ans += st.query(rev[i], rev[j]); } System.out.println(ans); } class SparseTable { int[][] t; public SparseTable(int[] A) { int N = A.length; t = new int[(int) (Math.log(N) / Math.log(2) + 1)][]; t[0] = new int[(int) N]; for (int i = 0; i < N; ++i) { t[0][i] = A[i]; } for (int i = 1; i < t.length; ++i) { int p = 0; while ((p + 1) + (1 << i) <= N) ++p; t[i] = new int[p]; for (int j = 0; j < t[i].length; ++j) { t[i][j] = Math.min(t[i - 1][j], t[i - 1][j + (1 << (i - 1))]); } } } int query(int l, int r) { int a = 0; while (1 << (a + 1) <= (r - l)) { ++a; } return Math.min(t[a][l], t[a][r - (1 << a)]); } } class Scanner { private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private boolean hasNextByte() { if (ptr < buflen) { return true; } else { ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } private boolean isPrintableChar(int c) { return 33 <= c && c <= 126; } private void skipUnprintable() { while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; } public boolean hasNext() { skipUnprintable(); return hasNextByte(); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while (true) { if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; } else if (b == -1 || !isPrintableChar(b)) { return minus ? -n : n; } else { throw new NumberFormatException(); } b = readByte(); } } } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }