// Rochelle Elva
// 7/23/08
// Solution to BHCSI Contest Problem: Pal

import java.io.*;
import java.util.*;

public class pal {
	
	public static void main(String[] args){
		
		try{
		
		 	Scanner input = new Scanner(new File("pal.in"));
		 
		 	int numWords =  input.nextInt();
		 
        	//Read File Line By Line
   			String[] pwords = new String[numWords];
			String[] npwords = new String[numWords];
			int pwd = 0;
			int npwd = 0;
		
			for(int i = 0; i < numWords; i++){
			
		   		String word = input.next();
		   	
		   		if(ispal(word)){
		   	 		pwords[pwd] = word;
		   	 		pwd++;
		   		}//end if
		   		else {
		   			npwords[npwd] = word;
		   			npwd++;
		   		}//end else
		   
			}//end for 
	    	input.close() ;	
		
			//print output
	    	//print list of palindromes
			System.out.println("Palindromes:");
			for(int i = 0; i < pwd; i++){
		  		System.out.println(pwords[i]);	
			}
		
			//print list of non-palindromes
			System.out.println();
			System.out.println("Non-palindromes:");
		
			for(int i = 0; i < npwd; i++){
				System.out.println(npwords[i]);	
			}
			
		}//end try 
		catch (IOException e) {
    	}
	  	
	}//end main
//----------------------------------------------------------------------

	public static boolean ispal(String wd){
		int left = 0;
		int right = wd.length()- 1;
		while(left < right){
			if(wd.charAt(left)!= wd.charAt(right))
				return false;
			else{
				left++;
				right--;
			}
		}//end while
	return true;
	}//end method
//---------------------------------------------------	
}//end class