For 2 given matrices of size n x n. Your task is to multiply them.
 
Example 1:Ã¢â¬â¹
Ã¢â¬â¹Input: 
matrixA = {{1, 1, 1}, {1, 1, 1}, 
           {1, 1, 1}}
matrixB = {{1, 1, 1}, {1, 1, 1},
           {1, 1, 1}}
Output: {{3, 3, 3}, {3, 3, 3}, {3, 3, 3}}
Example 2:
Input: 
matrixA = {{1, 2}, {3, 4}},
matrixB = {{4, 3}, {2, 1}}
Output: {{8, 5}, {20, 13}}
 
Your Task:
You don't need to read or print anything. Your task is to complete the function Multiply() which takes two matrices matrixA amd matrixB as input parameter and multiply the two matrices. You don't have to return anything. Copy the values of output matrix into matrixA.
 
Expected Time Compelxity: O(n^{3})
Expected Space Complexity: O(n^{2})
 
Constraints:
1 <= n <= 100
1 <= elements of matrices <= 100

Source: geeksforgeeks | Difficulty: EASY
Tags: Matrices

Data structures

Mathematics

Starter code: #User function Template for python3

class Solution:
	def Mutliply(self, matrixA, matrixB):
		# Code here

Solutions:
class Solution:

	def Mutliply(self, matrixA, matrixB):
		n = len(matrixA)
		matrixC = [[0] * n for l in range(n)]
		for i in range(n):
			for j in range(n):
				ans = 0
				for k in range(n):
					ans += matrixA[i][k] * matrixB[k][j]
				matrixC[i][j] = ans
		for i in range(n):
			for j in range(n):
				matrixA[i][j] = matrixC[i][j]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		n = len(matrixA)
		list1 = [[0 for i in range(1, n + 1)] for j in range(1, n + 1)]
		for i in range(n):
			for j in range(n):
				for k in range(n):
					list1[i][j] += matrixA[i][k] * matrixB[k][j]
		for i in range(n):
			for j in range(n):
				matrixA[i][j] = list1[i][j]


def dot_product(matA, matB, i, j):
	sum = 0
	for n in range(len(matA[0])):
		sum += matA[j][n] * matB[n][i]
	return sum

class Solution:

	def Mutliply(self, matrixA, matrixB):
		output = [[0 for i in range(len(matrixA[0]))] for j in range(len(matrixA))]
		for j in range(len(matrixA)):
			for i in range(len(matrixA[0])):
				output[j][i] = dot_product(matrixA, matrixB, i, j)
		for j in range(len(matrixA)):
			for i in range(len(matrixA[0])):
				matrixA[j][i] = output[j][i]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		n = len(matrixA)
		ans = [[matrixA[i][j] for j in range(n)] for i in range(n)]
		for k in range(n):
			for i in range(n):
				csum = 0
				for j in range(n):
					csum += ans[k][j] * matrixB[j][i]
				matrixA[k][i] = csum
		return ans


class Solution:

	def Mutliply(self, A, B):
		C = [[0 for _ in range(len(A))] for _ in range(len(A))]
		n = len(A)
		for i in range(n):
			for j in range(n):
				for k in range(n):
					C[i][j] += A[i][k] * B[k][j]
		for i in range(n):
			for j in range(n):
				A[i][j] = C[i][j]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		n = len(matrixA)
		mat = [[0 for i in range(n)] for j in range(n)]
		for i in range(n):
			for j in range(n):
				s = 0
				for k in range(n):
					s += matrixA[i][k] * matrixB[k][j]
				mat[i][j] = s
		for i in range(n):
			for j in range(n):
				matrixA[i][j] = mat[i][j]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		c = [[sum((a * b for (a, b) in zip(matrixA, matrixB))) for matrixB in zip(*matrixB)] for matrixA in matrixA]
		for i in range(0, n):
			for j in range(0, n):
				matrixA[i][j] = c[i][j]


import numpy as np

