#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int g = 3;
long long qpow(long long a, long long b, long long m) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long exgcd(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  long long d = exgcd(b, a % b, y, x);
  y -= (a / b) * x;
  return d;
}
long long inv(long long a, long long m) {
  long long x1, x2;
  long long d = exgcd(a, m, x1, x2);
  if (d > 1) return -1;
  x1 = ((x1 % m) + m) % m;
  return x1;
}
long long ex_bsgs(long long a, long long b, long long m) {
  if (a % m == 0 && b) return -1;
  long long k = 0;
  long long ak = 1;
  long long d;
  while ((d = gcd(a, m)) > 1) {
    if (b % d) return -1;
    m /= d, b /= d;
    ak = ak * (a / d) % m;
    k++;
    if (ak == b) return k;
  }
  long long inva = inv(ak, m);
  b = inva * b % m;
  long long n = ceil(sqrt(m));
  long long bn = b;
  map<long long, int> MP;
  for (int i = 0; i <= n; i++) {
    MP[bn] = i;
    bn = bn * a % m;
  }
  long long an = qpow(a, n, m);
  long long atn = 1;
  for (int i = 1; i <= n; i++) {
    atn = atn * an % m;
    if (MP.find(atn) != MP.end()) return i * n - MP[atn] + k;
  }
  return -1;
}
const int maxn = 105;
struct matrix {
  int r, c;
  int m[maxn][maxn];
  matrix(int a, int b) {
    r = a, c = b;
    memset(m, 0, sizeof(m));
  }
  matrix(const matrix &m1) {
    r = m1.r, c = m1.c;
    for (int i = 1; i <= r; i++)
      for (int j = 1; j <= c; j++) m[i][j] = m1.m[i][j];
  }
  matrix operator*(const matrix &b) const {
    matrix ans(r, b.c);
    for (int i = 1; i <= r; i++) {
      for (int j = 1; j <= b.c; j++) {
        for (int k = 1; k <= c; k++) {
          ans.m[i][j] += (1ll * m[i][k] * b.m[k][j]) % (mod - 1);
          if (ans.m[i][j] >= (mod - 1)) ans.m[i][j] -= (mod - 1);
        }
      }
    }
    return ans;
  }
  matrix qpow(int q) {
    matrix ans(r, c);
    matrix a = *this;
    for (int i = 1; i <= a.r; i++) ans.m[i][i] = 1;
    while (q) {
      if (q & 1) ans = ans * a;
      q >>= 1;
      a = a * a;
    }
    return ans;
  }
};
int main() {
  int k;
  cin >> k;
  vector<int> b(k + 1);
  for (int i = 1; i <= k; i++) cin >> b[i];
  long long n, m;
  cin >> n >> m;
  long long hn = ex_bsgs(g, m, mod);
  matrix M(k, k);
  for (int i = 2; i <= k; i++) M.m[i][i - 1] = 1;
  for (int i = 1; i <= k; i++) M.m[1][i] = b[i];
  matrix ans = M.qpow((n - k));
  long long x1, x2;
  long long d = exgcd(ans.m[1][1], mod - 1, x1, x2);
  if (hn % d) {
    cout << -1 << endl;
    return 0;
  }
  x1 *= (hn) / d;
  long long wd = (mod - 1) / d;
  x1 = (x1 % wd + wd) % wd;
  long long res = qpow(g, x1, mod);
  cout << res << endl;
  return 0;
}
