#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
int n, m, tot, ftot, ans[maxn];
int ver[maxn << 1], nxt[maxn << 1], head[maxn];
int fver[maxn << 1], fnxt[maxn << 1], fhead[maxn];
int in[maxn], fin[maxn], mpos[maxn], npos[maxn];
queue<int> q;
void add(int u, int v) {
  ver[++tot] = v;
  nxt[tot] = head[u];
  head[u] = tot;
}
void fadd(int u, int v) {
  fver[++ftot] = v;
  fnxt[ftot] = fhead[u];
  fhead[u] = ftot;
}
bool tpsort1() {
  for (int i = 1; i <= n; i++) {
    mpos[i] = i;
    if (!in[i]) q.push(i);
  }
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    for (int i = head[now]; i; i = nxt[i]) {
      int y = ver[i];
      in[y]--;
      mpos[y] = min(mpos[now], mpos[y]);
      if (!in[y]) q.push(y);
    }
  }
  for (int i = 1; i <= n; i++)
    if (in[i]) return 0;
  return 1;
}
void tpsort2() {
  for (int i = 1; i <= n; i++) {
    npos[i] = i;
    if (!fin[i]) q.push(i);
  }
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    for (int i = fhead[now]; i; i = fnxt[i]) {
      int y = fver[i];
      fin[y]--;
      npos[y] = min(npos[now], npos[y]);
      if (!fin[y]) q.push(y);
    }
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    add(a, b), fadd(b, a);
    in[b]++, fin[a]++;
  }
  if (!tpsort1()) {
    printf("-1\n");
    return 0;
  }
  tpsort2();
  int js = 0;
  for (int i = 1; i <= n; i++) {
    if (mpos[i] == i && npos[i] == i) {
      js++;
      ans[i] = 0;
    } else
      ans[i] = 1;
  }
  printf("%d\n", js);
  for (int i = 1; i <= n; i++) {
    if (!ans[i])
      printf("A");
    else
      printf("E");
  }
  return 0;
}
