Simple small solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\npublic class Solution {\n    public long MatrixSumQueries(int n, int[][] queries) {\n        \n        var rows = new HashSet<int>();\n        var columns = new HashSet<int>();\n        long sum = 0;\n\n        for(int i = queries.Length - 1; i >= 0; i--)\n        {\n            var isRow = queries[i][0] == 0;\n            var isColumn = queries[i][0] == 1;\n            var index = queries[i][1];\n            var val =  queries[i][2];\n\n            if(isRow && !rows.Contains(index))\n            {\n                sum += (n - columns.Count) * val;\n                rows.Add(index);\n            }\n            else if(isColumn && !columns.Contains(index))\n            {\n                sum +=  (n - rows.Count) * val;\n                columns.Add(index);\n            }\n        }\n\n        return sum;\n    }\n}\n```
['C#']