human
Print matrix after applying increment operations in M ranges | Function to update and print the matrix after performing queries.
Add 1 to the first element of the sub - matrix.
If there is an element after the last element of the sub - matrix then decrement it by 1.
Calculate the running sum.
Print the updated element.
Next line.
Size of the matrix.
Queries"
Solution in Python:

What is a code to print matrix after applying increment operations in M ranges and the other steps required?
assistant
#Here is code to print matrix after applying increment operations in M ranges and the other steps required.
 def updateMatrix ( n , q , mat ) :
	for i in range ( 0 , len ( q ) ) :
		X1 = q [ i ] [ 0 ] ;
		Y1 = q [ i ] [ 1 ] ;
		X2 = q [ i ] [ 2 ] ;
		Y2 = q [ i ] [ 3 ] ;
		mat [ X1 ] [ Y1 ] = mat [ X1 ] [ Y1 ] + 1 ;
		if ( Y2 + 1 < n ) :
			mat [ X2 ] [ Y2 + 1 ] = mat [ X2 ] [ Y2 + 1 ] - 1 ;
		elif ( X2 + 1 < n ) :
			mat [ X2 + 1 ] [ 0 ] = mat [ X2 + 1 ] [ 0 ] - 1 ;
	sum = 0 ;
	for i in range ( 0 , n ) :
		for j in range ( 0 , n ) :
			sum = sum + mat [ i ] [ j ] ;
			print ( sum , end = ' ▁ ' ) ;
		print ( " ▁ " ) ;
n = 5 ;
mat = [ [ 0 for i in range ( n ) ] for i in range ( n ) ] ;
q = [ [ 0 , 0 , 1 , 2 ] , [ 1 , 2 , 3 , 4 ] , [ 1 , 4 , 3 , 4 ] ] ;
updateMatrix ( n , q , mat ) ;