#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > operator*(vector<vector<long long> > A,
                                     vector<vector<long long> > B) {
  int k = A.size();
  vector<vector<long long> > C(k, vector<long long>(k));
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < k; j++) {
      C[i][j] = 0;
      for (int h = 0; h < k; h++) {
        C[i][j] += (A[i][h] * B[h][j]) % (long long)998244352;
        C[i][j] %= (long long)998244352;
      }
    }
  }
  return C;
};
vector<vector<long long> > powmod(vector<vector<long long> > A, long long n) {
  int k = A.size();
  vector<vector<long long> > res(k, vector<long long>(k));
  for (int i = 0; i < k; i++)
    for (int j = 0; j < k; j++) res[i][j] = (i == j) ? 1 : 0;
  while (n) {
    if (n & 1) {
      res = A * res;
      n--;
    } else
      A = A * A, n >>= 1;
  }
  return res;
}
long long powmod(long long a, long long b, long long p) {
  long long res = 1;
  while (b)
    if (b & 1)
      res = (long long)((res * 1ll * a) % p), --b;
    else
      a = (long long)((a * 1ll * a) % p), b >>= 1;
  return res;
}
long long bsgs(long long a, long long m) {
  a %= (long long)998244353;
  m %= (long long)998244353;
  long long n = sqrt((long long)998244353 + .0) + 1;
  map<long long, long long> vals;
  for (long long p = 1; p <= n; p++)
    vals[powmod(a, p * n, (long long)998244353)] = p;
  for (long long q = 0; q < n + 1; q++) {
    long long cur =
        ((powmod(a, q, (long long)998244353)) * m) % (long long)998244353;
    if (vals.count(cur)) {
      long long ans = vals[cur] * n - q;
      return ans;
    }
  }
  return -1;
}
int main() {
  ios_base::sync_with_stdio(false);
  int k;
  cin >> k;
  vector<long long> b(k);
  for (int i = 0; i < k; i++) cin >> b[i];
  long long n, m;
  cin >> n >> m;
  vector<vector<long long> > B(k, vector<long long>(k));
  for (int i = 0; i < k; i++)
    for (int j = 0; j < k; j++) {
      if (i == 0)
        B[i][j] = b[j];
      else
        B[i][j] = (i == j + 1) ? 1 : 0;
    }
  long long p = (powmod(B, n - k)[0][0]);
  long long a = powmod(3, p, (long long)998244353);
  long long c = bsgs(a, m);
  if (c == -1) {
    cout << -1;
    return 0;
  }
  cout << powmod(3, c, (long long)998244353) % (long long)998244353 << endl;
}
