#include <bits/stdc++.h>
using namespace std;
vector<int> g[200005], g1[200005];
int f[200005], rasp[200005], mina[200005], minb[200005];
queue<int> q;
int dfs(int nod) {
  if (mina[nod] != 2e9) return min(mina[nod], nod);
  for (auto it : g[nod]) mina[nod] = min(mina[nod], dfs(it));
  return min(mina[nod], nod);
}
int dfs2(int nod) {
  if (minb[nod] != 2e9) return min(minb[nod], nod);
  for (auto it : g1[nod]) minb[nod] = min(minb[nod], dfs2(it));
  return min(minb[nod], nod);
}
int main() {
  int n, m, i, x, y;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    g[y].push_back(x);
    f[x]++;
    g1[x].push_back(y);
  }
  for (i = 1; i <= n; i++)
    if (f[i] == 0) q.push(i);
  int cnt = 0;
  while (!q.empty()) {
    int nod = q.front();
    q.pop();
    cnt++;
    for (auto it : g[nod]) {
      f[it]--;
      if (f[it] == 0) q.push(it);
    }
  }
  if (cnt != n) {
    printf("-1\n");
    return 0;
  }
  for (i = 1; i <= n; i++) mina[i] = 2e9, minb[i] = 2e9;
  for (i = 1; i <= n; i++)
    if (mina[i] != 2e9)
      continue;
    else
      dfs(i);
  for (i = 1; i <= n; i++)
    if (minb[i] != 2e9)
      continue;
    else
      dfs2(i);
  for (i = 1; i <= n; i++)
    if (mina[i] > i && minb[i] > i) rasp[i] = 1;
  cnt = 0;
  for (i = 1; i <= n; i++)
    if (rasp[i] == 1) cnt++;
  printf("%d\n", cnt);
  for (i = 1; i <= n; i++)
    if (rasp[i] == 1)
      putchar('A');
    else
      putchar('E');
  return 0;
}
