#include <bits/stdc++.h>
using namespace std;
int hd[200007], nxt[200007], to[200007], en;
int hd2[200007], nxt2[200007], to2[200007], en2;
int vis[200007];
bool vis2[200007];
bool E[200007];
inline void adde(int a, int b) {
  nxt[en] = hd[a];
  hd[a] = en;
  to[en] = b;
  en++;
  nxt2[en2] = hd2[b];
  hd2[b] = en2;
  to2[en2] = a;
  en2++;
}
bool dfs(int x) {
  vis[x] = -1;
  for (int i = hd[x]; ~i; i = nxt[i]) {
    if (vis[to[i]] == -1) return false;
    if (!vis[to[i]] && !dfs(to[i])) return false;
  }
  vis[x] = 1;
  return true;
}
void dfs2(int x) {
  vis2[x] = 1;
  for (int i = hd2[x]; ~i; i = nxt2[i]) {
    if (!vis2[to2[i]]) dfs2(to2[i]);
  }
}
int main() {
  memset(vis, 0, sizeof vis);
  memset(hd, -1, sizeof hd);
  memset(hd2, -1, sizeof hd2);
  int n, m;
  scanf("%d%d", &n, &m);
  en = 0;
  en2 = 0;
  for (int i = (0); i < (m); i++) {
    int j, k;
    scanf("%d%d", &j, &k);
    adde(j, k);
  }
  for (int i = (1); i <= (n); i++)
    if (!vis[i]) {
      if (!dfs(i)) {
        puts("-1");
        return 0;
      }
    }
  int ans = 0;
  memset(E, 0, sizeof E);
  memset(vis, 0, sizeof vis);
  memset(vis2, 0, sizeof vis2);
  for (int i = (1); i <= (n); i++) {
    if (!vis[i] && !vis2[i]) ans++, E[i] = 1;
    if (!vis[i]) dfs(i);
    if (!vis2[i]) dfs2(i);
  }
  printf("%d\n", ans);
  for (int i = (1); i <= (n); i++) {
    if (E[i])
      putchar('A');
    else
      putchar('E');
  }
  putchar('\n');
}
