#include <iostream>
#include<algorithm>
#include <cmath>
using namespace std;
//0 0 0
//0 0 1
/*
010
011
100
101
110
111
*/
void f(string s, string a, string b, int And, int OR, int XOR, int n) {
if (n != And + OR + XOR)
{
cout << "NO";
return;
}
char *c;
for (int i = 0; i < n; i++) {
if (a[i] == b[i] == 0 && s[i] == 1)
{
cout << "NO";
return;
}
else if (a[i] == b[i] && s[i] == 0) {
if (XOR != 0)
{
XOR--;
c[i] = '^';
}
else {
cout << "NO";
return;
}
}
else if (a[i] != b[i] && s[i] == 0) {
if (And != 0)
{
And--;
c[i] = '&';
}
else
{
cout << "NO";
return;
}
}
else if (a[i] == b[i] == s[i] == 1) {
if (And != 0) {
And--;
c[i] = '&';
}
else if (OR != 0) {
OR--;
c[i] = '|';
}
else {
cout << "NO";
return;
}
}
else if ((a[i] != b[i]) && s[i] == 1)
{
if (XOR != 0) {
XOR--;
c[i] = '^';
}
else if (OR != 0) {
OR--;
c[i] = '|';
}
else {
cout << "NO";
return;
}
}
else if (a[i] == b[i] ==s[i] == 0) {
if (And != 0)
{
And--;
c[i] = '&';
}
else if (XOR != 0) {
XOR--;
c[i] = '^';
}
else if (OR != 0) {
OR--;
c[i] = '|';
}
else {
cout << "NO";
return;
}
}
}
if (And != 0 || OR != 0 || XOR != 0)
{
cout << "NO";
return;
}
cout << "YES" << endl;
for (int i = 0; i < n; i++)
cout << c[i];
return ;
}
int main() {
int n, And, OR, XOR;
cin >> n >> And >> OR >> XOR;
string s, c, a, b;
cin >> a >> b >> s;
f(s, a, b, And, OR, XOR, n);
return 0;
}
Copy