#include <bits/stdc++.h>
int oo[1 + 200000 * 2], oj[1 + 200000 * 2];
int link(int o, int j) {
  static int _ = 1;
  oo[_] = o, oj[_] = j;
  return _++;
}
int ae[200000], af[200000];
char instack[200000], visited[200000];
int dfs1(int i) {
  int o;
  if (visited[i]) return instack[i];
  visited[i] = instack[i] = 1;
  for (o = ae[i]; o; o = oo[o]) {
    int j = oj[o];
    if (dfs1(j)) return 1;
  }
  instack[i] = 0;
  return 0;
}
void dfs2(int i) {
  int o;
  if (visited[i]) return;
  visited[i] = 1;
  for (o = af[i]; o; o = oo[o]) {
    int j = oj[o];
    dfs2(j);
  }
}
int main() {
  static char cc[200000 + 1];
  int n, m, h, i, j, ans;
  scanf("%d%d", &n, &m);
  for (h = 0; h < m; h++) {
    scanf("%d%d", &i, &j), i--, j--;
    ae[i] = link(ae[i], j);
    af[j] = link(af[j], i);
  }
  memset(cc, 'A', n * sizeof *cc);
  for (i = 0; i < n; i++)
    if (visited[i])
      cc[i] = 'E';
    else if (dfs1(i)) {
      printf("-1\n");
      return 0;
    }
  memset(visited, 0, n * sizeof *visited);
  for (i = 0; i < n; i++)
    if (visited[i])
      cc[i] = 'E';
    else
      dfs2(i);
  ans = 0;
  for (i = 0; i < n; i++)
    if (cc[i] == 'A') ans++;
  printf("%d\n", ans);
  printf("%s\n", cc);
  return 0;
}