class Solution:

	def Mutliply(self, matrixA, matrixB):
		full_matrix = [[sum((a * b for (a, b) in zip(matrixA, matrixB))) for matrixB in zip(*matrixB)] for matrixA in matrixA]
		for i in range(0, n):
			for j in range(0, n):
				matrixA[i][j] = full_matrix[i][j]


import numpy as np

class Solution:

	def Mutliply(self, matrixA, matrixB):
		row1 = len(matrixA)
		row2 = len(matrixB)
		col1 = len(matrixA[0])
		col2 = len(matrixB[0])
		full_list = []
		row = []
		sum1 = 0
		for i in range(row1):
			for j in range(row1):
				for k in range(row1):
					sum1 += matrixA[i][k] * matrixB[k][j]
				row.append(sum1)
				sum1 = 0
			full_list.append(row)
			row = []
		for i in range(row1):
			for j in range(col1):
				matrixA[i][j] = full_list[i][j]
		return matrixA


class Solution:

	def Mutliply(self, matrixA, matrixB):
		summ = 0
		row_list = []
		full_matrix = []
		for i in range(0, len(matrixA)):
			for j in range(0, len(matrixA)):
				for k in range(0, len(matrixA)):
					summ += matrixA[i][k] * matrixB[k][j]
				row_list.append(summ)
				summ = 0
			full_matrix.append(row_list)
			row_list = []
		for i in range(0, len(matrixA)):
			for j in range(0, len(matrixA)):
				matrixA[i][j] = full_matrix[i][j]
		return matrixA


class Solution:

	def Mutliply(self, matrixA, matrixB):
		output = [[sum((a * b for (a, b) in zip(a_row, b_col))) for b_col in zip(*matrixB)] for a_row in matrixA]
		n = len(matrixA)
		for i in range(n):
			for j in range(n):
				matrixA[i][j] = output[i][j]


from numpy import array

class Solution:

	def Mutliply(self, matrixA, matrixB):
		arr1 = array(matrixA)
		arr2 = array(matrixB)
		ans = arr1 @ arr2
		l = len(matrixA[0])
		for i in range(l):
			for j in range(l):
				matrixA[i][j] = ans[i][j]
		return matrixA


class Solution:

	def Mutliply(self, matrixA, matrixB):
		matrix = [[0] * len(matrixA) for i in range(len(matrixA))]
		for i in range(len(matrixA)):
			for j in range(len(matrixB[0])):
				sum = 0
				for k in range(len(matrixB)):
					sum += matrixA[i][k] * matrixB[k][j]
				matrix[i][j] = sum
		for i in range(len(matrixA)):
			for j in range(len(matrixA)):
				matrixA[i][j] = matrix[i][j]


class Solution:

	def Mutliply(self, A, B):
		n = len(A)
		c = []
		for i in range(n):
			temp = [0] * n
			c.append(temp)
		for i in range(n):
			for j in range(n):
				for k in range(n):
					c[i][j] += A[i][k] * B[k][j]
		for i in range(n):
			for j in range(n):
				A[i][j] = c[i][j]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		n = len(matrixA[0])
		ans = []
		for i in range(n):
			l = []
			for j in range(n):
				su = 0
				for k in range(n):
					mu = matrixA[i][k] * matrixB[k][j]
					su += mu
				l.append(su)
			ans.append(l)
		for i in range(n):
			for j in range(n):
				matrixA[i][j] = ans[i][j]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		new_matrix = []
		for i in range(len(matrixA)):
			new = []
			for j in range(len(matrixB)):
				new.append(0)
			new_matrix.append(new)
		for i in range(len(matrixA)):
			for j in range(len(matrixB)):
				new_matrix[i][j] = matrixA[i][j]
		for i in range(len(matrixA)):
			for j in range(len(matrixB[0])):
				new = 0
				for k in range(len(matrixA[0])):
					new += new_matrix[i][k] * matrixB[k][j]
				matrixA[i][j] = new


