# input = "otDexiRif.rel  dMdaea"
# operations = (('PC',2,4), ('PL',1,3), ('RC',6,2), ('RL',1,4))
# cols = 7

# input = "iuB anC ePeid vgeUnon"
# operations = (('PC',2,4), ('PL',1,3), ('RC',6,2), ('RL',1,4))
# cols = 7

input = "lire dsVl t'e:slaue  lS ah!dceelenr Geseviat1un Lcvavhrh le'tzne nspi ne sp oe s  ulo3gstraseesoocacala eo doi0iu g   rtbhipeore!riCTaovcur ert"
operations = (('RC',8,5), ('PC',3,13), ('RL',11,7), ('RC',10,7), ('PC',12,4), ('RL',6,5), ('PL',2,8), ('PC',1,6), ('PL',3,7), ('RC',2,8), ('RL',1,6), ('PL',4,10), ('RL',9,5), ('PC',11,5), ('RL',5,9), ('PC',7,9), ('RC',11,4), ('PL',11,1), ('RC',11,5), ('PC',8,11))
cols = 13

rows = len(input) // cols

if cols*rows != len(input):
    raise ValueError("cols*rows error")

min_cols = 0
min_rows = 0
for operation in operations:
    ope = operation[0]
    arg1 = operation[1]
    arg2 = operation[2]
    if ope == "PC":
        min_cols = max(min_cols, arg1, arg2)
    elif ope == "PL":
        min_rows = max(min_rows, arg1, arg2)
    elif ope == "RC":
        min_cols = max(min_cols, arg1)
    elif ope == "RL":
        min_rows = max(min_rows, arg1)
    else:
        raise ValueError("incorrect operation " + ope)
if cols < min_cols:
    raise ValueError("min cols error")
if rows < min_rows:
    raise ValueError("min rows error")

def print_table(table):
    for row in range(len(table)):
        for col in range(len(table[row])):
            print(table[row][col], end=" ")
        print("")
    print("")

def pc(col1, col2):
    global table
    for row in table:
        c = row[col1-1]
        row[col1-1] = row[col2-1]
        row[col2-1] = c
    return

def pl(row1, row2):
    global table
    row = table[row1-1].copy()
    table[row1-1] = table[row2-1].copy()
    table[row2-1] = row.copy()
    return

def rc(col, rot):
    global table
    s = list()
    for row in table:
        s.append(row[col-1])
    s = s[rot:]+s[:rot]
    for row in range(len(table)):
        table[row][col-1] = s[row]
    return

def rl(row, rot):
    global table
    table[row-1] = table[row-1][rot:] + table[row-1][:rot]
    return

table = list()
for row in range(rows):
    table.append([None,]*cols)
    
for i in range(len(input)):
    y = i//rows
    x = i%rows
    table[x][y] = input[i]

print_table(table)

for i in range(len(operations)):
    operation = operations[len(operations) - i - 1]
    print(operation)
    ope = operation[0]
    arg1 = operation[1]
    arg2 = operation[2]
    if ope == "PC":
        pc(arg1, arg2)
    elif ope == "PL":
        pl(arg1, arg2)
    elif ope == "RC":
        rc(arg1, arg2)
    elif ope == "RL":
        rl(arg1, arg2)
    print_table(table)
