Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?

The book contains a single string of characters "a", "b" and "c". It has been pointed out that no two consecutive characters are the same. It has also been conjectured that the string contains an unusually long subsequence that reads the same from both sides. 

Help Alice verify this by finding such subsequence that contains at least half of the characters of the original string, rounded down. Note that you don't have to maximise the length of it.

A string a is a subsequence of a string b if a can be obtained from b by deletion of several (possibly, zero or all) characters.

Input

The input consists of a single string s (2 ≤ |s| ≤ 10^6). The string s consists only of characters "a", "b", "c". It is guaranteed that no two consecutive characters are equal.

Output

Output a palindrome t that is a subsequence of s and |t| ≥ ⌊ (|s|)/(2) ⌋.

If there are multiple solutions, you may print any of them. You don't have to maximise the length of t.

If there are no solutions, output a string "IMPOSSIBLE" (quotes for clarity).

Examples

Input


cacbac


Output


aba


Input


abc


Output


a


Input


cbacacacbcbababacbcb


Output


cbaaacbcaaabc

Note

In the first example, other valid answers include "cacac", "caac", "aca" and "ccc".

Source: codeforces | Difficulty: HARD
Tags: Greedy algorithms

String algorithms

Complete search

Constructive algorithms


Solutions:
s = input()
n = len(s)
b = []
for j in s:
	b.append(j)
x = []
y = []
j = 0
i = n - 1
while j < i:
	if b[j] == b[i]:
		if i != j:
			x.append(b[j])
			y.append(b[i])
		else:
			x.append(b[j])
		i += -1
		j += 1
	elif b[j] == b[i - 1]:
		if i - 1 != j:
			x.append(b[j])
			y.append(b[i - 1])
		else:
			x.append(b[j])
		j += 1
		i += -2
	elif b[j + 1] == b[i]:
		if i != j + 1:
			x.append(b[j + 1])
			y.append(b[i])
		elif i == j + 1:
			x.append(b[j + 1])
		i += -1
		j += 2
	else:
		if i - 1 != j + 1:
			x.append(b[j + 1])
			y.append(b[i - 1])
		elif i - 1 == j + 1:
			x.append(b[j + 1])
		i += -2
		j += 2
res = x + y[::-1]
print(''.join(res))


s = input()
left = 0
right = len(s) - 1
out = ''
needed = len(s) // 2
if len(s) <= 3:
	print(s[0])
else:
	while right - left >= 3 and len(out) < needed:
		if s[left] == s[right]:
			out += s[left]
			left += 1
			right -= 1
		elif s[left] == s[right - 1]:
			out += s[left]
			left += 1
			right -= 2
		else:
			out += s[left + 1]
			if s[left + 1] == s[right]:
				right -= 1
			else:
				right -= 2
			left += 2
	if left <= right:
		print(out + s[left] + out[::-1])
	else:
		print(out + out[::-1])


s = input()
n = len(s)
i = 0
j = n - 1
ans = [-1] * n
while i < j:
	if s[i] != s[j]:
		if s[i + 1] == s[j - 1]:
			ans[i + 1] = ans[j - 1] = s[i + 1]
			i += 2
			j -= 2
		elif s[i] == s[j - 1]:
			ans[i] = ans[j - 1] = s[i]
			i += 1
			j -= 2
		elif s[i + 1] == s[j]:
			ans[i + 1] = ans[j] = s[j]
			i += 2
			j -= 1
	else:
		ans[i] = ans[j] = s[i]
		i += 1
		j -= 1
a = ''
for i in ans:
	if i != -1:
		a += i
if len(ans) < n // 2:
	print('IMPOSSIBLE')
	exit()
print(a)


s = input().strip()
n = len(s)
if n <= 3:
	print(s[0])
else:
	ans = ''
	(start, end) = (0, n - 1)
	while start + 1 < end - 1:
		if s[start] == s[end] or s[start] == s[end - 1]:
			ans += s[start]
		else:
			ans += s[start + 1]
		start += 2
		end -= 2
	t = len(ans)
	if 2 * t < n // 2:
		ans = ans + s[start] + ans[::-1]
		print(ans)
	else:
		print(ans + ans[::-1])


from collections import deque
s = input()
result = []
l = len(s)
i = 0
j = l - 1
count = 0
if l < 2:
	exit(0)
while j > i and count < l // 2:
	if s[i] == s[j]:
		result.append(s[i])
		i += 1
		j -= 1
		count += 2
	elif s[i] == s[j - 1] and j > i + 1:
		result.append(s[i])
		i += 1
		j -= 2
		count += 2
	elif s[i + 1] == s[j] and j > i + 1:
		result.append(s[i + 1])
		i += 2
		j -= 1
		count += 2
	elif s[i + 1] == s[j - 1] and j > i + 2:
		result.append(s[i + 1])
		i += 2
		j -= 2
		count += 2
	else:
		break
rev = result.copy()
rev.reverse()
if count < l / 2:
	print(''.join(result + [s[i]] + rev))
else:
	print(''.join(result + rev))


line = input()
n = len(line)

