Easiest solution in c++
\nclass Solution {\npublic:\n    \n    long long matrixSumQueries(int n, vector<vector<int>>& q) {\n        \n        vector<int>row(n, 0);\n        vector<int>
```\nclass Solution {\npublic:\n    \n    long long matrixSumQueries(int n, vector<vector<int>>& q) {\n        \n        vector<int>row(n, 0);\n        vector<int>col(n, 0);\n        \n        long long ans = 0;\n        int r = 0, c = 0;\n        for(int i = q.size()-1; i >= 0; i--)\n        {\n            int type = q[i][0];\n            int ind = q[i][1];\n            int val = q[i][2];\n            \n            if(type == 0 && row[ind] == 0 )\n            {\n                r++;\n                row[ind] = 1;\n                ans += (n - c) * val;\n            }\n            \n            if(type == 1 && col[ind] == 0)\n            {\n                c++;\n                col[ind] = 1;\n                ans += (n - r) * val;\n            }\n        }\n        return ans;\n        \n    }\n};\n```
['Array', 'C']