class Solution:

	def Mutliply(self, matrixA, matrixB):
		n = len(matrixA)
		ans = []
		for i in range(n):
			current_ar = []
			for j in range(n):
				current_sum = 0
				for k in range(n):
					current_sum += matrixA[i][k] * matrixB[k][j]
				current_ar.append(current_sum)
			ans.append(current_ar)
		for i in range(n):
			matrixA[i] = ans[i]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		n = len(matrixA)
		A = [[0] * n for i in range(n)]
		for i in range(n):
			for j in range(n):
				for k in range(n):
					A[i][j] += matrixA[i][k] * matrixB[k][j]
		for i in range(n):
			for j in range(n):
				matrixA[i][j] = A[i][j]


class Solution:

	def Mutliply(self, A, B):
		a = len(A)
		b = len(A[0])
		c = len(B[0])
		C = [[0 for _ in range(a)] for _ in range(c)]
		for i in range(a):
			for j in range(c):
				for k in range(b):
					C[i][j] += A[i][k] * B[k][j]
		for i in range(a):
			for j in range(b):
				A[i][j] = C[i][j]


class Solution:

	def Mutliply(self, a, b):
		row = len(a)
		col = len(a[0])
		x = col
		col2 = len(b[0])
		res = [[0 for _ in range(row)] for j in range(col2)]
		for i in range(row):
			for j in range(col2):
				s = 0
				for k in range(x):
					s += a[i][k] * b[k][j]
				res[i][j] = s
		for i in range(row):
			for j in range(col2):
				a[i][j] = res[i][j]


import numpy as np

class Solution:

	def Mutliply(self, matrixA, matrixB):
		a = np.array(matrixA)
		b = np.array(matrixB)
		c = np.dot(a, b)
		c = c.tolist()
		n = len(matrixA)
		for i in range(n):
			for j in range(n):
				matrixA[i][j] = c[i][j]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		n = len(matrixA)
		a = []
		for i in range(n):
			b = []
			for j in range(n):
				b.append(0)
			a.append(b)
		for i in range(n):
			for j in range(n):
				s = 0
				for k in range(n):
					s += matrixA[i][k] * matrixB[k][j]
				a[i][j] = s
		for i in range(n):
			for j in range(n):
				matrixA[i][j] = a[i][j]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		ans = []
		n = len(matrixA)
		for i in range(n):
			temp = []
			for j in range(n):
				a = 0
				for k in range(n):
					a += matrixA[i][k] * matrixB[k][j]
				temp.append(a)
			ans.append(temp)
		for i in range(n):
			for j in range(n):
				matrixA[i][j] = ans[i][j]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		for i in range(len(matrixA)):
			temp = []
			for j in range(len(matrixB[0])):
				t = 0
				for k in range(len(matrixA[0])):
					t += matrixA[i][k] * matrixB[k][j]
				temp.append(t)
			matrixA[i] = temp


class Solution:

	def Mutliply(self, matrixA, matrixB):
		matrixC = [[0 for j in range(len(matrixA[0]))] for i in range(len(matrixA))]
		for i in range(len(matrixA)):
			for j in range(len(matrixB[0])):
				for k in range(len(matrixB)):
					matrixC[i][j] += matrixA[i][k] * matrixB[k][j]
		for i in range(len(matrixA)):
			for j in range(len(matrixB[0])):
				matrixA[i][j] = matrixC[i][j]
		return matrixA


class Solution:

	def Mutliply(self, matrixA, matrixB):
		ans = []
		for i in range(n):
			arr = []
			for j in range(n):
				s = 0
				for k in range(n):
					s += matrixA[i][k] * matrixB[k][j]
				arr.append(s)
			ans.append(arr)
		for i in range(n):
			matrixA[i] = ans[i]
		return matrixA


import copy