def f(left, right):
	d = [0 for _ in range(n + 1)]
	cnt = 0
	if left + 2 == right:
		d[left + 1] = 1
		cnt += 1
	while left >= 0 and right < n:
		if line[left] == line[right]:
			d[left] = 1
			d[right] = 1
			left -= 1
			right += 1
			cnt += 2
		elif left - 1 >= 0 and right + 1 < n and (line[left - 1] == line[right + 1]):
			d[left - 1] = 1
			d[right + 1] = 1
			left -= 2
			right += 2
			cnt += 2
		elif right + 1 < n and line[left] == line[right + 1]:
			d[left] = 1
			d[right + 1] = 1
			left -= 1
			right += 2
			cnt += 2
		elif left - 1 >= 0 and line[left - 1] == line[right]:
			d[left - 1] = 1
			d[right] = 1
			left -= 2
			right += 1
			cnt += 2
		else:
			left -= 1
			right += 1
	if cnt >= n // 2:
		ans = []
		for (idx, c) in enumerate(line):
			if d[idx]:
				ans.append(c)
		return (True, ''.join(ans))
	return (False, '')
if n <= 3:
	print(line[0])
if n > 3:
	if n % 2:
		left = n // 2 - 1
		right = n // 2 + 1
	else:
		left = n // 2 - 1
		right = n // 2
	(flag, ans) = f(left, right)
	while not flag:
		for i in range(n):
			(flag, ans) = f(i, i + 2)
			if flag:
				break
	print(ans)


from array import array
import math
import sys
DEBUG = False

def inp():
	return sys.stdin.readline().rstrip()

def dprint(*value, sep=' ', end='\n'):
	if DEBUG:
		print(*value, sep=sep, end=end)

def solve(S):
	N = len(S)
	la = array('i', [0] * (N + 2))
	ra = array('i', [0] * (N + 2))
	lb = array('i', [0] * (N + 2))
	rb = array('i', [0] * (N + 2))
	lc = array('i', [0] * (N + 2))
	rc = array('i', [0] * (N + 2))
	la[N + 1] = N
	ra[0] = -1
	lb[N + 1] = N
	rb[0] = -1
	lc[N + 1] = N
	rc[0] = -1
	for i in range(N - 1, -1, -1):
		if S[i] == 'a':
			la[i + 1] = i
		else:
			la[i + 1] = la[i + 2]
		if S[i] == 'b':
			lb[i + 1] = i
		else:
			lb[i + 1] = lb[i + 2]
		if S[i] == 'c':
			lc[i + 1] = i
		else:
			lc[i + 1] = lc[i + 2]
	for i in range(N):
		if S[i] == 'a':
			ra[i + 1] = i
		else:
			ra[i + 1] = ra[i]
		if S[i] == 'b':
			rb[i + 1] = i
		else:
			rb[i + 1] = rb[i]
		if S[i] == 'c':
			rc[i + 1] = i
		else:
			rc[i + 1] = rc[i]
	dprint('lc', lc)
	dprint('rc', rc)
	rep = []
	mid = []
	li = 0
	ri = N
	while li < ri:
		dprint(li, ri)
		if ri - li == 1:
			mid.append(S[li])
			break
		al = la[li + 1]
		ar = ra[ri] + 1
		bl = lb[li + 1]
		br = rb[ri] + 1
		cl = lc[li + 1]
		cr = rc[ri] + 1
		da = ar - al
		db = br - bl
		dc = cr - cl
		dm = max(da, db, dc)
		dprint('clcr', cl, cr)
		if dm == da:
			if da > 1:
				rep.append('a')
			else:
				mid.append('a')
			li = al + 1
			ri = ar - 1
		elif dm == db:
			if db > 1:
				rep.append('b')
			else:
				mid.append('b')
			li = bl + 1
			ri = br - 1
		else:
			if dc > 1:
				rep.append('c')
			else:
				mid.append('c')
			li = cl + 1
			ri = cr - 1
	left = ''.join(rep)
	rep.reverse()
	right = ''.join(rep)
	return left + ''.join(mid) + right

def main():
	S = inp()
	print(solve(S))
main()


import math
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n
avl = AvlTree()

class SegmentTree1:

	def __init__(self, data, default='z', func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] >= k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater
s = input()
n = len(s)
ans = ''
ans1 = ''
t = 0
while n > 0:
	if n <= 3:
		ans += s[t]
		n -= 4
		continue
	if s[t] == s[-t - 1] or s[t] == s[-t - 2]:
		e = s[t]
	else:
		e = s[t + 1]
	ans += e
	ans1 += e
	n -= 4
	t += 2
print(ans + ans1[::-1])


import sys
input = lambda : sys.stdin.readline().strip()
s = list(input())
i = 0
j = len(s) - 1
res = ['']
while i < j - 2:
	if s[i] == s[j] or s[i] == s[j - 1]:
		res += s[i]
	else:
		res.append(s[i + 1])
	i += 2
	j -= 2
n = len(res)
if len(s) % 4:
	res.append(s[i])
for i in range(n - 1, -1, -1):
	res.append(res[i])
print(''.join(res))


s = input()
n = len(s)
cnt = {'a': 0, 'b': 0, 'c': 0}
for i in range(n):
	cnt[s[i]] += 1
base = 'a'
if cnt[s[0]] > cnt[base]:
	base = s[0]
if cnt[s[1]] > cnt[base]:
	base = s[1]
on = []
le = cnt[base]
for i in range(n):
	on.append(s[i] == base)
(bl, br) = (0, 0)
(il, ir) = (0, n - 1)
while le < n // 2 and il <= ir:
	if s[il] == base:
		bl += 1
		il += 1
	elif s[ir] == base:
		br += 1
		ir -= 1
	elif bl < br:
		il += 1
	elif bl > br:
		ir -= 1
	elif s[il] == s[ir]:
		on[il] = True
		on[ir] = True
		il += 1
		ir -= 1
		if il != ir:
			le += 2
		else:
			le += 1
	else:
		ir -= 1
if le >= n // 2:
	ans = ''.join([s[i] for i in range(n) if on[i]])
	print(ans)
