I used your logic and coded but still I am getting partially correct answer.Here is my code:

#include

#include

#include

#include

#include

#include <unordered_set>

using namespace std;

const long long int M = 1000000007;

long long int count_setbits(string s)

{

return count(s.begin(),s.end(),‘1’);

}

long long int fact(long long int n);

long long int nCr(long long int n,long long int r)

{

return fact(n) / (fact® * fact(n - r));

}

// Returns factorial of n

long long int fact(long long int n)

{

long long int res = 1;

for (long long int i = 2; i <= n; i++)

res = res * i;

return res;

}

int main()

{

long long int t;

cin >> t;

while (t–)

{

long long int n,max_setbits,min_setbits,intersection_setbits,answer=0;

cin >> n;

string a, b;

cin >> a >> b;

```
if ((count_setbits(a) + count_setbits(b) - n) > 0)
intersection_setbits = count_setbits(a) + count_setbits(b) - n;
else
intersection_setbits = 0;
max_setbits = count_setbits(a) + count_setbits(b) - 2 * intersection_setbits;
min_setbits = abs(count_setbits(a) - count_setbits(b));
long long int j = min_setbits;
while (j <= max_setbits)
{
answer += nCr(n, j);
j += 2;
}
cout << (answer%M) << "\n";
}
```

}