#include #define MAXN 100 #define P 131 #define MOD ((int) 1e9 + 7) using namespace std; int n; char s[MAXN + 10]; long long p[MAXN + 10], f[MAXN + 10], g[MAXN + 10]; long long gao(int L, int R) { if (L <= R) { int len = R - L + 1; return (f[R] - f[L - 1] * p[len] % MOD + MOD) % MOD; } else { int len = L - R + 1; return (g[R] - g[L + 1] * p[len] % MOD + MOD) % MOD; } } int main() { scanf("%s", s + 1); n = strlen(s + 1); p[0] = 1; for (int i = 1; i <= n; i++) p[i] = p[i - 1] * P % MOD; for (int i = 1; i <= n; i++) f[i] = (f[i - 1] * P + s[i]) % MOD; for (int i = n; i > 0; i--) g[i] = (g[i + 1] * P + s[i]) % MOD; int ans1 = n + 1; for (int i = (n + 1) / 2 + 1; i <= n; i++) if (gao(n, i) == gao(i - (n - i + 1), i - 1)) { ans1 = i; break; } int len1 = n - 2 * (n + 1 - ans1); int ans2 = n; for (int i = n / 2 + 1; i < n; i++) if (gao(n, i + 1) == gao(i - (n - i), i - 1)) { ans2 = i; break; } int len2 = n - 2 * (n - ans2) - 1; for (int i = 1; i <= n; i++) printf("%c", s[i]); for (int i = min(len1, len2); i > 0; i--) printf("%c", s[i]); return 0; }