#include <bits/stdc++.h>
using namespace std;
#define Yalahwy cin.tie(0), cout.tie(0), cin.sync_with_stdio(0), cout.sync_with_stdio(0);
#define ll long long
#define ld long double
#define EPS 1e-9
#define INF INT_MAX
#define pb push_back
#define pf push_front
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define rep(i, k, n) for(int i=k; i < n ; i++)
#define rev(i, n, k) for(int i = n; i>= k; i--)
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define NIL -1
// alt + ctrl + l
// يا رب
const ll MOD = 1000000007;
const ll N = 100;
const ll C = 10;
//const ll K = 5;
const ll M = 10;
//const int OO=0x3f3f3f3f;
//const ll LOO=0x3f3f3f3f3f3f3f3f;
//int dx8[] = {+0, +0, -1, +1, +1, +1, -1, -1};
//int dy8[] = {-1, +1, +0, +0, +1, -1, +1, -1};
//int dx4[] = {+0, +0, -1, +1};
//int dy4[] = {-1, +1, +0, +0};
//struct cmp {
// bool operator()(M const& p1, M const& p2)
// {
// return p1.dis > p2.dis;
// }
//};
int main() {
Yalahwy
ll T = 1;
// cin >> T;
while (T--){
ll n, x, y, z;
string a, b, s;
cin >> n >> x >> y >> z >> a >> b >> s;
bool ok = true;
vector<ll> v;
vector<bool> bo(n, false);
vector<char> ans(n);
for (int i = 0; i < n; ++i) {
if(a[i] == '1' && b[i] == '1' && s[i] == '0'){
if(z){
z--;
ans[i] = '^';
bo[i] = true;
}
else{
ok = false;
break;
}
}
else if( (a[i] != b[i]) && s[i] == '0'){
if(x){
x--;
ans[i] = '&';
bo[i] = true;
}
else{
ok = false;
break;
}
}
}
for (int i = 0; i < n; ++i) {
if(bo[i])continue;
if(a[i] == '0' && b[i] == '0' && s[i] == '0'){
v.push_back(i);
}
else if(a[i] == '0' && b[i] == '0' && s[i] == '1'){
ok = false;
break;
}
else if(((a[i] == '1' && b[i] == '0') || (a[i] == '0' && b[i] == '1')) && s[i] == '0'){
if(x){
x--;
ans[i] = '&';
}
else{
ok = false;
break;
}
}
else if(((a[i] == '1' && b[i] == '0') || (a[i] == '0' && b[i] == '1')) && s[i] == '1'){
if(z){
z--;
ans[i] = '^';
}
else if(y){
y--;
ans[i] = '|';
}
else{
ok = false;
break;
}
}
else if(a[i] == '1' && b[i] == '1' && s[i] == '0'){
if(z){
z--;
ans[i] = '^';
}
else{
ok = false;
break;
}
}
else if(a[i] == '1' && b[i] == '1' && s[i] == '1'){
if(x){
x--;
ans[i] = '&';
}
else if(y) {
y--;
ans[i] = '|';
}
else{
ok = false;
break;
}
}
}
for (int i = 0; i < v.size(); ++i) {
if(x){
x--;
ans[v[i]] = '&';
}
else if(y){
y--;
ans[v[i]] = '|';
}
else if(z){
z--;
ans[v[i]] = '^';
}
else{
ok = false;
}
}
if(ok){
yes
for(auto f: ans){
cout << f;
}
cout << endl;
}
else{
no
}
}
}
Copy