Easiy c++ solution
\n\n# Code\n\nclass Solution {\npublic:\n    long long matrixSumQueries(int n, vector<vector<int>>& q) {\n        long long sum=0;\n        map<int,int> mpr,mpc
\n\n# Code\n```\nclass Solution {\npublic:\n    long long matrixSumQueries(int n, vector<vector<int>>& q) {\n        long long sum=0;\n        map<int,int> mpr,mpc;\n        set<int> sr,sc;\n        int some=q.size();\n        for(int i=some-1;i>=0;i--){\n            int type=q[i][0];\n            int ind=q[i][1];\n            int val=q[i][2];\n            if(type==0){\n                if(mpr[ind]==0){\n                    sum+=((n-sc.size())*val);\n                    mpr[ind]=1;\n                    sr.insert(ind);\n                }\n            }\n            else{\n                if(mpc[ind]==0){\n                    sum+=((n-sr.size())*val);\n                    mpc[ind]=1;\n                    sc.insert(ind);\n                }\n            }\n        }\n        return sum;\n    }\n};\n```
['C++']