# Arup Guha
# 2/19/2026
# Code to make a large sample case for my samplemap.c program

import random

# I read these in from a dictionary.
words = []
n = int(input())
for i in range(n):
    w = input().strip()
    if len(w) <= 19:
        words.append(w)

# 1 is add
# 2 is sub
# 3 is query
# 4 is remove

# I add each word twice.
print(2*len(words)+400000)
for i in range(len(words)):
    print(1,words[i])
for i in range(len(words)):
    print(1,words[i])

# I do 100000 random operations.
for i in range(100000):
    x = random.randint(0, len(words)-1)
    choice = random.randint(0,3)

    # 25% chance for each of these.
    if choice == 0:
        print(2,words[choice])
    elif choice == 1:
        print(1,words[choice])
    elif choice == 2:
        print(3,words[choice])
    else:
        print(4,words[choice])

# Put 10 more copies of 10,000 words.
for i in range(10):
    for j in range(10000):
        print(1,words[j])

# More random ops
for i in range(200000):

    x = random.randint(0, len(words)-1)
    choice = random.randint(0,9)

    # 30% del, 20% add, 40% query, 10% remove
    if choice < 3:
        print(2,words[x])
    elif choice < 5:
        print(1,words[x])
    elif choice < 9:
        print(3,words[x])
    else:
        print(4,words[x])