class Solution:

	def Mutliply(self, matrixA, matrixB):
		summ = 0
		n = len(matrixA)
		row_list = []
		full_matrix = []
		for i in range(0, n):
			for j in range(0, n):
				for k in range(0, n):
					summ += matrixA[i][k] * matrixB[k][j]
				row_list.append(summ)
				summ = 0
			full_matrix.append(row_list)
			row_list = []
		for i in range(0, n):
			for j in range(0, n):
				matrixA[i][j] = full_matrix[i][j]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		matrixC = [[0 for i in range(n)] for i in range(n)]
		for i in range(n):
			for j in range(n):
				tempsum = 0
				for k in range(n):
					tempsum += matrixA[i][k] * matrixB[k][j]
				matrixC[i][j] = tempsum
		for i in range(n):
			for j in range(n):
				matrixA[i][j] = matrixC[i][j]
		return matrixA


class Solution:

	def Mutliply(self, matrixA, matrixB):
		new = []
		for i in range(n):
			r = []
			for j in range(n):
				r.append(0)
			new.append(r)
		for i in range(n):
			for j in range(n):
				for k in range(n):
					new[i][j] += matrixA[i][k] * matrixB[k][j]
		for i in range(n):
			for j in range(n):
				matrixA[i][j] = matrixA[i][j] - matrixA[i][j] + new[i][j]
		return matrixA


class Solution:

	def Mutliply(self, matrixA, matrixB):
		import numpy as np
		x = np.array(matrixA)
		y = np.array(matrixB)
		matrixA[:] = np.dot(x, y)
		return matrixA


class Solution:

	def Mutliply(self, matrixA, matrixB):
		mul = []
		for i in range(len(matrixA)):
			count = 0
			l = []
			while count < len(matrixA):
				s = 0
				for j in range(len(matrixA)):
					s = s + matrixA[i][j] * matrixB[j][count]
				l.append(s)
				count += 1
			mul.append(l)
		for i in range(len(matrixA)):
			for j in range(len(matrixA)):
				matrixA[i][j] = mul[i][j]


import numpy as np

class Solution:

	def Mutliply(self, matrixA, matrixB):
		x = np.array(matrixA)
		y = np.array(matrixB)
		matrixA[:] = np.dot(x, y)
if __name__ == '__main__':
	T = int(input())
	for i in range(T):
		n = int(input())
		matrixA = []
		matrixB = []
		for _ in range(n):
			matrixA.append(list(map(int, input().split())))
		for _ in range(n):
			matrixB.append(list(map(int, input().split())))
		ob = Solution()
		ob.Mutliply(matrixA, matrixB)
		for i in range(n):
			for j in range(n):
				print(matrixA[i][j], end=' ')
			print()


class Solution:

	def Mutliply(self, matrixA, matrixB):
		n = len(matrixA)
		matc = [[0] * n for i in range(n)]
		for i in range(n):
			for j in range(n):
				ans = 0
				for k in range(n):
					ans += matrixA[i][k] * matrixB[k][j]
				matc[i][j] = ans
		for i in range(n):
			for j in range(n):
				matrixA[i][j] = matc[i][j]
		return matc
if __name__ == '__main__':
	T = int(input())
	for i in range(T):
		n = int(input())
		matrixA = []
		matrixB = []
		for _ in range(n):
			matrixA.append(list(map(int, input().split())))
		for _ in range(n):
			matrixB.append(list(map(int, input().split())))
		ob = Solution()
		ob.Mutliply(matrixA, matrixB)
		for i in range(n):
			for j in range(n):
				print(matrixA[i][j], end=' ')
			print()


class Solution:

	def Mutliply(self, mat1, mat2):
		(N, M) = (len(mat1), len(mat1[0]))
		(P, Q) = (len(mat2), len(mat2[0]))
		ans = [[0 for _ in range(0, Q)] for _ in range(0, N)]
		for i in range(0, N):
			for j in range(0, Q):
				currSum = 0
				for idx in range(0, M):
					currSum += mat1[i][idx] * mat2[idx][j]
				ans[i][j] = currSum
		for i in range(0, N):
			for j in range(0, Q):
				mat1[i][j] = ans[i][j]
