#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;
for (int i = 0; i < len; i++)
{
if (a[i] == b[i] && a[i] == '0' && s[i] == '1')
{
cout << "NO\n";
return 0;
}
else if (a[i] != b[i] && s[i] == '0')
{
if (AND)
{
AND--;
ans += '&';
}
else
{
cout << "NO\n";
return 0;
}
}
else if (a[i] == b[i]&&a[i]=='1' && s[i] == '0')
{
if (XOR)
{
XOR--;
ans += '^';
}
else
{
cout << "NO\n";
return 0;
}
}
else if (a[i] == b[i] && a[i] == '0' && s[i] == '0')
{
if (XOR)
{
ans += '^';
XOR--;
}
else if (OR)
{
ans += '|';
OR--;
}
else if (AND)
{
ans += '&';
AND--;
}
else
{
cout << "NO\n";
return 0;
}
}
if (a[i] != b[i] && s[i] == '1')
{
if (XOR)
{
ans += '^';
XOR--;
}
else if (OR)
{
ans += '|';
OR--;
}
else
{
cout << "NO\n";
return 0;
}
}
else if (a[i] == b[i] && a[i] == '1' && s[i] == '1')
{
if (AND)
{
ans += '&';
AND--;
}
else if (OR)
{
ans += '|';
OR--;
}
else
{
cout << "NO\n";
return 0;
}
}
}
cout << "YES\n";
cout << ans;
}
Copy