#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
long long gcd(long long first, long long second) {
  return !second ? first : gcd(second, first % second);
};
long long x, y, z, arr[105];
struct matrix {
  long long Mxpow[105][105];
  matrix(long long s) {
    memset(Mxpow, 0, sizeof(Mxpow));
    for (int i = 1; i <= x; i++) {
      Mxpow[i][i] = s;
    }
  }
  friend matrix operator*(matrix s, matrix ss) {
    matrix p(0);
    for (int i = 1; i <= x; i++) {
      for (int j = 1; j <= x; j++) {
        for (int k = 1; k <= x; k++) {
          (p.Mxpow[i][j] += s.Mxpow[i][k] * ss.Mxpow[k][j]) %= (998244353 - 1);
        }
      }
    }
    return p;
  }
  matrix operator%(long long s) { return *this; }
};
long long power(long long s, long long n, long long MOD) {
  long long ss = 1;
  while (n) {
    if (n & 1) {
      ss = ss * s % MOD;
    }
    n >>= 1, s = s * s % MOD;
  }
  return ss;
}
long long Gen_Out(long long s) {
  long long res = 1, ss = sqrt(998244353);
  map<long long, long long> pq;
  for (int i = 0; i <= ss; i++) {
    pq[res] = i, res = res * 3 % 998244353;
  }
  for (int i = 0; i <= 998244353 / ss + 1; i++) {
    res = power(3, 998244353 - 1 - i * ss % (998244353 - 1), 998244353) * s %
          998244353;
    if (pq[res]) {
      return pq[res] + i * ss;
    }
  }
}
matrix Matrix_Mul(matrix r, long long s, long long MOD) {
  matrix rec(1);
  while (s) {
    if (s & 1) {
      rec = rec * r % MOD;
    }
    s >>= 1;
    r = r * r % MOD;
  }
  return rec;
}
matrix rip(0);
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  cin >> x;
  for (int i = 1; i <= x; i++) {
    cin >> arr[i];
  }
  for (int i = 1; i <= x - 1; i++) {
    rip.Mxpow[i][i + 1] = 1;
  }
  for (int i = 1; i <= x; i++) {
    rip.Mxpow[x][i] = arr[x + 1 - i];
  }
  cin >> z >> y;
  rip = Matrix_Mul(rip, z - x, 998244353 - 1);
  long long gc = gcd(rip.Mxpow[x][x], 998244353 - 1);
  long long inv = power(rip.Mxpow[x][x] / gc, 402653184 - 1, 998244353 - 1);
  long long ind = Gen_Out(y);
  if (ind % gc != 0) {
    cout << -1 << endl;
    return 0;
  }
  ind /= gc;
  cout << power(3, ind * inv, 998244353) % 998244353 << endl;
  return 0;
}