if __name__ == '__main__':
	T = int(input())
	for i in range(T):
		n = int(input())
		matrixA = []
		matrixB = []
		for _ in range(n):
			matrixA.append(list(map(int, input().split())))
		for _ in range(n):
			matrixB.append(list(map(int, input().split())))
		ob = Solution()
		ob.Mutliply(matrixA, matrixB)
		for i in range(n):
			for j in range(n):
				print(matrixA[i][j], end=' ')
			print()


class Solution:

	def Mutliply(self, matrixA, matrixB):
		full_matrix = []
		s = 0
		n = len(matrixA)
		temp = []
		for i in range(n):
			for j in range(n):
				for k in range(n):
					s += matrixA[i][k] * matrixB[k][j]
				temp.append(s)
				s = 0
			full_matrix.append(temp)
			temp = []
		for i in range(0, n):
			for j in range(0, n):
				matrixA[i][j] = full_matrix[i][j]
if __name__ == '__main__':
	T = int(input())
	for i in range(T):
		n = int(input())
		matrixA = []
		matrixB = []
		for _ in range(n):
			matrixA.append(list(map(int, input().split())))
		for _ in range(n):
			matrixB.append(list(map(int, input().split())))
		ob = Solution()
		ob.Mutliply(matrixA, matrixB)
		for i in range(n):
			for j in range(n):
				print(matrixA[i][j], end=' ')
			print()


class Solution:

	def Mutliply(self, matrixA, matrixB):
		n = len(matrixA)
		m = len(matrixB)
		n1 = len(matrixA[0])
		m2 = len(matrixB[0])
		res = [[0 for i in range(m2)] for j in range(n)]
		for i in range(n):
			for j in range(n1):
				for k in range(m):
					res[i][j] += matrixA[i][k] * matrixB[k][j]
		for i in range(n):
			for j in range(m):
				matrixA[i][j] = res[i][j]


class Solution:

	def Mutliply(self, A, B):
		C = [[0] * len(B[0]) for i in range(len(A))]
		for i in range(len(A[0])):
			for j in range(len(B)):
				for k in range(len(B[0])):
					C[i][j] += int(A[i][k]) * int(B[k][j])
		for i in range(len(A)):
			for j in range(len(A[0])):
				A[i][j] = C[i][j]


class Solution:

	def Mutliply(self, A, B):
		n = len(A)
		ans = []
		for i in range(n):
			a = []
			for j in range(n):
				su = 0
				for k in range(n):
					su += A[i][k] * B[k][j]
				a.append(su)
			ans.append(a)
		for i in range(n):
			for j in range(n):
				A[i][j] = ans[i][j]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		r = []
		l = len(matrixA)
		for x in range(l):
			c = []
			for y in range(l):
				s = 0
				for z in range(l):
					s = s + matrixA[x][z] * matrixB[z][y]
				c.append(s)
			matrixA[x] = c


import copy

