#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') {
      f = -1;
    }
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - 48;
    c = getchar();
  }
  return x * f;
}
const int maxn = 200010;
vector<int> E[maxn], G[maxn];
int n, m;
int deg[maxn], deg2[maxn], cnt;
int f1[maxn], f2[maxn];
void topsort1() {
  queue<int> q;
  for (int i = 1; i <= n; ++i) {
    if (deg[i] == 0) {
      q.push(i);
    }
  }
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    cnt++;
    for (int i = 0; i < E[x].size(); ++i) {
      int y = E[x][i];
      f1[y] = min(f1[x], f1[y]);
      if (--deg[y] == 0) {
        q.push(y);
      }
    }
  }
}
void topsort2() {
  queue<int> q;
  for (int i = 1; i <= n; ++i) {
    if (deg2[i] == 0) {
      q.push(i);
    }
  }
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = 0; i < G[x].size(); ++i) {
      int y = G[x][i];
      f2[y] = min(f2[x], f2[y]);
      if (--deg2[y] == 0) {
        q.push(y);
      }
    }
  }
}
char c[maxn];
int main() {
  n = read(), m = read();
  for (int i = 1; i <= m; ++i) {
    int u = read(), v = read();
    G[u].push_back(v), E[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) {
    deg[i] = G[i].size();
    deg2[i] = E[i].size();
    f1[i] = f2[i] = i;
  }
  topsort1();
  topsort2();
  if (cnt < n) {
    puts("-1");
  } else {
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
      if (f1[i] == f2[i]) {
        ++ans;
        c[i - 1] = 'A';
      } else {
        c[i - 1] = 'E';
      }
    }
    c[n] = '\0';
    printf("%d\n", ans);
    puts(c);
  }
  return 0;
}
