#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long mod = 998244353;
const int maxn = 105;
int N, M, K, b[maxn];
struct Ma {
  long long m[maxn][maxn];
  Ma() { clear(); }
  void clear() { memset((m), 0, sizeof(m)); }
  void init() {
    for (int i = 1; i <= K; i++) m[i][i] = 1;
  }
  Ma operator*(Ma &T) {
    Ma re;
    for (int i = 1; i <= K; i++)
      for (int j = 1; j <= K; j++)
        for (int k = 1; k <= K; k++)
          re.m[i][j] += m[i][k] * T.m[k][j] % (mod - 1),
              re.m[i][j] %= (mod - 1);
    return re;
  }
};
long long qp(long long x, long long n) {
  long long re = 1;
  while (n) {
    if (n & 1) re = re * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return re;
}
long long BSGS(long long a, long long b) {
  map<long long, long long> tab;
  long long u = (long long)ceil(sqrt(mod));
  long long now = 1, step;
  for (long long i = 0; i < u; i++) {
    long long tem = b * qp(now, mod - 2) % mod;
    if (!tab.count(tem)) tab[tem] = i;
    now = now * a % mod;
  }
  step = now;
  now = 1;
  for (int i = 0; i < mod; i += u) {
    if (tab.count(now)) return i + tab[now];
    now = now * step % mod;
  }
  return -1;
}
long long gcd(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  long long re = gcd(b, a % b, y, x);
  y -= a / b * x;
  return re;
}
long long solve2(long long p) {
  long long b = BSGS(3, M);
  long long x, y, d = gcd(p, mod - 1, x, y);
  if (b % d) return -1;
  x = (x * b / d % (mod - 1) + mod - 1) % (mod - 1);
  return qp(3, x);
}
Ma qp(Ma t, long long n) {
  Ma re;
  re.init();
  while (n) {
    if (n & 1) re = re * t;
    t = t * t;
    n >>= 1;
  }
  return re;
}
long long solve1() {
  Ma A;
  for (int i = 1; i <= K - 1; i++) A.m[i + 1][i] = 1;
  for (int i = 1; i <= K; i++) A.m[i][K] = b[K - i + 1];
  A = qp(A, N - 1);
  return A.m[K][1];
}
int main() {
  scanf("%d", &K);
  for (int i = 1; i <= K; i++) scanf("%d", &b[i]);
  scanf("%d%d", &N, &M);
  long long p = solve1();
  printf("%d\n", solve2(p));
}
