#include <cstdio>
#include <algorithm>
#include <cstring>
#define MAX 100
using namespace std;
int main()
{
int length;
char str[MAX];
while(gets(str)){
length = strlen(str);
sort(str, str + length);
puts(str);
while (next_permutation(str, str + length))
{
puts(str);
}
}
return 0;
}
/**************************************************************
Problem: 1369
User: LiuJ
Language: C++
Result: Accepted
Time:70 ms
Memory:1020 kb
****************************************************************/
#include <stdio.h>
int n;
int d[100001];
int tl, tr;
int partition(int l, int r)
{
int p = d[l];
while (l < r)
{
while (l < r && d[r] >= p)
r--;
d[l] = d[r];
while (l < r && d[l] <= p)
l++;
d[r] = d[l];
}
d[l] = p;
return l;
}
void quick_select(int l, int r, int k)
{
int p = partition(l, r);
if (p == k)
return;
if (tl != -1 && tr != -1 && tl == tr)
return;
if (p < k)
{
tl = d[p];
quick_select(p+1, r, k);
}
else
{
tr = d[p];
quick_select(l, p-1, k);
}
}
int main()
{
int i;
while (scanf("%d", &n) != EOF)
{
for (i = 0; i < n; i++)
scanf("%d", &d[i]);
tl = tr = -1;
quick_select(0, n-1, (n-1)/2);
int tot = 0;
int t = d[(n-1)/2];
for (i = 0; i < n; i++)
tot += (d[i] == t);
if (tot > n/2)
printf("%d\n", t);
else
puts("-1");
}
return 0;
}
/**************************************************************
Problem: 1370
User: cust123
Language: C++
Result: Accepted
Time:860 ms
Memory:1404 kb
****************************************************************/