#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353, Mo = 100003;
int n, m, k;
struct Matrix {
  int a[103][103];
  Matrix() { memset(a, 0, sizeof(a)); }
  int *operator[](int x) { return a[x]; }
  Matrix operator*(Matrix A) {
    Matrix C;
    for (int w = 1; w <= k; w++)
      for (int i = 1; i <= k; i++)
        for (int j = 1; j <= k; j++)
          (C[i][j] += 1ll * a[i][w] * A[w][j] % (mod - 1)) %= (mod - 1);
    return C;
  }
} Ans, Base;
int ksm(int x, int k) {
  int s = 1;
  for (; k; k >>= 1, x = 1ll * x * x % mod)
    if (k & 1) s = 1ll * s * x % mod;
  return s;
}
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
void exgcd(int a, int b, int &x, int &y) {
  if (!b)
    x = 1, y = 0;
  else
    exgcd(b, a % b, y, x), y -= a / b * x;
}
struct Hstb {
  vector<pair<int, int> > H[Mo];
  void ins(int x, int i) { H[x % Mo].push_back(make_pair(x, i)); }
  int find(int x) {
    for (auto w : H[x % Mo])
      if (w.first == x) return w.second;
    return -1;
  }
} Hs;
int BSGS(int g, int A, int P) {
  int M = sqrt(P);
  for (int i = 0, tt = A; i <= M; i++, tt = 1ll * tt * g % P) Hs.ins(tt, i);
  for (int i = 1, bs = ksm(g, M), tt = bs; i <= M + 1;
       i++, tt = 1ll * tt * bs % P)
    if (Hs.find(tt) != -1) return i * M - Hs.find(tt);
  return -1;
}
signed main() {
  cin >> k;
  for (int i = 1; i <= k; i++) cin >> Base[k - i + 1][k];
  for (int i = 2; i <= k; i++) Base[i][i - 1] = 1;
  Ans[1][k] = 1;
  cin >> n >> m;
  n--;
  for (; n; n >>= 1, Base = Base * Base)
    if (n & 1) Ans = Ans * Base;
  int r = BSGS(3, m, mod);
  int a = Ans[1][1], b = mod - 1, g = gcd(a, b), x, y;
  if (r % g) return puts("-1"), 0;
  a /= g, b /= g;
  r /= g;
  exgcd(a, b, x, y);
  x = 1ll * x * r % (mod - 1);
  int c = (x + mod - 1) % (mod - 1);
  x = ksm(3, c);
  cout << x << endl;
}
