#pragma GCC optimize("Ofast") #pragma GCC optimize(1) #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC target("popcnt") #include using namespace std; typedef long long ll; typedef string str; typedef pair pii; #define F first #define S second #define pb push_back #define pq priority_queue #define all(x) (x).begin(),(x).end() #define bug(x) cerr << (x) << '\n' #define yn(x) cout << (x==1?"Yes\n":"No\n") #define PI 3.14159265358979323 #define Ststone ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) const ll max_n=2e5+20,max_int=2147483647,mod1=1e9+7,mod2=998244353; const bool online = 0; ll dx[8] = {1,0,0,-1,1,1,-1,-1}; ll dy[8] = {0,1,-1,0,1,-1,1,-1}; ll t,n,q,m,a,b,c,d,e,dp[5010][10][10],ans=0; vector v,v1,v2,v3,v4; char cc; str s; ll f(ll x,ll y){ return ((a*(x&y))+(b*(x|y))+(c*(x^y)))%4; } void solve(){ cin >> n; cin >> a >> b >> c; for(ll goal=0;goal<4;goal++){ for(ll i=0;i<5010;i++){ for(ll j=0;j<4;j++){ for(ll k=0;k<4;k++){ dp[i][j][k] = 0; } } } for(ll i=0;i<4;i++){ for(ll j=0;j<4;j++){ if(f(i,j)==goal) dp[1][i][j] = 1; } } for(ll i=2;i> t; t = 1; for(ll i=1;i<=t;i++){ //cout << "Case #"<