import sys sys.setrecursionlimit(1000000000) # # Solution Template for Human LCD II # # Australian Informatics Olympiad 2026 Invitationals # # This file is provided to assist with reading of input and writing of output # for the problem. You may modify this file however you wish, or # you may choose not to use this file at all. # # R and C are the dimensions of the display; R * C is at most 1000. R = 0 C = 0 # A and B contain the initial and target colours. Both lists start from 0. A = [] B = [] # The ith instruction changes cell (X[i], Y[i]) to colour V[i]; coordinates are # 1-based. L = 0 X = [] Y = [] V = [] # Read the two R by C grids. R, C = map(int, input().strip().split()) for i in range(0, R): A.append(list(map(int, input().strip().split()))) for i in range(0, R): B.append(list(map(int, input().strip().split()))) # TODO: Construct at most one million legal instructions transforming A into B. # For full marks, minimise the number of instructions. # An empty instruction sequence is shown below; it is correct only when A # equals B. print(L) for i in range(0, L): print(X[i], Y[i], V[i])