#include <bits/stdc++.h>
using namespace std;
struct E {
  int v, next;
} e[200005], g[200005];
int n, m, a, b;
int h[200005], k;
int hg[200005], kg;
int in[200005];
void add(int u, int v) {
  e[++k] = (E){v, h[u]};
  h[u] = k;
  in[v]++;
  g[++kg] = (E){u, hg[v]};
  hg[v] = kg;
}
bool Bfs(vector<int>& q) {
  register int i, j, v;
  for (i = 1; i <= n; i++)
    if (!in[i]) q.push_back(i);
  for (i = 0; i < q.size(); i++) {
    for (j = h[q[i]]; j; j = e[j].next) {
      if (!--in[e[j].v]) q.push_back(e[j].v);
    }
  }
  return q.size() == n;
}
int pr[200005], ne[200005];
int ans[200005], sm;
int main() {
  register int i, j;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &a, &b);
    add(a, b);
  }
  vector<int> tp;
  if (!Bfs(tp)) return puts("-1"), 0;
  for (i = 1; i <= n; i++) pr[i] = ne[i] = i;
  for (i = tp.size() - 1; i >= 0; i--) {
    for (j = h[tp[i]]; j; j = e[j].next) {
      pr[tp[i]] = min(pr[tp[i]], pr[e[j].v]);
    }
  }
  for (i = 0; i < tp.size(); i++) {
    for (j = hg[tp[i]]; j; j = g[j].next) {
      ne[tp[i]] = min(ne[tp[i]], ne[g[j].v]);
    }
  }
  for (i = 1; i <= n; i++) {
    if (min(pr[i], ne[i]) == i) ans[i] = 1, sm++;
  }
  printf("%d\n", sm);
  for (i = 1; i <= n; i++) {
    putchar("EA"[ans[i]]);
  }
}
