m,n = map(int,input().split()) a = [input().split() for x in range(5)] a[m-1],a[n-1] = a[n-1],a[m-1] for row in a: print(*row)