#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n, m, d[maxn << 1], num, f[maxn << 1];
int head[maxn << 1], cnt;
struct edge {
  int to, next;
} e[maxn << 1];
char s[maxn];
void adde(int u, int v) {
  e[++cnt].to = v;
  d[v]++;
  e[cnt].next = head[u];
  head[u] = cnt;
}
int read() {
  int res = 0, f = 1;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = -1;
  } while (!isdigit(ch));
  do {
    res = res * 10 + ch - '0';
    ch = getchar();
  } while (isdigit(ch));
  return res * f;
}
void topsort() {
  queue<int> q;
  for (int i = (1); i <= (n << 1); ++i)
    if (!d[i]) q.push(i);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = head[u]; i; i = e[i].next) {
      int v = e[i].to;
      d[v]--;
      f[v] = min(f[u], f[v]);
      if (!d[v]) q.push(v);
    }
  }
}
signed main() {
  n = read();
  m = read();
  for (int i = (1); i <= (m); ++i) {
    int u = read(), v = read();
    adde(u, v);
    adde(v + n, u + n);
  }
  for (int i = (1); i <= (n << 1); ++i) f[i] = i;
  topsort();
  for (int i = (1); i <= (n); ++i)
    if (d[i]) return puts("-1"), 0;
  for (int i = (1); i <= (n); ++i)
    if (f[i] == i && f[i + n] == i + n)
      s[i] = 'A', ++num;
    else
      s[i] = 'E';
  printf("%d\n", num);
  puts(s + 1);
}