else:
	print('IMPOSSIBLE')


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
from collections import defaultdict
from itertools import permutations
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys
input = lambda : sys.stdin.readline().strip()
s = list(input())
i = 0
j = len(s) - 1
res = ['']
while i < j - 2:
	if s[i] == s[j] or s[i] == s[j - 1]:
		res.append(s[i])
	else:
		res.append(s[i + 1])
	i += 2
	j -= 2
print(''.join(res + ([s[i]] if len(s) % 4 else ['']) + list(reversed(res))))


l1 = []
l2 = []
s = input()
n = len(s)
if n == 2 or n == 3:
	print(s[0])
	exit(0)
p = 0
q = n - 1
i = 0
while p + 1 < q - 1:
	a = s[p]
	b = s[p + 1]
	c = s[q]
	d = s[q - 1]
	if a == c:
		l1.append(a)
		l2.append(c)
		p += 1
		q -= 1
	elif a == d:
		l1.append(a)
		l2.append(d)
		p += 1
		q -= 2
	elif b == c:
		l1.append(b)
		l2.append(c)
		p += 2
		q -= 1
	elif b == d:
		l1.append(b)
		l2.append(d)
		p += 2
		q -= 2
l2.reverse()
if p <= q:
	print(''.join(l1), end='')
	print(s[p], end='')
	print(''.join(l2))
else:
	print(''.join(l1), end='')
	print(''.join(l2))


from sys import stdin, stdout
import collections
s = input()
N = len(s)
A = collections.deque()
B = collections.deque()
C = collections.deque()
for i in range(len(s)):
	if s[i] == 'a':
		A.append(i)
	elif s[i] == 'b':
		B.append(i)
	elif s[i] == 'c':
		C.append(i)
start = -1
end = N
res = ''
required = N // 2
front = []
tail = []
flag = 0
while required > 0:
	while A and A[0] <= start:
		A.popleft()
	while A and A[-1] >= end:
		A.pop()
	while B and B[0] <= start:
		B.popleft()
	while B and B[-1] >= end:
		B.pop()
	while C and C[0] <= start:
		C.popleft()
	while C and C[-1] >= end:
		C.pop()
	A_range = 0
	B_range = 0
	C_range = 0
	if A:
		A_range = A[-1] - A[0] + 1
	if B:
		B_range = B[-1] - B[0] + 1
	if C:
		C_range = C[-1] - C[0] + 1
	m = max(A_range, B_range, C_range)
	if required == 1:
		if A_range > 0:
			front.append('a')
		elif B_range > 0:
			front.append('b')
		elif C_range > 0:
			front.append('c')
		else:
			flag = 1
			break
		required -= 1
	elif required >= 2:
		if A_range == m and m >= 2:
			start = A[0]
			end = A[-1]
			front.append('a')
			tail.append('a')
		elif B_range == m and m >= 2:
			start = B[0]
			end = B[-1]
			front.append('b')
			tail.append('b')
		elif C_range == m and m >= 2:
			start = C[0]
			end = C[-1]
			front.append('c')
			tail.append('c')
		else:
			break
		required -= 2
if required <= 0:
	tail = tail[::-1]
	print(*front, *tail, sep='')
else:
	print('IMPOSSIBLE')


from sys import stdin, stdout
s = input()
N = len(s)
required = N // 2
front = []
tail = []
left = 0
right = N - 1
while left <= right and required > 0:
	A = left
	B = left + 1
	C = right - 1
	D = right
	if required == 1:
		front.append(s[A])
		required -= 1
		break
	if s[A] == s[D]:
		front.append(s[A])
		tail.append(s[A])
		left = A + 1
		right = D - 1
	elif s[A] == s[C]:
		front.append(s[A])
		tail.append(s[A])
		left = A + 1
		right = C - 1
	elif s[B] == s[D]:
		front.append(s[B])
		tail.append(s[B])
		left = B + 1
		right = D - 1
	elif s[B] == s[C]:
		front.append(s[B])
		tail.append(s[B])
		left = B + 1
		right = C - 1
	required -= 2
if required == 0:
	tail = tail[::-1]
	print(*front, *tail, sep='')
else:
	print('IMPOSSIBLE')


S = input()
i = 0
j = len(S) - 1
ans = []
f = 0
while i < j:
	if S[i] == S[j]:
		pass
	elif S[i] == S[j - 1]:
		j -= 1
	elif S[i + 1] == S[j]:
		i += 1
	else:
		i += 1
		j -= 1
	if i == j:
		f = 1
	ans.append(S[i])
	i += 1
	j -= 1
print(''.join(ans + ans[::-1][f:]))


s = input()
i = 0
j = len(s) - 1
t = []
middle = None
while i <= j:
	if j - i + 1 <= 3:
		middle = s[i]
	elif s[i] == s[j] or s[i] == s[j - 1]:
		t.append(s[i])
	else:
		t.append(s[i + 1])
	i += 2
	j -= 2
a = ''.join(t)
b = ''.join(t[::-1])
if middle:
	print(f'{a}{middle}{b}')
else:
	print(f'{a}{b}')


def Input():
	tem = input().split()
	ans = []
	for it in tem:
		ans.append(int(it))
	return ans
s = input()
n = len(s)
if n < 4:
	print(s[0])
