#include <iostream>
#include <math.h>
using namespace std;

int main()
{
	int N, M;
	cin >> N; cin >> M;
	int *A = new int[N + 1], *B = new int[M + 1];
	for (int i = 1; i < N + 1; i++)
		A[i] = i;
	for (int i = 1; i < M + 1; i++) 
		cin >> B[i];
	for (int i = 0; i <= N - M; i++)
	{
		for (int j = 1; j <= M; j++)
			A[i + B[j]] = A[i + j];
	}
	int C; 
	cin >> C;
	int sum = 0;
	for (int i = 1; i < N + 1; i++)
		sum += pow(C, i) * A[i];
	cout << sum % 998244353;
	delete[] A;
	delete[] B;
}