#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
vector<vector<long long>> matrixMult(const vector<vector<long long>> A,
                                     const vector<vector<long long>> B) {
  assert(!A.empty() && A[0].size() == B.size());
  vector<vector<long long>> C(A.size(), vector<long long>(B[0].size(), 0));
  for (int i = 0; i < (int)C.size(); ++i)
    for (int j = 0; j < (int)C[0].size(); ++j)
      for (int k = 0; k < (int)A[0].size(); ++k)
        C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % (mod - 1);
  return C;
}
vector<vector<long long>> matrixIdentity(const int n) {
  vector<vector<long long>> M(n, vector<long long>(n, 0));
  for (int i = 0; i < n; ++i) M[i][i] = 1;
  return M;
}
vector<vector<long long>> matrixPow(vector<vector<long long>> A, long long k) {
  auto B = k > 0 ? --k, A : matrixIdentity(A.size());
  for (; k; k >>= 1) {
    if (k & 1) B = matrixMult(A, B);
    A = matrixMult(A, A);
  }
  return B;
}
long long extGCD(long long a, long long b, long long &x, long long &y) {
  if (!b) {
    x = 1;
    y = 0;
    return a;
  }
  long long q = extGCD(b, a % b, y, x);
  y -= a / b * x;
  return q;
}
namespace BSGS {
long long qpow(long long a, long long b, const long long p) {
  long long res = 1;
  while (b) {
    if (b & 1) (res *= a) %= p;
    (a *= a) %= p;
    b >>= 1;
  }
  return res;
}
long long inv(const long long x, const long long p) {
  return qpow(x, p - 2, p);
}
long long bsgs(long long a, long long b, const long long p) {
  a = (a % p + p) % p;
  b = (b % p + p) % p;
  const long long u = (long long)sqrt(p) + 1;
  map<long long, long long> tab;
  long long now = 1;
  for (long long i = 0; i < u; i++) {
    const long long tmp = b * inv(now, p) % p;
    if (!tab.count(tmp)) tab[tmp] = i;
    (now *= a) %= p;
  }
  const long long step = now;
  now = 1;
  for (long long i = 0; i < p; i += u) {
    if (tab.count(now)) return i + tab[now];
    (now *= step) %= p;
  }
  assert(false);
  return -1;
}
}  // namespace BSGS
long long modPow(long long n, long long k) {
  long long res = 1;
  for (n %= mod; k; k >>= 1) {
    if (k & 1) res = res * n % mod;
    n = n * n % mod;
  }
  return res;
}
long long q(const long long x) {
  long long res = BSGS::bsgs(3, x, mod);
  assert((modPow(3, res) - x) % mod == 0);
  return res;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  int k;
  cin >> k;
  vector<long long> b(k);
  for (long long &x : b) cin >> x;
  vector<vector<long long>> M(k, vector<long long>(k, 0));
  for (int i = 1; i < k; ++i) M[i][i - 1] = 1;
  for (int i = 0; i < k; ++i) M[i][k - 1] = b[k - 1 - i];
  vector<vector<long long>> u(1, vector<long long>(k, 0));
  u.back().back() = 1;
  long long n, m;
  cin >> n >> m;
  M = matrixPow(M, n - 1);
  u = matrixMult(u, M);
  const long long pw = u[0][0];
  cerr << "pw"
       << " = " << (pw) << endl;
  const long long q_m = q(m);
  long long q_x = 0, _y = 0;
  const long long g = extGCD(pw, mod - 1, q_x, _y);
  assert(q_x * pw + _y * (mod - 1) == g);
  if (q_m % g) {
    cout << -1;
    return 0;
  }
  q_x %= mod - 1;
  if (q_x < 0) q_x += mod - 1;
  q_x *= q_m / g;
  q_x %= mod - 1;
  cout << modPow(3, q_x) << endl;
  assert((q_x * pw - q_m) % (mod - 1) == 0);
  return 0;
}
