#include <bits/stdc++.h>
using namespace std;
int get() {
  int x = 0;
  char s = getchar();
  while (s < '0' || s > '9') s = getchar();
  while (s >= '0' && s <= '9')
    x = (x << 3) + (x << 1) + (s ^ 48), s = getchar();
  return x;
}
const int mo = 998244353;
void exgcd(const int a, const int b, int &d, int &x, int &y) {
  if (!b)
    d = a, x = 1, y = 0;
  else {
    exgcd(b, a % b, d, y, x);
    y -= a / b * x;
  }
}
struct Matrix {
  int n, m, c[102][102];
  Matrix() {}
  Matrix(const int nn, const int mm) { n = nn, m = mm, memset(c, 0, sizeof c); }
  int *operator[](const int x) { return c[x]; }
  Matrix operator*(const Matrix a) {
    Matrix r = Matrix(n, a.m);
    for (int i = 1; i <= n; ++i)
      for (int k = 1; k <= m; ++k)
        if (c[i][k])
          for (int j = 1; j <= a.m; ++j)
            r[i][j] = (r[i][j] + 1ll * c[i][k] * a.c[k][j]) % (mo - 1);
    return r;
  }
} A, B;
Matrix pow(Matrix x, int k) {
  Matrix ans = x;
  --k;
  while (k) {
    if (k & 1) ans = ans * x;
    x = x * x;
    k >>= 1;
  }
  return ans;
}
int fpow(int x, int k) {
  int ans = 1;
  while (k) {
    if (k & 1) ans = 1ll * ans * x % mo;
    x = 1ll * x * x % mo;
    k >>= 1;
  }
  return ans;
}
int bsgs(const int b, const int n) {
  map<int, int> mp;
  int m = ceil(sqrt(mo)), tmp = 1;
  for (int i = 1; i <= m; ++i) {
    tmp = 1ll * tmp * b % mo;
    mp[1ll * tmp * n % mo] = i;
  }
  int res = 1;
  for (int i = 1; i <= m; ++i) {
    res = 1ll * res * tmp % mo;
    if (mp[res]) return m * i - mp[res];
  }
  return -1;
}
int main() {
  int k = get(), n, m;
  A = Matrix(1, k);
  B = Matrix(k, k);
  A[1][k] = 1;
  for (int i = 2; i <= k; ++i) B[i][i - 1] = 1;
  for (int i = k; i; --i) B[i][k] = get();
  n = get(), m = get();
  A = A * pow(B, n - k);
  int t = bsgs(3, m), d, y, x;
  exgcd(A[1][k], mo - 1, d, x, y);
  if (t % d)
    printf("-1");
  else {
    x = (1ll * t / d * x % (mo - 1) + mo - 1) % (mo - 1);
    printf("%d", fpow(3, x));
  }
  return 0;
}
