#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   int n, m, cnt, head[N], vis[N], in[N], u, v, ans, op[N];   int idx, dfn[N], g[N], f[N];   struct edge {     int v, nxt;   } e[N];   void add(int u, int v) {     e[++cnt] = (edge){v, head[u]};     head[u] = cnt;   }   int dfs(int u) {     vis[u] = in[u] = 1;     for (int i = head[u], v; v = e[i].v, i; i = e[i].nxt)       if (in[v] || (!vis[v] && !dfs(v))) return 0;     return in[dfn[++idx] = u] = 0, 1;   }   int main() {     cin >> n >> m;     for (int i = (1); i <= (m); i++) scanf( %d%d , &u, &v), add(u, v);     for (int i = (1); i <= (n); i++)       if (!vis[i] && !dfs(i)) return puts( -1 ), 0;     memset(g, 0x3f, sizeof g), memset(f, 0x3f, sizeof f);     for (int j = (1); j <= (n); j++)       for (int i = head[dfn[j]], v; v = e[i].v, i; i = e[i].nxt)         g[dfn[j]] = min(g[dfn[j]], min(v, g[v]));     for (int j = (n); j >= (1); j--)       for (int i = head[dfn[j]], v; v = e[i].v, i; i = e[i].nxt)         f[v] = min(f[v], min(dfn[j], f[dfn[j]]));     for (int i = (1); i <= (n); i++)       if (min(g[i], f[i]) > i) ans++, op[i] = 1;     cout << ans << endl;     for (int i = (1); i <= (n); i++) putchar(op[i] ?  A  :  E );     return 0;   }   