#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
const long long EULER = 402653184;
const int N = 40000;
long long k, m, n, b[110];
struct mat {
  long long dat[110][110];
  mat() { memset(dat, 0, sizeof dat); }
  mat operator*(mat y) {
    mat tmp;
    for (int i = (1); i <= (k); ++i)
      for (int j = (1); j <= (k); ++j)
        for (int l = (1); l <= (k); ++l) {
          tmp.dat[i][j] += dat[i][l] * y.dat[l][j];
          tmp.dat[i][j] %= (MOD - 1);
        }
    return tmp;
  }
} a;
mat qpow(mat a, int n) {
  mat b;
  for (int i = (1); i <= (100); ++i) b.dat[i][i] = 1;
  for (; n; n >>= 1, a = a * a) {
    if (n & 1) b = b * a;
  }
  return b;
}
long long pw1(long long x, long long n, long long mod) {
  if (n == 0) return 1;
  long long y = pw1(x, n / 2, mod);
  y = y * y % mod;
  if (n & 1)
    return x * y % mod;
  else
    return y;
}
long long GCD(long long x, long long y) {
  long long r = 0;
  while (x) {
    r = y % x, y = x, x = r;
  }
  return y;
}
long long Indr(long long x) {
  long long tmp = 1;
  int M = (int)sqrt(MOD);
  map<long long, int> pws;
  for (int i = (0); i <= (M); ++i) pws[tmp] = i, tmp = tmp * 3 % MOD;
  for (int i = (0); i <= (MOD / M + 1); ++i) {
    tmp = pw1(3, MOD - 1 - i * M % (MOD - 1), MOD) * x % MOD;
    if (pws[tmp]) return pws[tmp] + i * M;
  }
}
int main() {
  cin >> k;
  for (int i = (1); i <= (k); ++i) cin >> b[i];
  for (int i = (1); i <= (k - 1); ++i) a.dat[i][i + 1] = 1;
  for (int i = (1); i <= (k); ++i) a.dat[k][i] = b[k + 1 - i];
  cin >> n >> m;
  a = qpow(a, n - k);
  long long npow = a.dat[k][k];
  long long gcd = GCD(npow, MOD - 1);
  long long invL = pw1(npow / gcd, EULER - 1, MOD - 1);
  long long ind = Indr(m);
  if (ind % gcd != 0) {
    cout << -1 << endl;
    return 0;
  }
  ind /= gcd;
  long long res = pw1(3, ind, MOD);
  cout << pw1(res, invL, MOD) << endl;
  return 0;
}
