// Arup Guha
// 3/22/2026
// Solution to Kattis Problem: Circuit Math
// Used to illustrate use of ArrayDeque for COP 3330.

import java.util.*;

public class circuitmath {

	public static void main(String[] args) {
	
		// Read in number of variables set up variable storage.
		Scanner stdin = new Scanner(System.in);
		int n = Integer.parseInt(stdin.nextLine());
		boolean[] values = new boolean[n];
		
		// Set up next line.
		StringTokenizer tok = new StringTokenizer(stdin.nextLine());
		
		// Set variables appropriately.
		for (int i=0; i<n; i++) 
			values[i] = tok.nextToken().equals("T");
			
		// Get the expression.
		tok = new StringTokenizer(stdin.nextLine());
		
		// Set up stack.
		ArrayDeque<Boolean> stack = new ArrayDeque<Boolean>();
		
		// Go through the expression.
		while (tok.hasMoreTokens()) {
		
			// Get character input.
			char tmp = tok.nextToken().charAt(0);
			
			// Variable add to stack.
			if (tmp >= 'A' && tmp <= 'Z') 
				stack.addLast(values[tmp-'A']);
			
			// Operator...
			else {
			
				// Special case, pop 1, push its negation.
				if (tmp == '-') {
					boolean top = stack.pollLast();
					stack.addLast(!top);
				}
				
				// Regular case.
				else {
				
					// Pop the last two.
					boolean op2 = stack.pollLast();
					boolean op1 = stack.pollLast();
				
					// Push back the appropriate answer.
					if (tmp == '+') 
						stack.addLast(op1 || op2);
					else 
						stack.addLast(op1 && op2);
				}
			}
		} // end while.
		
		// Print accordingly.
		if (stack.pollLast())
			System.out.println("T");
		else
			System.out.println("F");
	}
}