Here is the link to the problem: https://atcoder.jp/contests/abc173/tasks/abc173_c

Now the thing is that I first wrote the code in C++ but that code was producing the wrong output for the sample test cases. Then I wrote the code in Python using the same logic and the same statements (the Python way) and it was producing the correct outputs. Now I can’t figure out what was wrong with the C++ code. Can anyone please help me with this?

C++ Code:

```
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main()
{
FASTIO
int grid[6][6];
int h,w,k;
cin >> h >> w >> k;
char x;
for(int i=0; i<h; i++)
{
for(int j=0; j<w; j++)
{
cin >> x;
if(x == '#') grid[i][j] = 1;
}
}
// for(int i=0; i<h; i++)
// {
// for(int j=0; j<w; j++)
// cout << grid[i][j] << " ";
// cout << "\n";
// }
int cnt = 0;
for(int i=0; i<(1<<h); i++)
{
for(int j=0; j<(1<<w); j++)
{
int black = 0;
for(int m=0; m<h; m++)
{
for(int n=0; n<w; n++)
{
if((1&(i>>m) == 0) && (1&(j>>n) == 0) && (grid[m][n] == 1)) black++;
}
}
if(black == k) cnt++;
}
}
cout << cnt << "\n";
return 0;
}
```

Python Code:

```
h, w, k = map(int,input().split())
grid = [[] for x in range(h)]
for i in range(h):
grid[i] = input()
cnt = 0
for i in range(1<<h):
for j in range(1<<w):
black = 0
for p in range(h):
for q in range(w):
if 1&(i>>p) == 0 and 1&(j>>q) == 0 and grid[p][q] == '#':
black += 1
if black == k:
cnt += 1
print(cnt)
```

**Note:** Don’t know why the Python code is not color formatted correctly. (I did use ```)