import java.util.;
import java.lang.;
import java.io.*;
/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main(String[] args)throws java.lang.Exception
{
// your code goes here
int i,j;
int c,status=0;
Scanner s = new Scanner(System.in);
i= s.nextInt();
j=s.nextInt();
int a[]= new int[i];
for(int k=0;k<i;k++)
{
if(s.hasNextInt())
a[k]=s.nextInt();
}
int k=0;
c=s.nextInt();
while(c!=0)
{
switch(c)
{
case 1:
if(k>0)
k--;
break;
case 2:
if(k<i-1)
k++;
break;
case 3:
if(a[k]>0&&status==0)
{a[k]--;
status =1;}
break;
case 4:
if(a[k]<j&&status==1)
{
a[k]++;
status =0;
}
break;
}
c=s.nextInt();
}
for( j=0;j<i;j++)
{
System.out.print(a[j]+" ");
}
}
}