program vredost_dodele;
var i,j,m,n,c,z,x: longint;
var a:array[1..20000000]of longint;
var b:array[1..100000]of longint;
    function stepen(x:longint;y:longint):longint;
    var a,i:longint;
        begin
            a:=1;
            for i:=1 to y do
                a:=a*x;
            stepen:=a;
        end;
    begin
        readln(n,m);
        for i:=1 to m do 
            read(b[i]);
        readln(c);
        for i:=1 to n do 
            a[i]:=i;
        for i:=0 to n-m do
            begin
                for j:=1 to m do
                    a[i+b[j]]:=a[i+j];
            end;
        z:=0;
        for i:=1 to n do
            z:=z+(stepen(c,i)*a[i]);
        x:=z mod 998244353;
        write(x);
    end.