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


int main(){
   signed long long int c;
	signed long long int i,j;
	signed long long int n,m;
cin>>n>>m;
signed long long int nizB[m];
signed long long int nizA[n];

for(i=1; i<=m; i++){
	cin>>nizB[i];
}
cin>>c;
for(i=1; i<=n; i++){
	nizA[i]=i;
}


for(i=0; i<=(n-m); i++){
	for(j=1; j<=m; j++){
		nizA[i+nizB[j]] = nizA[i+j];
                    	}   } 
              	for(i=1; i<=n; i++){
	cout<<nizA[i]<<" ";
}

signed long long int x;
signed long long int s=0;
for(i=1; i<=n; i++){
	
	s=s+(pow(c,i) * nizA[i]);
cout<<s<<" ";
}

x=s % 998244353;
cout<<x;



}