Simple C++ Solution
\nclass Solution {\n    \npublic:\n    void put(vector<vector<int>>& mat, unordered_map<int, vector<int>> &mpp){\n        \n        for(int i = 0; i < mat.size(
```\nclass Solution {\n    \npublic:\n    void put(vector<vector<int>>& mat, unordered_map<int, vector<int>> &mpp){\n        \n        for(int i = 0; i < mat.size(); i++){\n            for(int j = 0; j < mat[0].size(); j++){\n                \n                vector<int> indexes {i,j};\n                mpp[mat[i][j]] = indexes;\n            }\n        }\n    }\n    \npublic:\n    vector<int> find(int val, unordered_map<int, vector<int>> &mpp){\n        return mpp[val];\n    }\n    \npublic:\n    int firstCompleteIndex(vector<int>& arr, vector<vector<int>>& mat) {\n        \n        int noOfRows = mat.size(),  noOfCols = mat[0].size();\n        vector<int> rows(noOfRows,0),  cols(noOfCols, 0);\n        \n        unordered_map<int, vector<int>> mpp;\n        put(mat, mpp);\n        \n        for(int i = 0; i < arr.size(); i++){\n            \n            int val = arr[i];\n            \n            vector<int> rowCol = find(val, mpp);\n            \n            rows[rowCol[0]] += 1;\n            cols[rowCol[1]] += 1;\n            \n            if(rows[rowCol[0]] == noOfCols || cols[rowCol[1]] == noOfRows){\n                return i;\n            }\n            \n            \n        }\n        \n        return -1;\n    }\n};\n```
['C']