#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
struct edge {
  int r, next;
} e[N * 2], d[N * 2];
int h[N], tot, n, m;
void add(int a, int b) {
  e[++tot].next = h[a];
  e[tot].r = b;
  h[a] = tot;
}
int g[N], tt;
void add2(int a, int b) {
  d[++tt].next = g[a];
  d[tt].r = b;
  g[a] = tt;
}
int vis[N], vis1[N];
void dfs(int x) {
  if (vis[x]) return;
  vis[x] = 1;
  for (int j = g[x]; j; j = d[j].next) {
    int y = d[j].r;
    dfs(y);
  }
}
void df(int x) {
  if (vis1[x] == 1) return;
  vis1[x] = 1;
  for (int j = h[x]; j; j = e[j].next) {
    int y = e[j].r;
    df(y);
  }
}
int rd[N], x[N];
int q[N], l = 1, r;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    add(a, b);
    rd[b]++;
    add2(b, a);
  }
  for (int i = 1; i <= n; i++)
    if (!rd[i]) q[++r] = i;
  while (l <= r) {
    int x = q[l++];
    for (int i = h[x]; i; i = e[i].next) {
      int y = e[i].r;
      rd[y]--;
      if (!rd[y]) q[++r] = y;
    }
  }
  for (int i = 1; i <= n; i++)
    if (rd[i]) {
      printf("-1");
      return 0;
    }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    x[i] = vis[i] | vis1[i];
    ans += x[i] < 1;
    dfs(i);
    df(i);
  }
  printf("%d\n", ans);
  for (int i = 1; i <= n; i++) x[i] ? printf("E") : printf("A");
}
