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

public class boole
{
		static TreeSet pp;
		static int maxVPos;
		static StringBuffer out;
		static boolean[] p2v;
		static int[] i2p;
		static Node root;

		public static void main(String[] args)
				throws IOException
		{
				BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
				String s;
				while ((s = in.readLine()) != null) {
						pp = new TreeSet();
						maxVPos = 0;
						root = new Node(s, new ParsePosition(0));
						p2v = new boolean[26];
						i2p = new int[pp.size()];
						int j = 0;
						for (Iterator it = pp.iterator(); it.hasNext(); ) {
								i2p[j++] = ((Character) it.next()).charValue() - 'a';
						}

						out = new StringBuffer(s.length());
						for (int i = 0; i < s.length(); ++i)
								out.append(' ');
						System.out.println(s);
						printTab(0);
						System.out.println();
				}
		}


		static void printTab(int vi)
		{
				if (vi >= i2p.length) {
						root.eval();
						System.out.println(out);
						return;
				}
				p2v[i2p[vi]] = false;
				printTab(vi + 1);
				p2v[i2p[vi]] = true;
				printTab(vi + 1);
		}


		static int nnws(String s, int i)
		{
				int n = s.length();
				while (i < n && Character.isWhitespace(s.charAt(i)))
						++i;
				return i == n ? -1 : i;
		}


		static int expect(char c, String s, int i)
		{
				i = nnws(s, i);
				if (s.charAt(i) != c)
						throw new RuntimeException("unexpected char " + s.charAt(i));
				return i;
		}

		static class Node
		{
				private final int vpos;
				private final char op;
				private final Node left, right;

				void put(boolean v)
				{
						out.setCharAt(vpos, v ? '1' : '0');
				}

				boolean eval()
				{
						boolean e;
						switch (op) {
						case '!':
								e = (! left.eval());
								break;
								
						case '<':
								e = (left.eval() == right.eval());
								break;
								
						case '-':
								e = ((! left.eval()) | right.eval());
								break;

						case '&':
								e = (left.eval() & right.eval());
								break;

						case '|':
								e = (left.eval() | right.eval());
								break;

						default:
								e = (p2v[op - 'a']);
								break;
						}
						put(e);
						return e;
				}


				Node(String s, ParsePosition p)
				{
						int i = nnws(s, p.getIndex());
						if (s.charAt(i) == '(') {
								i = nnws(s, i + 1);
								if (s.charAt(i) == '!') {
										op = '!';
										vpos = i;
										p.setIndex(i + 1);
										left = new Node(s, p);
										right = null;
								} else {
										p.setIndex(i);
										left = new Node(s, p);
										i = nnws(s, p.getIndex());
										op = s.charAt(i);
										if (op == '<' || op == '-') {
												vpos = expect('-', s, i + 1);
												i = expect('>', s, vpos + 1);
										} else
												vpos = i;
										p.setIndex(i + 1);
										right = new Node(s, p);
								}
								i = expect(')', s, p.getIndex()) + 1;
						} else if (Character.isLowerCase(s.charAt(i))) {
								op = s.charAt(i);
								pp.add(new Character(op));
								vpos = i;
								++i;
								left = right = null;
						} else
								throw new RuntimeException("bumm " + s.charAt(i));
						p.setIndex(i);
						if (maxVPos < vpos) maxVPos = vpos;
				}
		}
}
