#include <bits/stdc++.h>
template <class T>
inline T read() {
  T r = 0, f = 0;
  char c;
  while (!isdigit(c = getchar())) f |= (c == '-');
  while (isdigit(c)) r = (r << 1) + (r << 3) + (c ^ 48), c = getchar();
  return f ? -r : r;
}
inline long long qpow(long long a, int b) {
  long long ans = 1;
  for (; b; b >>= 1) {
    if (b & 1) (ans *= a) %= 998244353;
    (a *= a) %= 998244353;
  }
  return ans;
}
int exgcd(int a, int b, long long &x, long long &y) {
  if (!b) {
    x = 1, y = 0;
    return a;
  }
  int d = exgcd(b, a % b, y, x);
  y -= x * (a / b);
  return d;
}
int K, n, m;
long long f[111], a[111][111];
long long b[111], c[111][111];
inline void Mul() {
  for (int i = 0; i < K; i++)
    for (int j = 0; j < K; j++) (b[i] += a[i][j] * f[j]) %= 998244352;
  for (int i = 0; i < K; i++) f[i] = b[i], b[i] = 0;
}
inline void Mulself() {
  for (int i = 0; i < K; i++)
    for (int j = 0; j < K; j++)
      for (int k = 0; k < K; k++) (c[i][j] += a[i][k] * a[k][j]) %= 998244352;
  for (int i = 0; i < K; i++)
    for (int j = 0; j < K; j++) a[i][j] = c[i][j], c[i][j] = 0;
}
std::map<int, int> h;
inline int BSGS(int x) {
  int t = sqrt(998244353);
  long long mul = x;
  for (int i = 0; i < t; i++) h[mul] = i, (mul *= 3) %= 998244353;
  mul = qpow(3, t);
  long long now = mul;
  for (int i = 1; i <= t + 1; i++)
    if (h.count(now))
      return i * t - h[now];
    else
      (now *= mul) %= 998244353;
  return -1;
}
int main() {
  K = read<int>();
  for (int i = 0; i < K - 1; i++) a[i][i + 1] = 1;
  for (int i = 0; i < K; i++) a[K - 1][K - i - 1] = read<int>();
  f[K - 1] = 1;
  n = read<int>();
  for (n--; n; n >>= 1) {
    if (n & 1) Mul();
    Mulself();
  }
  long long x = BSGS(read<int>());
  long long y = f[0], inv = 0, Y = 0;
  int d = exgcd(y, 998244352, inv, Y);
  if (x % d) return puts("-1"), 0;
  inv = (inv % 998244352 + 998244352) % 998244352;
  printf("%lld\n", qpow(3, x / d * inv % 998244352));
  return 0;
}
