#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e2 + 9, maxV = 200 + 9, MOD = 998244353, AND = (1 << 20) - 1,
          lg = 20;
int n, k, m;
vector<vector<long long>> operator*(const vector<vector<long long>> &one,
                                    const vector<vector<long long>> &two) {
  vector<vector<long long>> ret(one.size(), vector<long long>(two[0].size()));
  for (int i = 0; i < one.size(); i++)
    for (int j = 0; j < two[0].size(); j++)
      for (int u = 0; u < two.size(); u++)
        ret[i][j] = (ret[i][j] + one[i][u] * two[u][j]) % (MOD - 1);
  return ret;
}
vector<vector<long long>> operator^(vector<vector<long long>> a, int b) {
  vector<vector<long long>> ret(k, vector<long long>(k));
  for (int i = 0; i < k; i++) ret[i][i] = 1;
  while (b) {
    if (b & 1) ret = ret * a;
    b >>= 1;
    a = a * a;
  }
  return ret;
}
long long fastPow(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return ret;
}
int solv(long long a, long long b) {
  const int limit = 40000;
  map<int, int> mp;
  for (int i = 0; i <= limit; i++) mp[b * fastPow(a, i) % MOD] = i;
  for (int i = 1; i < MOD + limit; i += limit)
    if (mp.find((int)fastPow(a, i)) != mp.end())
      return (MOD - 1 + i - mp[(int)fastPow(a, i)]) % (MOD - 1);
  return -1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> k;
  vector<vector<long long>> base(k, vector<long long>(k));
  for (int i = 0; i < k; i++) cin >> base[0][i], base[0][i] %= MOD - 1;
  for (int i = 1; i < k; i++) base[i][i - 1] = 1;
  cin >> n >> m;
  n -= k;
  vector<vector<long long>> start(k, vector<long long>({0}));
  start[0][0] = 1;
  vector<vector<long long>> ending = (base ^ n) * start;
  long long ende = ending[0][0];
  int logar = solv(fastPow(3, ende), m);
  if (logar == -1) {
    cout << "-1\n";
    return 0;
  }
  cout << fastPow(3, logar) << '\n';
}