else:
	m = n // 2
	(l, r) = (0, n - 1)
	ans = [[] for i in range(2)]
	while l + 1 < r - 1:
		if s[l + 1] == s[r]:
			ans[0].append(s[l + 1])
			ans[1].append(s[r])
		elif s[l + 1] == s[r - 1]:
			ans[0].append(s[l + 1])
			ans[1].append(s[r - 1])
		elif s[l] == s[r]:
			ans[0].append(s[l])
			ans[1].append(s[r])
		else:
			ans[0].append(s[l])
			ans[1].append(s[r - 1])
		l += 2
		r -= 2
	for i in range(len(ans[0])):
		print(ans[0][i], end='')
	if l < r:
		print(s[l], end='')
	for i in range(len(ans[1]) - 1, -1, -1):
		print(ans[1][i], end='')
	print()


s = input()
length = len(s)
left = 0
right = len(s) - 1
endStr = ''
while left < right - 2:
	if s[left] == s[right]:
		endStr = endStr + s[left]
		left += 1
		right -= 1
	elif s[left] == s[right - 1]:
		endStr = endStr + s[left]
		left += 1
		right -= 2
	elif s[left + 1] == s[right]:
		endStr = endStr + s[right]
		left += 2
		right -= 1
	else:
		endStr = endStr + s[left + 1]
		left += 2
		right -= 2
endStr = endStr + s[left] + endStr[::-1]
if len(s) // 2 > len(endStr):
	print('IMPOSSIBLE')
else:
	print(endStr)


s = input()
(i, j) = (0, len(s) - 1)
half = []
while j - i + 1 > 3:
	if s[i] == s[j]:
		half.append(s[i])
		i += 1
		j -= 1
	elif s[i + 1] == s[j]:
		half.append(s[i + 1])
		i += 2
		j -= 1
	elif s[i] == s[j - 1]:
		half.append(s[i])
		i += 1
		j -= 2
	else:
		half.append(s[i + 1])
		i += 2
		j -= 2
res = ''.join(half)
if j > i:
	res += s[i]
res += ''.join(half[::-1])
print(res)


import sys
input = lambda : sys.stdin.readline().strip()
s = list(input())
i = 0
j = len(s) - 1
res = ['']
while i < j - 2:
	if s[i] == s[j] or s[i] == s[j - 1]:
		res.append(s[i])
	else:
		res.append(s[i + 1])
	i += 2
	j -= 2
print(''.join(res + ([s[i]] if len(s) % 4 else ['']) + list(reversed(res))))


import sys
input = sys.stdin.readline
s = list(input())
if s[-1] != 'a' and s[-1] != 'b' and (s[-1] != 'c'):
	s = s[:-1]
ans = []
i = 0
while i + 1 < len(s) - i - 2:
	st = s[i] + s[i + 1] + s[len(s) - i - 1] + s[len(s) - i - 2]
	if st.count('a') >= 2:
		ans.append('a')
	elif st.count('b') >= 2:
		ans.append('b')
	else:
		ans.append('c')
	i += 2
if len(s) % 4 != 0:
	ans.append(s[i])
if len(s) % 4 == 0:
	sys.stdout.write(''.join(ans))
	ans.reverse()
	sys.stdout.write(''.join(ans) + '\n')
else:
	sys.stdout.write(''.join(ans))
	ans.reverse()
	sys.stdout.write(''.join(ans[1:]) + '\n')


s = input()
n = len(s)

