#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 10;
long long n, m, A[maxn], pos[maxn], tss;
vector<long long> G[2][maxn];
bool mark[2][maxn], mrk[maxn];
void dfs_ts(long long a) {
  mrk[a] = 1;
  for (long long b : G[0][a]) {
    if (!mrk[b]) {
      dfs_ts(b);
    }
  }
  pos[a] = tss++;
}
void dfs(long long a, long long t) {
  mark[t][a] = 1;
  for (long long b : G[t][a]) {
    if (!mark[t][b]) {
      dfs(b, t);
    }
  }
}
string ans;
int32_t main() {
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long a, b;
    cin >> a >> b;
    a--, b--;
    G[0][a].push_back(b);
    G[1][b].push_back(a);
  }
  for (long long i = 0; i < n; i++) {
    if (!mrk[i]) {
      dfs_ts(i);
    }
  }
  for (long long a = 0; a < n; a++) {
    for (long long b : G[0][a]) {
      if (pos[a] <= pos[b]) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  long long ss = 0;
  for (long long i = 0; i < n; i++) {
    if (!mark[0][i] && !mark[1][i]) {
      ss++;
      ans.push_back('A');
    } else {
      ans.push_back('E');
    }
    dfs(i, 0);
    dfs(i, 1);
  }
  cout << ss << endl << ans << endl;
}
