l = [[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0]]
l[0][0] = 1
x = 0
y = 0

def afficher():
    for a in l:
        print(a, "\n")

afficher()

while True:

    i = input()

    if i =="d" and x < 4:
        l[y][x]= 0
        x += 1
        l[y][x]= 1
    elif i =="q" and x > 0:
        l[y][x] = 0
        x -= 1
        l[y][x] = 1
    elif i == "z" and y > 0:
        l[y][x] = 0
        y -= 1
        l[y][x] = 1
    elif i == "s" and y < 4:
        l[y][x] = 0
        y += 1
        l[y][x] = 1
    afficher()