def sol(s, n):
	center = ''
	if n % 2 == 0:
		if n == 2:
			return s[0]
		elif n % 4 == 0:
			(second, third) = (n // 2 - 1, n // 2)
		else:
			center = s[n // 2]
			(second, third) = (n // 2 - 2, n // 2 + 1)
	elif n == 1 or n == 3:
		return s[0]
	else:
		center = s[n // 2]
		(second, third) = (n // 2 - 1, n // 2 + 1)
	(first, fourth) = (second - 1, third + 1)
	ans_half = [0 for i in range(n)]
	half_ans_len = 0
	i_curr = 0
	while first >= 0 and fourth < n:
		if s[first] == s[third] or s[first] == s[fourth]:
			ans_half[i_curr] = s[first]
			i_curr += 1
			half_ans_len += 1
		else:
			ans_half[i_curr] = s[second]
			i_curr += 1
			half_ans_len += 1
		first -= 2
		second -= 2
		third += 2
		fourth += 2
	return ''.join(ans_half[:half_ans_len][::-1]) + center + ''.join(ans_half[:half_ans_len])
print(sol(s, n))


s = input()
p = 0
k = len(s) - 1
dl = 0
odp = []
while p + 1 < k - 1:
	if s[p] == s[k]:
		odp.append(s[p])
		p += 1
		k -= 1
		dl += 2
	elif s[p] == s[k - 1]:
		odp.append(s[p])
		p += 1
		k -= 2
	elif s[p + 1] == s[k]:
		odp.append(s[p + 1])
		p += 2
		k -= 1
	else:
		odp.append(s[p + 1])
		p += 2
		k -= 2
srodek = 0
if k - p == 2:
	x = [s[p], s[p + 1], s[p + 2]]
	x.sort()
	if x[0] == x[1]:
		odp.append(x[0])
	elif x[1] == x[2]:
		odp.append(x[1])
	else:
		srodek = x[1]
if k - p == 1:
	if s[p] == s[p + 1]:
		odp.append(s[p])
	else:
		srodek = s[p]
if k == p:
	srodek = s[p]
if srodek == 0:
	if len(odp) * 2 >= len(s) // 2:
		for i in odp:
			print(i, end='')
		for i in range(len(odp)):
			j = len(odp) - 1 - i
			print(odp[j], end='')
	else:
		print('IMPOSSIBLE')
elif 2 * len(odp) + 1 >= len(s) // 2:
	for i in odp:
		print(i, end='')
	print(srodek, end='')
	for i in range(len(odp)):
		j = len(odp) - 1 - i
		print(odp[j], end='')
else:
	print('IMPOSSIBLE')


import sys
for line in sys.stdin:
	line = line[:-1]
	ans = ['a'] * (len(line) // 4)
	for i in range(len(line) // 4):
		if line[2 * i] in {line[-2 * i - 1], line[-2 * i - 2]}:
			ans[i] = line[2 * i]
		else:
			ans[i] = line[2 * i + 1]
	if len(line) % 2 == 1 or len(line) % 4 == 2:
		print(''.join(ans) + line[len(line) // 2] + ''.join(ans[::-1]))
	else:
		print(''.join(ans) + ''.join(ans[::-1]))
	break


s = str(input())
lst = []
l = 0
h = len(s) - 1
while h >= l:
	if s[l] == s[h]:
		lst.append(s[l])
		l = l + 1
		h = h - 1
	elif s[l] == s[h - 1]:
		h = h - 1
	elif s[l + 1] == s[h]:
		l = l + 1
	else:
		l = l + 1
		h = h - 1
lst1 = lst[::-1]
for i in range(len(lst)):
	print(lst[i], end='')
for i in range(1, len(lst)):
	print(lst1[i], end='')
print()


t = 1
for _ in range(t):
	s = input()
	n = len(s)
	if n <= 3:
		print(s[0])
		exit(0)
	finl_Str = ''
	for i in range(0, n, 2):
		if n - i - 2 <= i + 1:
			break
		if 'a' in s[i:i + 2] and 'a' in s[n - i - 2:n - i]:
			finl_Str += 'a'
		elif 'b' in s[i:i + 2] and 'b' in s[n - i - 2:n - i]:
			finl_Str += 'b'
		elif 'c' in s[i:i + 2] and 'c' in s[n - i - 2:n - i]:
			finl_Str += 'c'
	ans = ''
	if n % 4:
		ans = finl_Str + s[n // 2] + finl_Str[::-1]
	else:
		ans = finl_Str + finl_Str[::-1]
	print(ans)


word = input()
n = len(word)
ln = n // 2
letters = [[], [], []]
dic = {'a': 0, 'b': 1, 'c': 2}
for i in range(n):
	letters[dic[word[i]]].append(i)
ln2 = ln // 2
ans = ''
lb = -1
rb = n
for i in range(ln2):
	for (a, b) in [(lb + 1, rb - 1), (lb + 2, rb - 1), (lb + 1, rb - 2), (lb + 2, rb - 2)]:
		if word[a] == word[b]:
			ans += word[a]
			lb = a
			rb = b
			break
if len(ans) != ln2:
	[1, 2][3]
print(ans, end=word[lb + 1])
ans2 = list(ans)
ans2.reverse()
print(''.join(ans2))


s = input()
p = ''
for i in range(len(s) // 4):
	if s[i * 2] == s[-i * 2 - 1]:
		p += s[i * 2]
	elif s[i * 2 + 1] == s[-i * 2 - 1]:
		p += s[i * 2 + 1]
	elif s[i * 2] == s[-i * 2 - 2]:
		p += s[i * 2]
	else:
		p += s[i * 2 + 1]
l = len(p)
if len(s) % 4 != 0:
	p += s[len(s) // 2]
for i in range(l):
	p += p[l - i - 1]
print(p)


s = input()
n = len(s)
l = 0
h = n - 1
ans = []
while h >= l:
	if s[l] == s[h]:
		ans.append(s[l])
		l += 1
		h -= 1
	elif s[l + 1] == s[h]:
		l += 1
	elif s[l] == s[h - 1]:
		h -= 1
	else:
		h -= 1
		l += 1
n = len(ans)
for i in range(n):
	print(ans[i], end='')
for i in range(n - 2, -1, -1):
	print(ans[i], end='')
print()


s = input()
if len(s) == 3:
	print(s[0])
else:
	ans = ['a'] * (len(s) // 4)
	for i in range(len(s) // 4):
		if s[2 * i + 1] == s[-2 * i - 1]:
			ans[i] = s[2 * i + 1]
		elif s[2 * i + 1] == s[-2 * i - 2]:
			ans[i] = s[2 * i + 1]
		elif s[2 * i] == s[-2 * i - 1]:
			ans[i] = s[2 * i]
		elif s[2 * i] == s[-2 * i - 2]:
			ans[i] = s[2 * i]
		else:
			print('What???????')
	if len(s) % 4 != 0:
		ans = ''.join(ans) + s[len(s) // 2] + ''.join(ans[::-1])
	else:
		ans = ''.join(ans) + ''.join(ans[::-1])
	print(ans)


s = input()
t = ''
n = len(s)
for i in range(0, n, 2):
	if n - i - 2 <= i + 1:
		break
	s1 = s[i:i + 2]
	s2 = s[n - i - 1] + s[n - i - 2]
	if 'a' in s1 and 'a' in s2:
		t += 'a'
	elif 'b' in s1 and 'b' in s2:
		t += 'b'
	else:
		t += 'c'
if n % 4:
	fin = t + s[n // 2] + t[::-1]
else:
	fin = t + t[::-1]
print(fin)


def find(s):
	if len(s) == 1:
		return s
	if len(s) == 2:
		return s[0]
	if len(s) == 3:
		return s[0]
	left = 0
	right = len(s) - 1
	construct = []
	left_get = left
	right_get = right
	while left < right:
		if s[left] == s[right]:
			construct += [s[left]]
			left_get = left
			right_get = right
			left += 1
			right -= 1
		elif s[left] == s[right - 1]:
			if left < right - 1:
				construct += [s[left]]
				left_get = left
				right_get = right - 1
				left += 1
				right = right - 2
			else:
				break
		elif s[left] == s[right - 2]:
			if left < right - 2:
				construct += [s[left]]
				left_get = left
				right_get = right - 2
				left += 1
				right = right - 3
			else:
				break
		elif s[left + 1] == s[right]:
			if left + 1 < right:
				construct += [s[left + 1]]
				left_get = left + 1
				right_get = right
				left = left + 2
				right -= 1
			else:
				break
		elif s[left + 2] == s[right]:
			if left + 2 < right:
				construct += [s[left + 2]]
				left_get = left + 2
				right_get = right
				left = left + 3
				right -= 1
			else:
				break
		elif s[left + 1] == s[right - 1]:
			if left + 1 < right - 1:
				construct += [s[left + 1]]
				left_get = left + 1
				right_get = right - 1
				left = left + 2
				right = right - 2
			else:
				break
		else:
			break
	leftside = construct
	rightside = construct[::-1]
	if left_get + 1 <= right_get - 1:
		leftside += [s[left_get + 1]]
	ans = leftside + rightside
	if len(ans) >= len(s) // 2:
		return ''.join(leftside + rightside)
	else:
		return 'IMPOSSIBLE'
print(find(input()))


def main():
	s = input()
	n = len(s)
	l = 0
	r = n - 1
	temp = []
	temp2 = []
	while l <= r:
		if s[l] == s[r]:
			temp.append(s[l])
			if l != r:
				temp2.append(s[r])
			l += 1
			r -= 1
		elif s[l] == s[r - 1]:
			temp.append(s[l])
			if l != r - 1:
				temp2.append(s[r - 1])
			l += 1
			r -= 2
		else:
			l += 1
			r -= 1
	rev = temp2[::-1]
	cout << ''.join(temp) << ''.join(rev)
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'
main()


s = input()
i = 0
j = len(s) - 1
f = 0
ans = ''
while i < j:
	if s[i] == s[j]:
		pass
	elif s[i] == s[j - 1]:
		j -= 1
	elif s[i + 1] == s[j]:
		i += 1
	else:
		j -= 1
		i += 1
	if i == j:
		f = 1
	ans += s[i]
	i += 1
	j -= 1
print(ans + ans[::-1][f:])


from sys import stdin, stdout
s = stdin.readline().strip()
n = len(s)
if n <= 3:
	print(s[0])
else:
	ans = ''
	(start, end) = (0, n - 1)
	while start + 1 < end - 1:
		if s[start] == s[end] or s[start] == s[end - 1]:
			ans += s[start]
		else:
			ans += s[start + 1]
		start += 2
		end -= 2
	t = len(ans)
	if 2 * t < n // 2:
		ans = ans + s[start] + ans[::-1]
		print(ans)
	else:
		print(ans + ans[::-1])


import sys
input = sys.stdin.readline
s = [0] + list(input().strip()) + [0]
A = 0
B = len(s) - 1
ANS = []
while A < B:
	str0 = [5] * 3
	str1 = [5] * 3
	str0[ord(s[A + 2]) - 97] = 2
	str0[ord(s[A + 1]) - 97] = 1
	str1[ord(s[B - 2]) - 97] = 2
	str1[ord(s[B - 1]) - 97] = 1
	M = [str0[i] + str1[i] for i in range(3)]
	nextstr = M.index(min(M))
	A += str0[nextstr]
	B -= str1[nextstr]
	if A < B:
		ANS.append(s[A])
	elif A == B:
		ANS = ANS + [s[A]] + ANS[::-1]
		break
	else:
		ANS = ANS + ANS[::-1]
		break
print(''.join(ANS))


def gns():
	return list(map(int, input().split()))
s = input()
l = len(s)
(i, j) = (0, l - 1)
ans = []
t = l // 4
for i in range(t):
	x = i * 2
	y = l - 2 - i * 2
	if s[x] == s[y] or s[x] == s[y + 1]:
		ans.append(s[x])
	else:
		ans.append(s[x + 1])
if l % 4 >= 2:
	ans = ans + [s[l // 2]] + ans[::-1]
else:
	ans = ans + ans[::-1]
ans = ''.join(ans)
print(ans)


s = input()
n = len(s)
(f, b) = ([], [])
(i, j) = (0, n - 1)
while i < j:
	if s[i] != s[j]:
		if s[i] == s[j - 1]:
			j -= 1
		elif s[i + 1] == s[j]:
			i += 1
		else:
			i += 1
			j -= 1
	if s[i] == s[j]:
		f.append(s[i])
	if i < j:
		b.append(s[j])
	i += 1
	j -= 1
print(''.join(f + list(reversed(b))))


s = input()
i = 0
j = len(s) - 1
m = len(s) // 2
if s.count('a') >= m:
	print('a' * m)
elif s.count('b') >= m:
	print('b' * m)
elif s.count('c') >= m:
	print('c' * m)
else:
	i = 0
	j = len(s) - 1
	r = []
	while j - i > 2:
		if s[i] == s[j]:
			r.append(s[i])
			i += 1
			j -= 1
		elif s[i] == s[j - 1]:
			r.append(s[i])
			i += 1
			j -= 2
		elif s[i + 1] == s[j]:
			r.append(s[j])
			i += 2
			j -= 1
		else:
			r.append(s[i + 1])
			i += 2
			j -= 2
	if j >= i:
		x = r + [s[i]] + r[::-1]
	else:
		x = r + r[::-1]
	if len(x) < m:
		print('IMPOSSIBLE')
	else:
		print(''.join(x))


import sys

def rl(proc=None):
	if proc is not None:
		return proc(sys.stdin.readline())
	else:
		return sys.stdin.readline().rstrip()

def srl(proc=None):
	if proc is not None:
		return list(map(proc, rl().split()))
	else:
		return rl().split()

def main():
	s = rl()
	i = 0
	j = len(s) - 2
	r = ''
	while i + 2 <= j:
		if s[i] in s[j:j + 2]:
			r += s[i]
		else:
			r += s[i + 1]
		i += 2
		j -= 2
	if len(s) & 3:
		m = s[i]
	else:
		m = ''
	print(r + m + ''.join(reversed(r)))
main()


s = list(input().rstrip())
n = len(s)
i = 0
j = n - 1
d = []
while j - i > 1:
	if s[i] == s[j]:
		d.append(s[i])
		i += 1
		j -= 1
	elif s[i] == s[j - 1]:
		d.append(s[i])
		j -= 2
		i += 1
	else:
		i += 1
if i <= j:
	d.append(s[i])
	d += d[:len(d) - 1][::-1]
else:
	d += d[::-1]
print(''.join(d))


from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))

def solve():
	S = input()
	if len(S) <= 3:
		print(S[0])
		return
	lo = 0
	hi = len(S) - 1
	half = []
	mid = ''
	while lo < hi - 1:
		if lo == hi:
			mid = S[lo]
			break
		elif S[lo] == S[hi]:
			half.append(S[lo])
			lo += 1
			hi -= 1
		elif S[lo] == S[hi - 1]:
			half.append(S[lo])
			lo += 1
			hi -= 2
		elif S[lo + 1] == S[hi]:
			half.append(S[hi])
			lo += 2
			hi -= 1
		else:
			lo += 1
			hi -= 1
	if lo == hi or lo == hi - 1:
		mid = S[lo]
	print(''.join(half) + mid + ''.join(half[::-1]))
mode = 's'
if mode == 'T':
	t = ri()
	for i in range(t):
		solve()
else:
	solve()


from collections import deque
s = input()
left = deque([])
right = deque([])

def solve():
	(l, r) = (0, len(s))
	while l <= r:
		if r - l == 0:
			print(''.join(left + right))
			return
		elif r - l <= 3:
			print(''.join(left + deque([s[l]]) + right))
			return
		if 'a' in s[l:l + 2] and 'a' in s[r - 2:r]:
			left.append('a')
			right.appendleft('a')
		elif 'b' in s[l:l + 2] and 'b' in s[r - 2:r]:
			left.append('b')
			right.appendleft('b')
		else:
			left.append('c')
			right.appendleft('c')
		l += 2
		r -= 2
solve()


import sys
input = sys.stdin.readline
s = input()
n = len(s)
ans = []
ans1 = []
mxm = (n - 1) // 2
pt = 0
pt1 = n - 2
while pt < pt1 and mxm > 0:
	if mxm == 1:
		ans.append(s[pt])
		break
	q1 = pt
	q2 = pt1
	while q1 < q2 and q2 > pt1 - 2:
		if s[q1] == s[q2]:
			break
		q2 -= 1
	if s[q1] == s[q2]:
		ans.append(s[q1])
		ans1.append(s[q2])
		pt1 = q2 - 1
		mxm -= 2
	pt += 1
ans1.reverse()
for i in ans:
	print(i, end='')
for i in ans1:
	print(i, end='')


s = input()
n = len(s)
ans = ''
for i in range(0, n // 2, 2):
	if n - i - 2 <= i + 1:
		break
	else:
		l = set(s[i:i + 2])
		r = set(s[n - i - 2:n - i])
		temp = l.intersection(r)
		ans += [i for i in temp][0]
print(ans + s[n // 2] + ans[::-1] if n % 4 != 0 else ans + ans[::-1])


s = input()
remainingLength = len(s)
i = 0
j = remainingLength - 1
palindrome = ''
middleChar = ''
while remainingLength > 0:
	if remainingLength >= 4:
		firstPart = {s[i], s[i + 1]}
		lastPart = {s[j], s[j - 1]}
		palindromeCharacter = firstPart.intersection(lastPart).pop()
		palindrome = palindrome + palindromeCharacter
	else:
		middleChar = s[i]
	remainingLength -= 4
	i += 2
	j -= 2
totalPalindrome = palindrome + middleChar + palindrome[::-1]
print(totalPalindrome)


import sys
input = sys.stdin.readline
s = input().rstrip()
n = len(s)
ans = []
l = 0
r = n - 1
while l <= r:
	if s[l] == s[r]:
		ans.append(s[l])
		l += 1
		r -= 1
	elif s[l + 1] == s[r]:
		l += 1
	elif s[l] == s[r - 1]:
		r -= 1
	else:
		l += 1
		r -= 1
res = ans + ans[:len(ans) - 1][::-1]
print(''.join(res))


s = input()
l = 0
n = len(s) - 1
r = n
ans = ''
cent = ''
while r > l:
	if s[l] == s[r]:
		ans += s[l]
		l += 1
		r -= 1
	elif s[l + 1] == s[r - 1] and r - l > 2:
		ans += s[l + 1]
		l += 2
		r -= 2
	elif r - l > 1:
		if l < n - r:
			if s[l + 1] == s[r]:
				ans += s[l + 1]
				l += 2
				r -= 1
			elif s[l] == s[r - 1]:
				ans += s[l]
				l += 1
				r -= 2
			elif l < n - r:
				l += 1
			else:
				r -= 1
		elif s[l] == s[r - 1]:
			ans += s[l]
			l += 1
			r -= 2
		elif s[l + 1] == s[r]:
			ans += s[l + 1]
			l += 2
			r -= 1
		elif l < n - r:
			l += 1
		else:
			r -= 1
	elif l < n - r:
		l += 1
	else:
		r -= 1
if r == l:
	cent = s[l]
if len(ans) * 2 + len(cent) < len(s) // 2:
	print('IMPOSSIBLE')
else:
	print(ans + cent + ans[::-1])


sre = input()
pre = 0
kre = len(sre) - 1
pointeree = 0
plotttt = []
while pre + 1 < kre - 1:
	if sre[pre] == sre[kre]:
		plotttt.append(sre[pre])
		pre += 1
		kre -= 1
		pointeree += 2
	elif sre[pre] == sre[kre - 1]:
		plotttt.append(sre[pre])
		pre += 1
		kre -= 2
	elif sre[pre + 1] == sre[kre]:
		plotttt.append(sre[pre + 1])
		pre += 2
		kre -= 1
	else:
		plotttt.append(sre[pre + 1])
		pre += 2
		kre -= 2
dfdkngkfgjfb = 0
if kre - pre == 2:
	xrere = [sre[pre], sre[pre + 1], sre[pre + 2]]
	xrere.sort()
	if xrere[0] == xrere[1]:
		plotttt.append(xrere[0])
	elif xrere[1] == xrere[2]:
		plotttt.append(xrere[1])
	else:
		dfdkngkfgjfb = xrere[1]
if kre - pre == 1:
	if sre[pre] == sre[pre + 1]:
		plotttt.append(sre[pre])
	else:
		dfdkngkfgjfb = sre[pre]
if kre == pre:
	dfdkngkfgjfb = sre[pre]
if dfdkngkfgjfb == 0:
	if len(plotttt) * 2 >= len(sre) // 2:
		for i in plotttt:
			print(i, end='')
		for i in range(len(plotttt)):
			j = len(plotttt) - 1 - i
			print(plotttt[j], end='')
	else:
		print('IMPOSSIBLE')
elif 2 * len(plotttt) + 1 >= len(sre) // 2:
	for i in plotttt:
		print(i, end='')
	print(dfdkngkfgjfb, end='')
	for i in range(len(plotttt)):
		j = len(plotttt) - 1 - i
		print(plotttt[j], end='')
else:
	print('IMPOSSIBLE')


from sys import stdin, stdout, exit
s = stdin.readline().strip()
n = len(s)
ans_head = []
ans_tail = []
idx_h = 0
idx_t = n - 1
while idx_h + 1 < idx_t - 1:
	heads = set([s[idx_h], s[idx_h + 1]])
	if s[idx_t] in heads:
		ans_head.append(s[idx_t])
		ans_tail.append(s[idx_t])
	else:
		ans_head.append(s[idx_t - 1])
		ans_tail.append(s[idx_t - 1])
	idx_h += 2
	idx_t -= 2
if n % 4 != 0:
	ans_head.append(s[(n + 1) // 2])
ans = ''.join(ans_head) + ''.join(reversed(ans_tail))
stdout.write(ans + '\n')


s = input()
l = 0
r = len(s) - 1
ans = ''
while r - l > 1:
	if s[l] == s[r]:
		ans += s[l]
		l += 1
		r -= 1
	elif r - l > 2 and s[l + 1] == s[r]:
		ans += s[l + 1]
		l += 2
		r -= 1
	elif r - l > 2 and s[l] == s[r - 1]:
		ans += s[l]
		l += 1
		r -= 2
	elif r - l > 3 and s[l + 1] == s[r - 1]:
		ans += s[l + 1]
		l += 2
		r -= 2
	else:
		break
if r - l > 0:
	msg = ans + s[l + 1] + ans[::-1]
elif r - l == 0:
	msg = ans + s[l] + ans[::-1]
else:
	msg = ans + ans[::-1]
if len(msg) >= len(s) // 2:
	print(msg)
else:
	print('IMPOSSIBLE')


s = input()
n = len(s)
(i, j) = (0, n - 1)
ans = []
t = n // 4
for i in range(t):
	x = i * 2
	y = n - 2 - i * 2
	if s[x] == s[y] or s[x] == s[y + 1]:
		ans.append(s[x])
	else:
		ans.append(s[x + 1])
if n % 4 >= 2:
	ans = ans + [s[n // 2]] + ans[::-1]
else:
	ans = ans + ans[::-1]
print(''.join(ans))


s = input()
char = set()
n = len(s)
i = 0
j = n - 1
fin = ''
lis = []
while j >= i + 3:
	if s[i] == s[j]:
		lis.append(i)
		i += 1
		j -= 1
	elif s[i] == s[j - 1]:
		lis.append(i)
		i += 1
		j -= 2
	elif s[i + 1] == s[j]:
		lis.append(i + 1)
		i += 2
		j -= 1
	else:
		lis.append(i + 1)
		i += 2
		j -= 2
fin = ''.join([s[k] for k in lis])
fin_rev = fin[::-1]
if j >= i:
	fin += s[i]
print(fin + fin_rev)


S = input()
N = len(S)
(l, r) = (0, N - 1)
res = ''
mid = ''
while l <= r:
	if l == r:
		mid = S[l]
		break
	elif S[l] == S[r]:
		res += S[l]
		l += 1
		r -= 1
	elif S[l + 1] == S[r]:
		l += 1
	elif S[r - 1] == S[l]:
		r -= 1
	elif l > N - r:
		r -= 1
	else:
		l += 1
ans = res + mid + res[::-1]
if len(ans) >= N // 2:
	print(ans)
else:
	print('IMPOSSIBLE')