#include <bits/stdc++.h>
using namespace std;
const long long primo = 998244353;
const long long m = 110;
const long long mod = primo - 1;
long long x;
struct Matrix {
  long long mat[m][m];
  Matrix operator*(const Matrix &p) {
    Matrix ans;
    for (long long i = 0; i < x; i++)
      for (long long j = 0; j < x; j++)
        for (long long k = ans.mat[i][j] = 0; k < x; k++)
          ans.mat[i][j] = (ans.mat[i][j] + mat[i][k] * p.mat[k][j]) % mod;
    return ans;
  }
};
Matrix fExp(Matrix a, long long b) {
  Matrix ans;
  for (long long i = 0; i < m; i++)
    for (long long j = 0; j < m; j++) ans.mat[i][j] = i == j;
  while (b) {
    if (b & 1) ans = ans * a;
    a = a * a;
    b >>= 1;
  }
  return ans;
}
long long fexp(long long a, long long b, long long mod) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}
long long discreteLog(long long a, long long b, long long m) {
  a %= m;
  b %= m;
  long long n = (long long)sqrt(m + .0) + 1, an = 1;
  for (long long i = 0; i < n; i++) {
    an = (an * a) % m;
  }
  map<long long, long long> vals;
  for (long long i = 1, cur = an; i <= n; i++) {
    if (!vals.count(cur)) vals[cur] = i;
    cur = (cur * an) % m;
  }
  long long ans = 1e18;
  for (long long i = 0, cur = b; i <= n; i++) {
    if (vals.count(cur)) {
      ans = min(ans, vals[cur] * n - i);
    }
    cur = (cur * a) % m;
  }
  return ans;
}
long long primitiveRoot(long long p) {
  vector<long long> fact;
  long long phi = p - 1, n = phi;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      fact.push_back(i);
      while (n % i == 0) {
        n /= i;
      }
    }
  }
  if (n > 1) {
    fact.push_back(n);
  }
  for (long long res = 2; res <= p; res++) {
    bool ok = true;
    for (auto it : fact) {
      ok &= fexp(res, phi / it, p) != 1;
      if (!ok) {
        break;
      }
    }
    if (ok) {
      return res;
    }
  }
  return -1;
}
long long discreteRoot(long long k, long long a, long long mod) {
  long long g = primitiveRoot(mod);
  long long y = discreteLog(fexp(g, k, mod), a, mod);
  if (y == -1) {
    return y;
  }
  long long ans = fexp(g, y, mod);
  return fexp(ans, k, mod) == a ? ans : -1;
}
int32_t main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cin >> x;
  Matrix base;
  for (long long i = 0; i < x; i++)
    for (long long j = 0; j < x; j++) {
      base.mat[i][j] = (i == j + 1);
    }
  for (long long i = 0; i < x; i++) cin >> base.mat[0][i];
  long long n, res;
  cin >> n >> res;
  base = fExp(base, n - 1);
  long long exp = base.mat[x - 1][0];
  long long ans = discreteRoot(exp, res, primo);
  cout << (fexp(ans, exp, primo) == res ? ans : -1) << endl;
}
