import java.io.*;
import java.util.*;

public class formula_md_assert  {
	private static Scanner in;
	private static PrintWriter out;
	
	static final int OR = 1;
	static final int AND = 2;
	static final int NOT = 3;
	static final int VAR = 4;
	
	static final int N = 11;
	static final int MAX = 1 << N;

	String formula;
	int pos;
	char token;
	ArrayList<Integer> op = new ArrayList<Integer>();
	ArrayList<Integer> op1 = new ArrayList<Integer>();
	ArrayList<Integer> op2 = new ArrayList<Integer>();
	int m;
	
	int addOp(int binOp, int oper1, int oper2) {
		op.add(binOp);
		op1.add(oper1);
		op2.add(oper2);
		return m++;
	}
	
	void nextToken() {
		while (pos < formula.length() && formula.charAt(pos) == ' ')
			pos++;
		if (pos == formula.length()) {
			token = 0;
			return;
		}
		token = formula.charAt(pos++);
	}
	
	int parseTerm() {
		if (token == '~') {
			nextToken();
			return addOp(NOT, parseTerm(), 0);
		}
		if (token == '(') {
			nextToken();
			int result = parseOr();
			if (token != ')')
				throw new RuntimeException("Invalid parentheses");
			nextToken();
			return result;
		}
		if (token >= 'a' && token <= 'k') {
			char var = token;
			nextToken();
			return addOp(VAR, var - 'a', 0);
		}
		throw new RuntimeException("Invalid token: \"" + token + "\"");
	}
	
	int parseAnd() {
		int op1 = parseTerm();
		while (token == '&') {
			nextToken();
			op1 = addOp(AND, op1, parseTerm());
		}
		return op1;
	}
	
	int parseOr() {
		int op1 = parseAnd();
		while (token == '|') {
			nextToken();
			op1 = addOp(OR, op1, parseAnd());
		}
		return op1;
	}
	
	private void solve(String s) {
		if (s.length() > 1000)
			throw new RuntimeException("Formula is too long");
		formula = s;
		pos = 0;
		m = 0;
		nextToken();
		parseOr();
		if (token != 0)
			throw new RuntimeException("Extra tokens after formula");
		boolean[] value = new boolean[m];
		boolean[] table = new boolean[MAX];
		for (int mask = 0; mask < MAX; mask++) {
			for (int i = 0; i < m; i++) {
				switch (op.get(i)) {
				case OR:
					value[i] = value[op1.get(i)] || value[op2.get(i)];
					break;
				case AND:
					value[i] = value[op1.get(i)] && value[op2.get(i)];
					break;
				case NOT:
					value[i] = !value[op1.get(i)];
					break;
				case VAR:
					value[i] = (mask & (1 << (op1.get(i)))) > 0;
					break;
				}
			}
			table[mask] = value[m - 1];
		}
		int useful = 0;
		iloop:
		for (int i = 0; i < N; i++) {
			for (int mask = 0; mask < MAX; mask++) {
				if (table[mask] != table[mask ^ (1 << i)]) {
					useful |= 1 << i;
					continue iloop;
				}
			}
		}
		String ans = solve(table, useful);
		out.println(ans.contains("#") ? "No" : "Yes\n" + ans);
	}
	
	private String solve(boolean[] table, int vars) {
		if (vars == 0)
			return "#";
		if ((vars & (vars - 1)) == 0) {
			String not = table[vars] ? "" : "~";
			char var = 'a';
			while (vars > 1) {
				vars /= 2;
				var++;
			}
			return not + var;
		}
		boolean[] seen = new boolean[2];
		boolean[] mustbe = new boolean[2];
		boolean saved, badlvars;
		boolean[] current = new boolean[MAX];
		boolean[] save = new boolean[MAX];
		boolean[] goodleft = new boolean[MAX];
		boolean[] goodleft2 = new boolean[MAX];
		for (int lvars = (vars - 1) & vars; lvars > 0; lvars = ((lvars - 1) & vars)) {
			int rvars = vars ^ lvars;
			saved = false;
			badlvars = false;
			mustbe[0] = mustbe[1] = false;
			// TODO quicken
			Arrays.fill(current, false);
			Arrays.fill(save, false);
			Arrays.fill(goodleft, false);
			Arrays.fill(goodleft2, false);
			for (int left = lvars;; left = ((left - 1) & lvars)) {
				seen[0] = seen[1] = false;
				for (int right = rvars;; right = ((right - 1) & rvars)) {
					boolean v = table[left | right];
					seen[v ? 1 : 0] = true;
					current[right] = v;
					if (right == 0)
						break;
				}
				if (seen[0] && seen[1]) {
					goodleft[left] = true;
					if (!saved) {
						// TODO quicken
						System.arraycopy(current, 0, save, 0, MAX);
						saved = true;
					} else {
						// TODO quicken
						if (!Arrays.equals(current, save))
							badlvars = true;
					}
				} else {
					goodleft2[left] = true;
					mustbe[0] |= seen[0];
					mustbe[1] |= seen[1];
				}
				if (left == 0)
					break;
			}
			if (badlvars || !saved)
				continue;
			if (mustbe[0] == mustbe[1])
				continue;
			String right = solve(save, rvars);
			if (mustbe[0]) {
				return "(" + solve(goodleft, lvars) + ")&(" + right + ")";
			}
			return solve(goodleft2, lvars) + "|" + right;
		}
		return "#";
	}

	public static void main(String[] args) throws IOException {
		Locale.setDefault(Locale.US);
		in = new Scanner(new FileReader("formula.in"));
		out = new PrintWriter("formula.out");
		while (in.hasNext()) {
			new formula_md_assert().solve(in.nextLine());
		}
		in.close();
		out.close();
	}
}
