#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
int v1[maxn], vis[maxn], v2[maxn];
vector<int> g[maxn], rev[maxn];
char ans[maxn];
int cir = 0;
void dfs1(int x) {
  v1[x] = 1;
  for (int i = 0; i < g[x].size(); i++) {
    int y = g[x][i];
    if (!v1[y]) dfs1(y);
  }
}
void dfs2(int x) {
  v2[x] = 1;
  for (int i = 0; i < rev[x].size(); i++) {
    int y = rev[x][i];
    if (!v2[y]) dfs2(y);
  }
}
void dfs(int x) {
  vis[x] = 1;
  for (int i = 0; i < g[x].size(); i++) {
    int y = g[x][i];
    if (vis[y] == 1)
      cir = 1;
    else if (vis[y] == 0)
      dfs(y);
  }
  vis[x] = 2;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    rev[v].push_back(u);
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i);
  for (int i = 1; i <= n; i++) {
    if (v1[i] || v2[i])
      ans[i] = 'E';
    else
      ans[i] = 'A', cnt++;
    if (!v1[i]) dfs1(i);
    if (!v2[i]) dfs2(i);
  }
  if (cir)
    printf("-1\n");
  else
    printf("%d\n%s\n", cnt, ans + 1);
  return 0;
}
