#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[300000];
for (int i = 0; i < n; i++) {
if (a[i] == '1' && b[i] == '1' && s[i] == '1') {
if (And != 0)
{
c[i] = '&';
And--;
}
else if (OR != 0) {
c[i] = '|';
OR--;
}
else {
cout << "NO";
return;
}
}
else if (a[i] == '0' && b[i] == '0' && s[i] == '0') {
if (And != 0)
{
c[i] = '&';
And--;
}
else if (OR != 0) {
c[i] = '|';
OR--;
}
else if (XOR != 0) {
c[i] = '^';
XOR--;
}
else {
cout << "NO";
return;
}
}
else if (a[i] == '0' && b[i] == '1' && s[i] == '0') {
if (And != 0)
{
c[i] = '&';
And--;
}
else {
cout << "NO";
return;
}
}
else if (a[i] == '0' && b[i] == '1' && s[i] == '1') {
if (OR != 0) {
c[i] = '|';
OR--;
}
else if (XOR != 0) {
c[i] = '^';
XOR--;
}
else {
cout << "NO";
return;
}
}
else if (a[i] == '1' && b[i] == '0' && s[i] == '0') {
if (And != 0) {
c[i] = '&';
And--;
}
else {
cout << "NO";
return;
}
}
else if (a[i] == '1' && b[i] == '0' && s[i] == '1') {
if (OR != 0) {
c[i] = '|';
OR--;
}
else if (XOR != 0) {
c[i] = '^';
XOR--;
}
else {
cout << "NO";
return;
}
}
else if (a[i] == '1' && b[i] == '1' && s[i] == '0') {
if (XOR != 0) {
c[i] = '^';
XOR--;
}
else {
cout << "NO";
return;
}
}
else if (a[i] == '0' && b[i] == '0' && s[i] == '1') {
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 ;
return ;
}//4 2 1 1
//1001
//0101
//1101
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