#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int deg[maxn], mn[maxn], MN[maxn];
vector<int> adj[maxn];
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  fill(mn, mn + n, n);
  fill(MN, MN + n, n);
  for (int i = 0; i < m; i++) {
    int v, u;
    cin >> v >> u;
    v--;
    u--;
    adj[v].push_back(u);
    deg[u]++;
  }
  queue<int> Q;
  for (int i = 0; i < n; i++) {
    if (!deg[i]) Q.push(i);
  }
  vector<int> topol;
  while (Q.size()) {
    int v = Q.front();
    topol.push_back(v);
    Q.pop();
    for (auto u : adj[v]) {
      deg[u]--;
      if (!deg[u]) Q.push(u);
    }
  }
  if (topol.size() < n) {
    cout << -1;
    return 0;
  }
  for (auto v : topol) {
    for (auto u : adj[v]) {
      mn[u] = min(mn[u], min(mn[v], v));
    }
  }
  int ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    int v = topol[i];
    for (auto u : adj[v]) {
      MN[v] = min(min(u, MN[u]), MN[v]);
    }
    if (MN[v] > v && mn[v] > v) ans++;
  }
  cout << ans << '\n';
  for (int i = 0; i < n; i++) {
    int v = i;
    if (MN[v] > v && mn[v] > v)
      cout << 'A';
    else
      cout << 'E';
  }
}
