#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
vector<long long> adj[N], inv[N];
long long vis[N], dp[N], indeg[N], dp2[N];
bool dfs(long long node) {
  vis[node] = 1;
  for (long long next : adj[node]) {
    if (vis[next] == 1) return true;
    if (vis[next]) continue;
    if (dfs(next)) return true;
  }
  vis[node] = 2;
  return false;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; ++i) {
    long long u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    inv[v].push_back(u);
    ++indeg[v];
  }
  for (long long i = 1; i <= n; ++i) {
    if (vis[i]) continue;
    if (dfs(i)) {
      cout << -1;
      return 0;
    }
  }
  queue<long long> q;
  for (long long i = 1; i <= n; ++i) {
    dp2[i] = dp[i] = i;
    if (indeg[i] == 0) q.push(i);
  }
  vector<long long> topoOrder;
  while (!q.empty()) {
    const long long node = q.front();
    q.pop();
    topoOrder.push_back(node);
    for (long long next : adj[node]) {
      --indeg[next];
      if (indeg[next] == 0) {
        q.push(next);
      }
    }
  }
  for (long long i = (long long)topoOrder.size() - 1; i >= 0; --i) {
    const long long node = topoOrder[i];
    for (long long next : adj[node]) {
      dp[node] = min(dp[node], dp[next]);
    }
  }
  for (long long node : topoOrder) {
    for (long long prev : inv[node]) {
      dp2[node] = min(dp2[node], dp2[prev]);
    }
  }
  long long cnt = 0;
  string s = "";
  for (long long i = 1; i <= n; ++i) {
    if (i > min(dp[i], dp2[i])) {
      s += 'E';
    } else {
      ++cnt;
      s += 'A';
    }
  }
  cout << cnt << '\n' << s;
}
