
# read OV-input
# read set size and vector dimension
n, d = map(int, input().split()) 
# read vectors
U = n * [None]
for i in range(n):
    U[i] = input()
V = n * [None]
for i in range(n):
    V[i] = input()

# U[i] is i-th vector. Each U[i] is a 0/1-string. U[i][j] is "0" or "1"
# same for V

################################
# TODO - start
# construct ST-diameter instance
num_vertices = 2
edges = [(0,1)]
S = [0]
T = [1]
k = 0
## TODO - end
################################

# print ST-diameter instance
print(num_vertices, len(S), len(T), k)
for s in S:
    print(s)
for t in T:
    print(t)
for edge in edges:
    print(*edge)
