from __future__ import print_function

class Node(object):
	def __init__(self):
		self.edges = {} 
		self.link = None 
		self.len = 0 

class Eertree(object):
	def __init__(self):
		self.nodes = []
		
		self.rto = Node() 
		self.rte = Node() 

		
		self.rto.link = self.rte.link = self.rto;
		self.rto.len = -1
		self.rte.len = 0
		self.S = [0] 
		self.maxSufT = self.rte 

	def get_max_suffix_pal(self, startNode, a):
		
		
		
		u = startNode
		i = len(self.S)
		k = u.len
		while id(u) != id(self.rto) and self.S[i - k - 1] != a:
			assert id(u) != id(u.link) 
			u = u.link
			k = u.len

		return u

	def add(self, a):

		
		
		
		
		Q = self.get_max_suffix_pal(self.maxSufT, a)

		
		createANewNode = not a in Q.edges

		if createANewNode:
			
			P = Node()
			self.nodes.append(P)
			P.len = Q.len + 2
			if P.len == 1:
				
				P.link = self.rte
			else:
				
				
				
				P.link = self.get_max_suffix_pal(Q.link, a).edges[a]

			
			Q.edges[a] = P

		
		self.maxSufT = Q.edges[a]

		
		self.S.append(a)

		return createANewNode

	def get_sub_palindromes(self, nd, nodesToHere, charsToHere, result):
		
		

		
		for lnkName in nd.edges:
			nd2 = nd.edges[lnkName] 
			self.get_sub_palindromes(nd2, nodesToHere+[nd2], charsToHere+[lnkName], result)

		
		if id(nd) != id(self.rto) and id(nd) != id(self.rte): 
			tmp = .join(charsToHere)
			if id(nodesToHere[0]) == id(self.rte): 
				assembled = tmp[::-1] + tmp
			else: 
				assembled = tmp[::-1] + tmp[1:]
			result.append(assembled)

if __name__==:
	st = 
	print (, st)
	eertree = Eertree()
	for ch in st:
		eertree.add(ch)

	print (, len(eertree.nodes))

	
	result = []
	eertree.get_sub_palindromes(eertree.rto, [eertree.rto], [], result) 
	eertree.get_sub_palindromes(eertree.rte, [eertree.rte], [], result) 
	print (, result)