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