#include <bits/stdc++.h>
using namespace std;
long long mpow(long long a, long long b, long long mod) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}
int mlog(long long r, long long b, long long mod) {
  map<long long, int> mp;
  for (int i = 99999; i >= 0; i--) {
    mp[mpow(r, i, mod)] = i;
  }
  for (int i = 0; i < mod - 1; i += 100000) {
    if (mp.count(b * mpow(r, mod - 1 - i, mod) % mod)) {
      return i + mp[b * mpow(r, mod - 1 - i, mod) % mod];
    }
  }
  return -1;
}
vector<long long> pmod(vector<long long> a, vector<long long> p,
                       long long mod) {
  const int n = a.size();
  const int m = p.size();
  for (int i = n - 1; i >= m; i--) {
    for (int j = 0; j < m; j++) {
      a[i - m + j] += a[i] * p[j];
      a[i - m + j] %= mod;
    }
  }
  a.resize(m);
  return a;
}
vector<long long> pmul(vector<long long> a, vector<long long> b,
                       vector<long long> p, long long mod) {
  const int n = a.size();
  const int m = b.size();
  vector<long long> c(n + m - 1);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      c[i + j] += a[i] * b[j];
      c[i + j] %= mod;
    }
  }
  return pmod(c, p, mod);
}
vector<long long> ppow(vector<long long> a, long long b, vector<long long> p,
                       long long mod) {
  vector<long long> res(1, 1);
  while (b > 0) {
    if (b & 1) res = pmul(res, a, p, mod);
    a = pmul(a, a, p, mod);
    b >>= 1;
  }
  return res;
}
long long extgcd(long long a, long long b, long long c, long long mod) {
  long long s = 1;
  long long t = 0;
  while (b != 0) {
    long long q = a / b;
    a -= b * q;
    s -= t * q;
    swap(a, b);
    swap(s, t);
  }
  if (c % a != 0) return -1;
  if (s < 0) s += mod;
  return c / a * s % mod;
}
int main() {
  int K;
  long long N, M;
  scanf("%d", &K);
  vector<long long> p(K);
  for (int i = K - 1; i >= 0; i--) {
    scanf("%lld", &p[i]);
    p[i] %= 998244353 - 1;
  }
  scanf("%lld %lld", &N, &M);
  N--;
  M = mlog(3, M, 998244353);
  vector<long long> a(2);
  a[1] = 1;
  a = ppow(a, N, p, 998244353 - 1);
  long long ans = extgcd(a[K - 1], 998244353 - 1, M, 998244353 - 1);
  if (ans == -1) {
    puts("-1");
  } else {
    ans = mpow(3, ans, 998244353);
    printf("%lld\n", ans);
  }
  return 0;
}
