#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    long long n, m, c;
    cin >> n >> m;
    long long* b = new long long[m];
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
    }
    cin >> c;
    long long* a = new long long[n];
    for (int i = 0; i < n; ++i) {
        a[i] = i + 1;
    }
    for (int i = 0; i <= n - m; ++i) {
        for (int j = 0; j < m; ++j) {
            a[i + b[j] - 1] = a[i + j];
        }
    }
    for (int i = 0; i < n; ++i) {
        cout << a[i] << " ";
    }
    cout << endl;
    long long x = 0;
    for (int i = 0; i < n; ++i) {
        x += pow(c, i) * a[i];
    }
    x = abs(x % 998244353);
    cout << x;
}