import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.Vector;


public class ANARC_2010_C_Alt
{
	BufferedReader in;
	Scanner inr;
	PrintWriter out;

	void initIO() throws IOException
	{
		inr = new Scanner(System.in);
		in = new BufferedReader(new InputStreamReader(
				System.in));
		out = new PrintWriter(new OutputStreamWriter(System.out));
	}
	
	String s;
	
	boolean res;
	
	int p;
	
	int depth()
	{
		int res = 0;
		if (s.charAt(p) == '(')
		{
			p++;
			while (s.charAt(p) != ')')
				res = Math.max(res, depth() + 1);
			p++;
		}
		else
			p++;
		return res;
	}
	
	void debug(Object o)
	{
		//out.print(o);
	}
	
	boolean parse(boolean f)
	{
		boolean res = true;
		if (s.charAt(p) == '(')
		{
			int c = 0;
			p++;
			debug("(");
			while (s.charAt(p) != ')')
			{
				if (c++ > 0) debug(f ? " | " : " & ");
				boolean t = parse(!f);
				if (c == 1)
					res = t;
				else
				{
				if (f)
					res |= t;
				else
					res &= t;
				}
			}
			debug("= " + res + " )");
			p++;
		}
		else
		{
			debug(s.charAt(p));
			res = s.charAt(p++) == 'T';
		}
		return res;
	}
	
	void calc()
	{
		p = 0;
		int d = depth();
		p = 0;
		res = parse(d % 2 == 0);
	}
	
	void solve() throws Exception
	{
		int nt = 0;
		while (true)
		{
			s = in.readLine();
			if ("()".equals(s))
				break;
			calc();
			out.println("" + (++nt) + ". " + (res ? "true" : "false"));
		}
	}

	void run() throws Exception
	{
		initIO();
		solve();
		out.flush();
	}

	int nextInt()
	{
		return inr.nextInt();
	}
	
	String nextLine()
	{
		return inr.nextLine();
	}
	
	String nextString()
	{
		return inr.next();
	}

	public static void main(String[] args) throws Exception
	{
		new ANARC_2010_C_Alt().run();
	}
}
