#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
  string s;
  int cnt = 0;
  cin >> s;

  if (s[0] != 'A')
  {
    cout << "WA" << endl;
    return 0;
  }

  for (int i = 1; i < s.length(); i++)
  {
    if (i > 1 && i < s.length() - 1)
    {
      if (s[i] == 'C')
      {
        if (cnt == 0)
        {
          cnt = 1;
          continue;
        }
        else
        {
          cout << "WA" << endl;
          return 0;
        }
      }
    }
    if (s[i] - '0' >= 17 && s[i] - '0' <= 42)
    {
      cout << "WA" << endl;
      return 0;
    }
  }
  if (cnt == 0)
  {
    cout << "WA" << endl;
    return 0;
  }

  cout << "AC" << endl;
}
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
    string s; cin >> s;
	int n = s.size();
	if(s == "zyxwvutsrqponmlkjihgfedcba") {
		cout << -1 << endl;
		return 0;
	}
	if(n != 26) {
		for(char a = 'a'; a <= 'z'; a++) {
			if(count(s.begin(), s.end(), a) == 0) {
				cout << s << a << endl;
				return 0;
			}
		}
	}
	string k = s;
	next_permutation(k.begin(), k.end());
	for(int i = 0; i < n; i++){
		if(s[i] != k[i]) {
			cout << k.substr(0, i + 1) << endl;
            system("pause");
			return 0;
		}
	}

    system("pause");
}