<p>Given a 2D matrix <code>matrix</code>, handle multiple queries of the following type:</p>
<ul>
<li>Calculate the <strong>sum</strong> of the elements of <code>matrix</code> inside the rectangle defined by its <strong>upper left corner</strong><code>(row1, col1)</code> and <strong>lower right corner</strong><code>(row2, col2)</code>.</li>
<li><code>NumMatrix(int[][] matrix)</code> Initializes the object with the integer matrix <code>matrix</code>.</li>
<li><code>int sumRegion(int row1, int col1, int row2, int col2)</code> Returns the <strong>sum</strong> of the elements of <code>matrix</code> inside the rectangle defined by its <strong>upper left corner</strong><code>(row1, col1)</code> and <strong>lower right corner</strong><code>(row2, col2)</code>.</li>