For this Question: You are given a matrix <b>A</b> of dimensions <b>n x m</b>. The task is to perform <b>boundary traversal</b> on the matrix in clockwise manner.The first line of input contains T denoting the number of testcases. T testcases follow. Each testcase has two lines of input. The first line contains dimensions of the matrix A, n and m. The second line contains n*m elements separated by spaces.

Constraints:
1 <= T <= 100
1 <= n, m <= 30
0 <= A[i][j] <= 100For each testcase, in a new line, print the boundary traversal of the matrix A.Input:
4
4 4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
3 4
12 11 10 9 8 7 6 5 4 3 2 1
1 4
1 2 3 4
4 1
1 2 3 4

Output:
1 2 3 4 8 12 16 15 14 13 9 5
12 11 10 9 5 1 2 3 4 8
1 2 3 4
1 2 3 4

Explanation:
Testcase1: The matrix is:
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
The boundary traversal is 1 2 3 4 8 12 16 15 14 13 9 5
Testcase 2: Boundary Traversal will be 12 11 10 9 5 1 2 3 4 8.
Testcase 3: Boundary Traversal will be 1 2 3 4.
Testcase 4: Boundary Traversal will be 1 2 3 4., I have written this Solution Code: 

def boundaryTraversal(matrix, N, M): #N = 3, M = 4
	start_row = 0
	start_col = 0
	count = 0
	if N != 1 and M != 1:
		total = 2 * (N - 1) + 2 * (M - 1)
	else:
		total = max(M, N)

	#First row
	for i in range(start_col, M, 1): #0,1, 2, 3
		count += 1
		print(matrix[start_row][i], end = " ")
	
	if count == total:
		return
	
	start_row += 1

	#Last column
	for i in range(start_row, N, 1): # 1, 2
		count += 1
		print(matrix[i][M - 1], end = " ")
	
	if count == total:
		return
	
	M -= 1
	
	#Last Row
	for i in range(M - 1, start_col - 1, -1): # 2, 1, 0
		count += 1
		print(matrix[N - 1][i], end = " ")
	
	if count == total:
		return
	
	#First Column
	N -= 1 # 2
	for i in range(N - 1, start_row - 1, -1):
		count += 1
		print(matrix[i][start_col], end = " ")
	
	start_col += 1
	
	

testcase = int(input().strip())
for test in range(testcase):
	dim = input().strip().split(" ")
	N = int(dim[0])
	M = int(dim[1])

	matrix = []
	elements = input().strip().split(" ") #N * M
	start = 0
	for i in range(N):
		matrix.append(elements[start : start + M]) # (0, M - 1) | (M, 2*m-1)
		start = start + M

	boundaryTraversal(matrix, N, M)
	print(), In this Programming Language: Python, Now tell me if this Code is compilable or not?