#include <bits/stdc++.h>
using namespace std;
namespace IO {
template <class T>
inline void readin(T& x) {
  char c;
  bool f = 0;
  while ((c = getchar()) < '0' || '9' < c) f |= (c == '-');
  for (x = (c ^ 48); '0' <= (c = getchar()) && c <= '9';
       x = (x << 1) + (x << 3) + (c ^ 48))
    ;
  if (f) x = -x;
}
template <class T>
inline T readin(T x) {
  x = 0;
  char c;
  bool f = 0;
  while ((c = getchar()) < '0' || '9' < c) f |= (c == '-');
  for (x = (c ^ 48); '0' <= (c = getchar()) && c <= '9';
       x = (x << 1) + (x << 3) + (c ^ 48))
    ;
  return f ? -x : x;
}
template <class T>
void fwrit(const T x) {
  if (x < 0) return (void)(putchar('-'), fwrit(-x));
  if (x > 9) fwrit(x / 10);
  putchar(x % 10 ^ 48);
}
template <class T>
inline T Max(const T x, const T y) {
  return x < y ? y : x;
}
template <class T>
inline T Min(const T x, const T y) {
  return x < y ? x : y;
}
template <class T>
inline T fab(const T x) {
  return x > 0 ? x : -x;
}
inline int gcd(const int a, const int b) { return b ? gcd(b, a % b) : a; }
inline void getInv(int inv[], const int lim, const int MOD) {
  inv[0] = inv[1] = 1;
  for (int i = 2; i <= lim; ++i)
    inv[i] = 1ll * inv[MOD % i] * (MOD - MOD / i) % MOD;
}
inline long long mulMod(const long long a, const long long b,
                        const long long mod) {
  return ((a * b - (long long)((long double)a / mod * b + 1e-8) * mod) % mod +
          mod) %
         mod;
}
}  // namespace IO
using namespace IO;
const int maxk = 100;
const int mod = 998244353;
const int phimod = mod - 1;
inline int qkpow(int a, int n) {
  int ret = 1;
  for (; n > 0; n >>= 1, a = 1ll * a * a % mod)
    if (n & 1) ret = 1ll * ret * a % mod;
  return ret;
}
map<int, int> MP;
inline int bsgs(const int a, const int x, const int p) {
  int m = ceil(sqrt(p)), base = 1, tmp = 1;
  for (signed i = (1), i_end_ = (m); i <= i_end_; ++i) {
    base = 1ll * base * a % p;
    MP[1ll * base * x % p] = i;
  }
  for (signed i = (1), i_end_ = (m); i <= i_end_; ++i) {
    tmp = 1ll * tmp * base % p;
    if (MP[tmp]) return i * m - MP[tmp];
  }
  return -1;
}
struct matrix {
  int a[maxk + 5][maxk + 5], n, m;
  matrix(const int N = 0, const int M = 0) : n(N), m(M) {
    memset(a, 0, sizeof a);
  }
  inline void origin(const int N) {
    (*this) = matrix(N, N);
    for (signed i = (1), i_end_ = (n); i <= i_end_; ++i) a[i][i] = 1;
  }
  inline matrix operator*(const matrix rhs) const {
    if (m != rhs.n) {
      cout << "operator:>Error\n";
      exit(0);
    }
    matrix ret(n, rhs.m);
    for (signed i = (1), i_end_ = (n); i <= i_end_; ++i)
      for (signed j = (1), j_end_ = (m); j <= j_end_; ++j)
        if (a[i][j])
          for (signed k = (1), k_end_ = (rhs.m); k <= k_end_; ++k)
            ret.a[i][k] =
                (ret.a[i][k] + 1ll * a[i][j] * rhs.a[j][k] % phimod) % phimod;
    return ret;
  }
  inline void print() {
    cout << "Print:>n == " << n << ", m == " << m << '\n';
    for (signed i = (1), i_end_ = (n); i <= i_end_; ++i) {
      for (signed j = (1), j_end_ = (m); j <= j_end_; ++j)
        cout << a[i][j] << " ";
      cout << '\n';
    }
  }
  inline friend matrix qkpow(matrix a, int n) {
    if (a.n != a.m) {
      cout << "qkpow:>Error\n";
      exit(0);
    }
    matrix ret;
    ret.origin(a.n);
    for (; n > 0; n >>= 1, a = a * a)
      if (n & 1) ret = ret * a;
    return ret;
  }
};
int k, b[maxk + 5], n, m;
matrix ori, acc;
inline void Init() {
  cin >> k;
  for (signed i = (1), i_end_ = (k); i <= i_end_; ++i)
    cin >> b[i], b[i] %= phimod;
  cin >> n >> m;
}
inline int Get_exponent() {
  ori = matrix(1, k), acc = matrix(k, k);
  ori.a[1][k] = 1;
  for (signed i = (2), i_end_ = (k); i <= i_end_; ++i) acc.a[i][i - 1] = 1;
  for (signed i = (1), i_end_ = (k); i <= i_end_; ++i)
    acc.a[i][k] = b[k - i + 1];
  ori = ori * qkpow(acc, n - k);
  return ori.a[1][k];
}
int exgcd(const int a, const int b, int& x, int& y) {
  if (!b)
    return x = 1, y = 0, a;
  else {
    int d = exgcd(b, a % b, y, x);
    y -= (a / b) * x;
    return d;
  }
}
signed main() {
  Init();
  int exp = Get_exponent();
  int x = bsgs(qkpow(3, exp), m, mod);
  if (x == -1)
    cout << "-1\n";
  else
    cout << qkpow(3, x) << '\n';
  return 0;
}
