namespace _02.Lady_Bugs
{
using System;
using System.Linq;
public class Program
{
public static void Main()
{
var sizeList = int.Parse(Console.ReadLine());
var inputLadybugIndexes = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var param = Console.ReadLine().Split(' ').ToArray();
var array = new int[sizeList];
//setting the indexes of the ladybugs
foreach (var index in inputLadybugIndexes)
{
if (index >= 0 && index < array.Length)
{
array[index] = 1;
}
}
while (param[0] != "end")
{
var ladybugIndex = int.Parse(param[0]);
var direction = param[1];
var flyLength = int.Parse(param[2]);
//if there is a ladybug at the inputted index:
if (ladybugIndex >= 0 && ladybugIndex < array.Length && array[ladybugIndex] == 1)
{
array[ladybugIndex] = 0;
if (direction == "right")
{
MoveToRight(flyLength, ladybugIndex, array);
}
else
{
MoveToLeft(flyLength, ladybugIndex, array);
}
}
param = Console.ReadLine().Split(' ').ToArray();
}
Console.WriteLine(string.Join(" ", array));
}
static void MoveToRight(int flyLength, int ladybugIndex, int[] array)
{
if (flyLength >= 0)
{
while (ladybugIndex + flyLength < array.Length)
{
if (array[ladybugIndex + flyLength] != 1)
{
array[ladybugIndex + flyLength] = 1;
break;
}
ladybugIndex++;
}
}
else
{
while (ladybugIndex - Math.Abs(flyLength) < array.Length && ladybugIndex - Math.Abs(flyLength) >= 0)
{
if (array[ladybugIndex - Math.Abs(flyLength)] != 1)
{
array[ladybugIndex - Math.Abs(flyLength)] = 1;
break;
}
ladybugIndex--;
}
}
}
static void MoveToLeft(int flyLength, int ladybugIndex, int[] array)
{
if (flyLength >= 0)
{
while (ladybugIndex - flyLength < array.Length && ladybugIndex - flyLength >= 0)
{
if (array[ladybugIndex - flyLength] != 1)
{
array[ladybugIndex - flyLength] = 1;
break;
}
ladybugIndex--;
}
}
else
{
while (ladybugIndex + Math.Abs(flyLength) < array.Length && ladybugIndex + Math.Abs(flyLength) >= 0)
{
if (array[ladybugIndex + Math.Abs(flyLength)] != 1)
{
array[ladybugIndex + Math.Abs(flyLength)] = 1;
break;
}
ladybugIndex++;
}
}
}
}
}