#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define sz(s) (int)(s.size())
#define all(v) v.begin(),v.end()
#define clr(d,v) memset(d,v,sizeof(d))
#define ll long long
#define ld long double
#define ull unsigned long long
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
ll gcd(ll x, ll y) { return(!y) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return((x / gcd(x, y)) * y); }
void file()
{
std::ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
}
int main()
{
file();
int len, XOR, OR, AND;
cin >> len >> AND >> OR >> XOR;
string a, b, s;
cin >> a >> b >> s;
string ans(len, ' ');
vector<bool>vis(len, false);
for (int i = 0; i < len; i++)
{
if (a[i] == b[i] && a[i] == '0' && s[i] == '1')// 0 0 1
{
cout << "NO\n";
return 0;
}
else if (a[i] != b[i] && s[i] == '0') // 0 1 0, 1 0 0
{
if (AND)
{
AND--;
vis[i] = true;
ans[i]= '&';
}
else
{
cout << "NO\n";
return 0;
}
}
else if (a[i] == b[i] && a[i] == '1' && s[i] == '0') // 1 1 0
{
if (XOR)
{
vis[i] = true;
XOR--;
ans[i] = '^';
}
else
{
cout << "NO\n";
return 0;
}
}
}
for (int i = 0; i < len; i++)
{
if (vis[i])continue;
if (a[i] == b[i] && a[i] == '0' && s[i] == '0') // 0 0 0
{
if (XOR)
{
ans[i] = '^';
XOR--;
}
else if (OR)
{
ans[i] = '|';
OR--;
}
else if (AND)
{
ans[i] = '&';
AND--;
}
else
{
cout << "NO\n";
return 0;
}
}
else if (a[i] != b[i] && s[i] == '1') // 1 0 1 , 0 1 1
{
if (XOR)
{
ans[i] = '^';
XOR--;
}
else if (OR)
{
ans[i] = '|';
OR--;
}
else
{
cout << "NO\n";
return 0;
}
}
else if (a[i] == b[i] && a[i] == '1' && s[i] == '1') // 1 1 1
{
if (AND)
{
ans[i] = '&';
AND--;
}
else if (OR)
{
ans[i] = '|';
OR--;
}
else
{
cout << "NO\n";
return 0;
}
}
}
cout << "YES\n";
cout << ans;
}
Copy