#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353, SQ = 31596, MOD2 = 998244352;
vector<vector<long long> > ones(int n) {
  vector<vector<long long> > r(n, vector<long long>(n));
  for (int i = (0), qwerty = (n); i < qwerty; i++) r[i][i] = 1;
  return r;
}
long long mult(long long a, long long b, long long m = MOD) {
  return (a * b) % m;
}
vector<vector<long long> > operator*(vector<vector<long long> > &a,
                                     vector<vector<long long> > &b) {
  int n = int((a).size()), m = int((b[0]).size()), z = int((a[0]).size());
  vector<vector<long long> > r(n, vector<long long>(m));
  for (int i = (0), qwerty = (n); i < qwerty; i++)
    for (int j = (0), qwerty = (m); j < qwerty; j++)
      for (int k = (0), qwerty = (z); k < qwerty; k++)
        r[i][j] += a[i][k] * b[k][j], r[i][j] %= MOD2;
  return r;
}
vector<vector<long long> > be(vector<vector<long long> > b, long long e) {
  vector<vector<long long> > r = ones(int((b).size()));
  while (e)
    if (e & 1)
      r = r * b, e ^= 1;
    else
      b = b * b, e >>= 1;
  return r;
}
long long be(long long b, long long e, long long m = MOD) {
  long long r = 1;
  while (e)
    if (e & 1)
      r = (r * b) % m, e ^= 1;
    else
      b = (b * b) % m, e >>= 1;
  return r;
}
const long long rt = 3;
int k;
long long n, m;
long long discrete_log(long long b, long long a) {
  map<long long, long long> ds;
  for (int x = (0), qwerty = (SQ); x < qwerty; x++)
    ds[mult(a, be(be(b, MOD - 2), x))] = x;
  for (int x = (0), qwerty = (SQ); x < qwerty; x++) {
    long long ts = be(b, SQ * x);
    if (ds.count(ts)) return (SQ * x + ds[ts]) % MOD2;
  }
  return -1;
}
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> k;
  vector<vector<long long> > b(k, vector<long long>(k));
  for (int x = (0), qwerty = (k); x < qwerty; x++) cin >> b[0][x];
  for (int x = (1), qwerty = (k); x < qwerty; x++) b[x][x - 1] = 1;
  cin >> n >> m;
  b = be(b, n - k);
  long long ts = discrete_log(3, m);
  while (ts == -1)
    ;
  long long phi_mod1 = 402653184;
  long long g = gcd(ts, b[0][0]);
  if (g) {
    ts /= g;
    b[0][0] /= g;
  } else {
    cout << "1\n";
    exit(0);
  }
  if (ts == -1 || gcd(MOD - 1, b[0][0]) > 1)
    cout << "-1\n";
  else
    cout << be(3, (ts * be(b[0][0], phi_mod1 - 1, MOD - 1)) % (MOD - 1))
         << "\n";
}