class Solution:

	def Mutliply(self, matrixA, matrixB):
		n = len(matrixA)
		res = [[0 for i in range(n)] for j in range(n)]
		for i in range(n):
			for j in range(n):
				sum = 0
				for k in range(n):
					sum += matrixA[i][k] * matrixB[k][j]
				res[i][j] = sum
		for i in range(n):
			for j in range(n):
				matrixA[i][j] = res[i][j]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		r1 = len(matrixA)
		r2 = len(matrixB)
		c1 = len(matrixA[0])
		c2 = len(matrixB[0])
		result = [[0 for i in range(r1)] for j in range(r1)]
		for i in range(r1):
			for j in range(c2):
				for k in range(r2):
					result[i][j] += matrixA[i][k] * matrixB[k][j]
		for i in range(r1):
			for j in range(c1):
				matrixA[i][j] = result[i][j]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		newMat = []
		N = len(matrixA)
		M = len(matrixB[0])
		L = len(matrixB)
		for i in range(N):
			A = [0 for j in range(M)]
			newMat.append(A)
		for i in range(N):
			for j in range(M):
				for k in range(L):
					v = matrixA[i][k] * matrixB[k][j]
					newMat[i][j] = newMat[i][j] + v
		for i in range(N):
			for j in range(M):
				matrixA[i][j] = newMat[i][j]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		mat = [[0] * len(matrixA) for x in range(len(matrixA))]
		for i in range(len(matrixA)):
			for j in range(len(matrixB[0])):
				for k in range(len(matrixB)):
					mat[i][j] += matrixA[i][k] * matrixB[k][j]
		for l in range(len(matrixA)):
			for h in range(len(matrixA[0])):
				matrixA[l][h] = mat[l][h]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		(rowsA, colsA) = (len(matrixA), len(matrixA[0]))
		(rowsB, colsB) = (len(matrixB), len(matrixB[0]))
		if colsA != rowsB:
			return
		matrixC = [[0] * colsB for _ in range(rowsA)]
		for i in range(rowsA):
			for j in range(colsB):
				_sum = 0
				for k in range(colsA):
					_sum += matrixA[i][k] * matrixB[k][j]
				matrixC[i][j] = _sum
		for i in range(rowsA):
			for j in range(colsA):
				matrixA[i][j] = matrixC[i][j]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		ans = []
		length = len(matrixA)
		for i in range(length):
			sub_arr = []
			for x in range(length):
				element = 0
				for y in range(length):
					element += matrixA[i][y] * matrixB[y][x]
				sub_arr.append(element)
			for z in range(length):
				matrixA[i][z] = sub_arr[z]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		matrixC = []
		for i in range(len(matrixA)):
			for j in range(len(matrixA)):
				sumij = 0
				for k in range(len(matrixA)):
					sumij += matrixA[i][k] * matrixB[k][j]
				while i > len(matrixC) - 1:
					matrixC.append([])
				while k > len(matrixC[i]) - 1:
					matrixC[i].append(None)
				matrixC[i][j] = sumij
		for i in range(len(matrixA)):
			for j in range(len(matrixA)):
				matrixA[i][j] = matrixC[i][j]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		r = len(matrixA)
		c = len(matrixB[0])
		c1 = len(matrixA[0])
		res = [[0 for i in range(r)] for j in range(c1)]
		for i in range(r):
			for j in range(c):
				for k in range(c1):
					res[i][j] = res[i][j] + matrixA[i][k] * matrixB[k][j]
		for i in range(r):
			for j in range(c1):
				matrixA[i][j] = res[i][j]


class Solution:

	def Mutliply(self, A, B):
		res = [[0 for i in range(n)] for j in range(n)]
		for i in range(n):
			for j in range(n):
				for k in range(n):
					res[i][j] += A[i][k] * B[k][j]
		for i in range(n):
			for j in range(n):
				A[i][j] = res[i][j]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		r = len(matrixA)
		c = len(matrixA[0])
		final = [[0 for j in range(c)] for i in range(r)]
		for i in range(r):
			for j in range(c):
				for k in range(c):
					final[i][j] += matrixA[i][k] * matrixB[k][j]
		matrixA[:] = final[:]
		return


class Solution:

	def Mutliply(self, matrixA, matrixB):
		n = len(matrixA)
		m = len(matrixA[0])
		k = len(matrixB[0])
		newMatrix = []
		for i in range(0, n):
			newMatrix.append([])
			for j in range(0, k):
				sum = 0
				for kk in range(0, m):
					sum = sum + matrixA[i][kk] * matrixB[kk][j]
				newMatrix[i].append(sum)
		for i in range(0, n):
			for j in range(0, k):
				matrixA[i][j] = newMatrix[i][j]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		n = len(matrixA)
		c = []
		for i in range(n):
			k = []
			for j in range(n):
				k.append(0)
			c.append(k)
		for i in range(n):
			for j in range(n):
				c[i][j] = 0
				for k in range(n):
					c[i][j] += matrixA[i][k] * matrixB[k][j]
		for i in range(n):
			for j in range(n):
				matrixA[i][j] = c[i][j]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		n = len(matrixA)
		for i in range(n):
			row_buffer = [-1] * n
			for j in range(n):
				res = 0
				for h in range(n):
					res += matrixA[i][h] * matrixB[h][j]
				row_buffer[j] = res
			matrixA[i][:] = row_buffer


