```
class NumMatrix(object):
def __init__(self, matrix):
self.matrix = matrix
def update(self, row, col, val):
self.matrix[row][col]=val
def sumRegion(self, row1, col1, row2, col2):
return reduce(lambda s, row: s+sum(row[col1:col2+1]),self.matrix[row1:row2+1],0)
```