#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds; // pb_ds
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fi first
#define se second
#define EPS (1e-9)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define debug(x) cerr << #x << ": " << (x) << endl;
void _IO_() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#ifdef ELARABY
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
}
// N E S W NW NE SE SW
//int dr[] = {-1, 0, 1, 0, -1, -1, 1, 1};
//int dc[] = {0, 1, 0, -1, -1, 1, 1, -1};
template<typename T>
void input(vector<T> &v) {
for (T &i: v) {
cin >> i;
}
}
template<typename T>
void output(const vector<T> &v, const int inc = 0) {
for (int i = 0; i < int(v.size()); ++i) {
if (i) cout << ' ';
cout << v[i] + inc;
}
cout << '\n';
}
template<typename T>
void output(const vector<pair<T, T>> &v, const int inc1 = 0, const int inc2 = 0) {
for (int i = 0; i < int(v.size()); ++i) {
cout << v[i].first + inc1 << ' ' << v[i].second + inc2 << '\n';
}
}
void output(const string &s, const int st, const int ed) {
for (int i = st; i < ed; ++i) {
cout << s[i];
}
cout << '\n';
}
//////////////////------PROBLEM SOLUTIONS START FROM HERE------///////////////////
int n, x, y, z;
string a, b, s;
string solve() {
string c(n, '.');
for (int i = 0; i < n; ++i) {
if ((a[i] != b[i]) && s[i] == '0') {
--x;
c[i] = '&';
}//
else if (a[i] == '1' && b[i] == '1' && s[i] == '0') {
--z;
c[i] = '^';
}//
else if (a[i] == '0' && b[i] == '0' && s[i] == '1') {
return "NO";
}
}
if (x < 0 || y < 0 || z < 0) return "NO";
for (int i = 0; i < n; ++i) {
if (a[i] == '1' && b[i] == '1' && s[i] == '1') {
if (x > 0) --x, c[i] = '&';
else --y, c[i] = '|';
}//
else if ((a[i] != b[i]) && s[i] == '1') {
if (z > 0) --z, c[i] = '^';
else --y, c[i] = '|';
}//
}
if (x < 0 || y < 0 || z < 0) return "NO";
for (int i = 0; i < n; ++i) {
if (a[i] == '0' && b[i] == '0' && s[i] == '0') {
if (x > 0) --x, c[i] = '&';
else if (y > 0) --y, c[i] = '|';
else if (z > 0) --z, c[i] = '^';
}//
}
if (x == 0 && y == 0 && z == 0) return c;
return "NO";
}
int main() {
_IO_();
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
cin >> n >> x >> y >> z;
cin >> a >> b >> s;
string ans = solve();
if (ans == "NO") cout << ans;
else cout << "YES\n" << ans;
return 0;
}
Copy