范围讨论,邪道做法
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long LL;
typedef long double ld;
typedef pair<ll, ll> pll;
#define endl '\n'
#define fi first
#define se second
#define ve vector
#define vc vector
#define rep(i,a,b) for(int i = a;i <= b;i++)
#define uep(i,a,b) for(int i = a;i >= b;i--)
const ll mod = 998244353;
void solve() {
string s;
cin >> s;
string a = s;
if (s.size() >= 5000) {
rep(i, 0, s.size() - 1) {
if (s[i] == a[i]) {
rep(j, max(i - 100, 0), s.size() - 1) {
if (s[i] != s[j] && a[i] != s[j] && a[j] != s[i]) {
swap(s[i], s[j]);
break;
}
}
}
}
}
else {
rep(i, 0, s.size() - 1) {
if (s[i] == a[i]) {
rep(j, 0, s.size() - 1) {
if (s[i] != s[j] && a[i] != s[j] && a[j] != s[i]) {
swap(s[i], s[j]);
break;
}
}
}
}
}
rep(i, 0, s.size() - 1) {
if (s[i] == a[i]) {
cout << -1 << endl;
return;
}
}
cout << s << endl;
}
signed main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//cout << fixed << setprecision(7);//显示几位小数
ll T = 1;
//cin >> T;
while (T--) {
solve();
}
return 0;
}