#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int n, m, c;
    long long x = 0;
    
    cin >> n;
    cin >> m;

    int b[n], a[n];

    for(int i = 1; i <= m; ++i)
        cin >> b[i];

    cin >> c;

    for(int i = 1; i <= n; ++i)
        a[i] = i;

    for(int i = 0; i <= n-m; ++i)
    {
        for(int j = 1; j <= m; ++j)
        {
            a[i + b[j]] = a[i + j];
        }
    }

    for(int i = 1; i <= n; ++i)
        cout << a[i] << endl;

    for(int i = 1; i <= n; ++i)
    {
        x += pow(c, i) * a[i];
        x = x % 998244353;
    }
    cout << x << endl;
    return 0;
}