/** 2008 WCU Computer Science High School Programming Contest
* Solution to Problem One, Copyright 2008, all rights reserved
* Western Carolina University 
* Department of Mathematics and Computer Science
*/
import java.io.*;
import java.util.*;

public class Problem1 
{
	
  /** This class returns the 'reverse' version of a character is 
  * such exists; otherwise the character itself is returned. */
  public static char reverseChar(char c) 
  {
    switch(c) {
      case '(': return ')';
	case ')': return '(';
			
	case '{': return '}';
	case '}': return '{';
			
	case '[': return ']';
	case ']': return '[';
			
	case '<': return '>';
	case '>': return '<';
			
	default: return c;
    }
  }
	
  /** This function returns true or false whether the passed 
  * argument is a palindrome or not. */
  public static boolean isPalindrome(String str) 
  {
    // try matching char-by-char reading from both sides 
    // at once
    for(int i = 0; i < str.length() / 2; i++) 
    {
      if (str.charAt(i) != reverseChar(
        str.charAt(str.length()-1-i))) 
        {
          return false;
        }
    }
		
    // special case - strings of odd length:
    // the central character cannot be a reversible character
    if (str.length() % 2 == 1)
      if (str.charAt(str.length() / 2) != 
        reverseChar(str.charAt(str.length() / 2)))
          return false;
		
    return true;
  }
	
	
  public static void main(String[] args) 
  {
    Scanner scanIn = new Scanner(System.in);
		
    while(true) 
    {
      // get user input
      System.out.println(">> input phrase (type 'quit' to exit " +
        "the program):");
      String line = scanIn.nextLine();
			
      // check for need to quit
      if (line.equals("quit")) System.exit(0);
			
      // check for palindrome
      if (isPalindrome(line))
        System.out.println("\nThis is a palindrome.\n");
      else
        System.out.println("\nThis is not a palindrome.\n");
				
    }     // end of while
  }
}