// Arup Guha
// 11/15/2013
// Adapted from Java Solution to 2010 ACPC Problem C: Normalized Form

#include <stdio.h>

#define MAX 32001

struct node {
    char c;
    struct node* next;
};

typedef struct node nodeT;

typedef struct {
    nodeT* top;
} Stack;

// Functions that help solve the problem.
int getDepth(char* s) ;
int solve(char* expr);

// Linked List helper functions.
nodeT* insertFront(nodeT* front, char ch);
char atFront(nodeT* front);
nodeT* deleteFront(nodeT* front);

// Stack functions.
void initStack(Stack* s);
void push(Stack* s, char ch);
char pop(Stack* s);

int main() {

    char expr[MAX];
    scanf("%s", expr);
    int loop = 1;

    // Process cases
    while (strcmp(expr,"()")) {

        // Output result.
        if (solve(expr))
            printf("%d. true\n", loop);
        else
            printf("%d. false\n", loop);

        // Get next expression.
        scanf("%s", expr);
        loop++;
    }

    return 0;
}

// Returns the maximum nesting of parens in s.
int getDepth(char* s) {

    int i, cnt = 0, max = 0;
    for (i=0; i<strlen(s); i++) {
        if (s[i] =='(')
            cnt++;
        else if (s[i] == ')')
            cnt--;
        if (cnt > max) max = cnt;
    }
    return max;
}

int solve(char* expr) {

    int maxDepth = getDepth(expr), i;

    Stack s;
    initStack(&s);
    int curDepth = 0;

    // Process expression forward.
    for (i=0; i<strlen(expr); i++) {

        char c = expr[i];

        // Put on stack and change current level.
        if (c == '(') {
            push(&s, c);
            curDepth++;
        }

        // These just go on the stack.
        else if (c == 'T' || c == 'F')
            push(&s, c);

        // Here we finish a tree of some sort.
        else {

            int hasTrue = 0;
            int hasFalse = 0;

            // Pop off stack until we get open paren.
            while (1) {

                c = pop(&s);

                // Mark character, or get out.
                if (c == 'T') hasTrue = 1;
                else if (c == 'F') hasFalse = 1;
                else break;
            }

            // And case.
            if ((maxDepth - curDepth)%2 == 0) {
                if (hasFalse) push(&s, 'F');
                else          push(&s, 'T');
            }

            // Or case.
            else {
                if (hasTrue) push(&s, 'T');
                else         push(&s, 'F');
            }

            // Change in depth also...
            curDepth--;
        }
    } // end for

    // Here is what we care about.
    return pop(&s) == 'T';
}

// Creates a new node storing ch, inserts it to the front of the list
// pointed to by front and returns a pointer to the new front of the list.
nodeT* insertFront(nodeT* front, char ch) {
    nodeT* newnode = malloc(sizeof(nodeT));
    newnode->c = ch;
    newnode->next = front;
    return newnode;
}

// Returns the character at the front of the list pointed to by front.
// Must NOT be called on a NULL list.
char atFront(nodeT* front) {
    return front->c;
}

// Deletes the front node of the list pointed to by front and returns the
// new front of the list.
nodeT* deleteFront(nodeT* front) {
    nodeT* rest = front->next;
    free(front);
    return rest;
}

// Initializes an empty stack.
void initStack(Stack* s) {
    s->top = NULL;
}

// Pushes ch onto the stack pointed to by s.
void push(Stack* s, char ch) {
    s->top = insertFront(s->top, ch);
}

// Pop's the top element off the Stack pointed to by s and returns it.
char pop(Stack* s) {
    char retval = atFront(s->top);
    s->top = deleteFront(s->top);
    return retval;
}
