1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <bits/stdc++.h>
#define in insert
#define sz size()
#define MAX 10000

using namespace std;

int n,r;
bitset <MAX> b;
char s[MAX+1];
set <string> m;

void rec(void (*f)(bitset <MAX>), int n, int k, int i=0, bitset <MAX> w=0) {
	if (k==0) {
		(*f)(w);
	}
	for (int j=i; j<n; ++j) {
		w[j]=1;
		rec(f,n,k-1,j+1,w);
		w[j]=0;
	}
}

int main() {
	scanf("%d",&n);
	for (int i=0; i<3; ++i) {
		scanf("%d %s",&r,&s);
		for (int j=0; j<n; ++j) b[j]=s[j]-48;
		for (int j=0; j<=r; ++j) {
			rec(
				[](bitset <MAX> a) {
					m.in((a^b).to_string());
			},n,j);
		}
	}
	printf("%d\n",m.sz);
	return 0;
}