#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
int n, m;
int fir[N + 10][2], nex[N + 10][2], tot[2], en[N + 10][2];
int tag[N + 10][2], vis[N + 10];
void addEdge(int x, int y, int p) {
  tot[p]++;
  nex[tot[p]][p] = fir[x][p];
  fir[x][p] = tot[p];
  en[tot[p]][p] = y;
}
void dfs1(int x) {
  vis[x] = 1;
  for (int tmp = fir[x][0]; tmp > 0; tmp = nex[tmp][0]) {
    int y = en[tmp][0];
    if (vis[y] == 0) {
      dfs1(y);
    } else if (vis[y] == 1) {
      puts("-1");
      exit(0);
    }
  }
  vis[x] = 2;
}
void dfs2(int x, int p) {
  if (tag[x][p] == 1) {
    return;
  }
  tag[x][p] = 1;
  for (int tmp = fir[x][p]; tmp > 0; tmp = nex[tmp][p]) {
    int y = en[tmp][p];
    if (tag[y][p] == 0) {
      dfs2(y, p);
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    addEdge(x, y, 0);
    addEdge(y, x, 1);
  }
  for (int i = 1; i <= n; i++)
    if (vis[i] == 0) {
      dfs1(i);
    }
  string ans = "";
  int cnta = 0;
  for (int i = 1; i <= n; i++) {
    if (tag[i][0] == 0 && tag[i][1] == 0) {
      ans += "A";
      cnta++;
    } else {
      ans += "E";
    }
    dfs2(i, 0);
    dfs2(i, 1);
  }
  printf("%d\n", cnta);
  printf("%s\n", ans.c_str());
  return 0;
}
