#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char s = getchar();
  while ((s < '0' || s > '9') && s > 0) {
    if (s == '-') f *= -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = (x << 1) + (x << 3) + s - '0';
    s = getchar();
  }
  return x * f;
}
struct matrix {
  int n, m;
  long long c[105][105];
  matrix() { memset(c, 0, sizeof(c)); }
  matrix(int N, int M) {
    n = N, m = M;
    memset(c, 0, sizeof(c));
  }
  matrix operator*(const matrix& a) {
    matrix res = matrix(n, a.m);
    for (int i = 1; i <= n; i++)
      for (int k = 1; k <= m; k++)
        for (int j = 1; j <= a.m; j++)
          res.c[i][j] = (res.c[i][j] + c[i][k] * a.c[k][j]) % (998244353ll - 1);
    return res;
  }
};
inline matrix jzksm(matrix a, long long b) {
  matrix res = matrix(a.n, a.n);
  for (int i = 1; i <= a.n; i++) res.c[i][i] = 1;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a;
    a = a * a;
  }
  return res;
}
inline long long ksm(long long a, long long b, long long mo) {
  long long res = 1;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mo;
    a = a * a % mo;
  }
  return res;
}
int k;
long long B[105], n, m;
vector<long long> z;
inline long long BSGS(long long m, long long p) {
  long long sp = (sqrt(p) + 0.5), a = ksm(3, sp, p), b = m;
  map<long long, long long> g;
  for (int i = 1; i <= sp; i++) g[b] = i, b = b * 3 % p;
  b = a;
  for (int i = 1; i <= sp; i++) {
    if (g[b] > 0) return (sp * i % (p - 1) - g[b] + p) % (p - 1);
    b = b * a % p;
  }
  return -1;
}
inline long long exgcd(long long a, long long b, long long& x, long long& y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  long long res = exgcd(b, a % b, y, x);
  y -= a / b * x;
  return res;
}
int main() {
  k = read();
  for (int i = k; i > 0; i--) B[i] = read();
  n = read(), m = read();
  matrix a = matrix(1, k), b = matrix(k, k);
  a.c[1][k] = 1;
  for (int i = 1; i < k; i++) b.c[i + 1][i] = 1;
  for (int i = 1; i <= k; i++) b.c[i][k] = B[i];
  a = a * jzksm(b, n - k);
  if (a.c[1][k] == 0) a.c[1][k] += 998244353ll - 1;
  if (m != 1 && a.c[1][k] == 998244353ll - 1) return 0 * puts("-1");
  if (m == 1) return 0 * puts("1");
  long long t = BSGS(m, 998244353ll), j, o, ans, d;
  d = exgcd(a.c[1][k], 998244353ll - 1, j, o),
  j = (j * (t / d) % (998244353ll - 1) + 998244353ll - 1) % (998244353ll - 1);
  ans = ksm(3, j, 998244353ll);
  if (ksm(ans, a.c[1][k], 998244353ll) == m)
    printf("%lld\n", ans);
  else
    puts("-1");
  return 0;
}
