RT
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL read()
{
LL w=0; bool f=true; char c=getchar();
while(!isdigit(c)){if(c=='-')f=false;c=getchar();}
while(isdigit(c))w=(w<<1)+(w<<3)+(c^48),c=getchar();
return f?w:~w+1;
}
const int N=1e5+66,M=1e6+66,Mod=998244353;
int n,m,Q;
LL a[N],flag[N],sum=1;
struct node
{
LL typ,p,v,c;
}t[N];
vector<int>g[N];
struct cz
{
LL typ,pos,val;
}c[M];int tot;
LL mul(LL x,LL y){return (x*y)%Mod;}
LL add(LL x,LL y){return (x+y)%Mod;}
void work(int k)
{
if(t[k].typ==1)
{
c[++tot]=(cz){t[k].typ,t[k].p,t[k].v};
}
if(t[k].typ==2)
{
c[++tot]=(cz){t[k].typ,0,t[k].v};
}
if(t[k].typ==3)
{
for(int i=0;i<t[k].c;++i) work(g[k][i]);
}
}
int main()
{
// freopen("call3.in","r",stdin);
// freopen("call.out","w",stdout);
n=read();
for(int i=1;i<=n;++i) a[i]=read();
m=read();
for(int i=1;i<=m;++i)
{
t[i].typ=read();
if(t[i].typ==1) t[i].p=read(),t[i].v=read();
if(t[i].typ==2) t[i].v=read();
if(t[i].typ==3)
{
t[i].c=read();
for(int j=1;j<=t[i].c;++j) g[i].push_back(read());
}
}
Q=read();
for(int i=1;i<=Q;++i)
{
int f=read();
work(f);
}
for(int i=tot;i>=1;--i)
{
if(c[i].typ==2) sum=mul(sum,c[i].val);
else flag[c[i].pos]=add(flag[c[i].pos],mul(c[i].val,sum));
}
for(int i=1;i<=n;++i) printf("%lld ",add(mul(a[i],sum),flag[i]));
puts("");
fclose(stdin);
fclose(stdout);
return 0;
}