#NEWLINE# def __init__( self , matrix ) : #NEWLINE# #INDENT# '\n        initialize your data structure here.\n        :type matrix: List[List[int]]\n        ' #NEWLINE# if ( not matrix ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# ( m , n ) = ( len ( matrix ) , len ( matrix [ 0 ] ) ) #NEWLINE# self . __sums = [ [ 0 for _ in xrange ( ( n + 1 ) ) ] for _ in xrange ( ( m + 1 ) ) ] #NEWLINE# for i in xrange ( 1 , ( m + 1 ) ) : #NEWLINE# #INDENT# for j in xrange ( 1 , ( n + 1 ) ) : #NEWLINE# #INDENT# self . __sums [ i ] [ j ] = ( self . __sums [ i ] [ ( j - 1 ) ] + matrix [ ( i - 1 ) ] [ ( j - 1 ) ] ) #NEWLINE# #UNINDENT# #UNINDENT# for j in xrange ( 1 , ( n + 1 ) ) : #NEWLINE# #INDENT# for i in xrange ( 1 , ( m + 1 ) ) : #NEWLINE# #INDENT# self . __sums [ i ] [ j ] += self . __sums [ ( i - 1 ) ] [ j ]