#include <bits/stdc++.h>
using ll = long long;
ll modpow(ll x, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) (res *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return res;
}
ll baby_step_giant_step(ll a, ll b, ll p) {
  ll res = -1;
  const ll m = std::sqrt(p) + 1;
  std::map<ll, ll> table;
  for (ll i = 0, z = 1, t = modpow(a, m, p); i < m; ++i) {
    table[z] = i;
    z = (z * t) % p;
  }
  ll z = b * modpow(a, p - m, p) % p;
  for (int i = m - 1; i >= 0; --i) {
    if (table.count(z) == 1) {
      res = m * table[z] + i;
      break;
    }
    z = (z * a) % p;
  }
  return res;
}
using namespace std;
using matrix = vector<vector<ll>>;
constexpr int mod = 998244353;
matrix operator*(matrix const& a, matrix const& b) {
  const int n = a.size();
  matrix res(n, vector<ll>(n));
  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        (res[i][j] += a[i][k] * b[k][j]) %= (mod - 1);
      }
    }
  }
  return res;
}
matrix matpow(matrix x, ll n) {
  matrix res(x.size(), vector<ll>(x.size()));
  for (int i = 0; i < (int)x.size(); ++i) {
    res[i][i] = 1;
  }
  while (n > 0) {
    if (n & 1) res = res * x;
    x = x * x;
    n >>= 1;
  }
  return res;
}
int main() {
  int k;
  cin >> k;
  vector<ll> b(k);
  for (int i = 0; i < k; ++i) {
    cin >> b[i];
  }
  ll n, m;
  cin >> n >> m;
  matrix A;
  A.push_back(b);
  for (int i = 0; i < k - 1; ++i) {
    vector<ll> a(k);
    a[i] = 1;
    A.push_back(a);
  }
  const ll s = matpow(A, n - k)[0][0];
  const ll x = modpow(3, s, mod);
  const ll z = baby_step_giant_step(x, m, mod);
  if (z < 0) {
    cout << -1 << endl;
  } else {
    cout << modpow(3, z, mod) << endl;
  }
}