class Solution:

	def Mutliply(self, matrixA, matrixB):
		p = len(matrixA)
		q = len(matrixB[0])
		n = len(matrixA[0])
		result = [[0 for i in range(p)] for j in range(q)]
		for i in range(p):
			for j in range(q):
				for k in range(n):
					result[i][j] = result[i][j] + matrixA[i][k] * matrixB[k][j]
		for i in range(p):
			for j in range(q):
				(matrixA[i][j], result[i][j]) = (result[i][j], matrixA[i][j])


class Solution:

	def Mutliply(self, matrixA, matrixB):
		R = [[0 for i in range(n)] for j in range(n)]
		for i in range(n):
			for j in range(n):
				for k in range(n):
					R[i][j] += matrixA[i][k] * matrixB[k][j]
		for i in range(n):
			for j in range(n):
				matrixA[i][j] = R[i][j]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		g = len(matrixA[0])
		m = []
		for i in range(len(matrixA[0])):
			l = []
			for j in range(len(matrixA[0])):
				sum = 0
				for k in range(len(matrixA[0])):
					sum += matrixA[i][k] * matrixB[k][j]
				l.append(sum)
			m.append(l)
		for i in range(g):
			for j in range(g):
				matrixA[i][j] = m[i][j]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		ans = [[0] * len(matrixB[0]) for i in range(len(matrixA))]
		for i in range(len(matrixA[0])):
			for j in range(len(matrixB[0])):
				for k in range(len(matrixB)):
					ans[i][j] += matrixA[i][k] * matrixB[k][j]
		for i in range(len(ans)):
			for j in range(len(ans[0])):
				matrixA[i][j] = ans[i][j]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		n = len(matrixA)
		res = []
		for i in range(n):
			op = []
			for j in range(n):
				sm = 0
				for k in range(n):
					sm += matrixA[i][k] * matrixB[k][j]
				op.append(sm)
			res.append(op)
		for i in range(n):
			for j in range(n):
				matrixA[i][j] = res[i][j]


import numpy as np

class Solution:

	def Mutliply(self, matrixA, matrixB):
		R = np.zeros((n, n), dtype=int)
		for i in range(0, n):
			for j in range(0, n):
				for k in range(0, n):
					R[i][j] += matrixA[i][k] * matrixB[k][j]
		for i in range(n):
			for j in range(n):
				matrixA[i][j] = R[i][j]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		if len(matrixA[0]) != len(matrixB):
			print('error')
			return
		ans = [[0] * len(matrixA) for _ in range(len(matrixB[0]))]
		for row in range(len(matrixA)):
			for col in range(len(matrixB[0])):
				ans[row][col] = 0
				for itr in range(len(matrixA[0])):
					ans[row][col] += matrixA[row][itr] * matrixB[itr][col]
		for r in range(len(ans)):
			for c in range(len(ans[0])):
				matrixA[r][c] = ans[r][c]


class Solution:

	def Mutliply(self, matrixA, matrixB):
		matrixC = []
		for i in range(len(matrixA)):
			rows = []
			for j in range(len(matrixA)):
				c1 = 0
				for k in range(len(matrixA)):
					c1 += matrixA[i][k] * matrixB[k][j]
				rows.append(c1)
			matrixC.append(rows)
		for i in range(len(matrixC)):
			for j in range(len(matrixC)):
				matrixA[i][j] = matrixC[i][j]