#include <bits/stdc++.h>
using namespace std;
const int N = 200020;
inline int read() {
  int x = 0;
  char c = getchar();
  bool f = 0;
  while (c < '0' || c > '9') f |= (c == '-'), c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + (c ^ 48), c = getchar();
  return f ? -x : x;
}
int n, m, vis[N];
int head[2][N], to[N * 2], nxt[N * 2], deg[N], cnt;
void addedge(int* head, int u, int v) {
  to[++cnt] = v;
  nxt[cnt] = head[u];
  head[u] = cnt;
}
void check(int* head) {
  queue<int> Q;
  for (int i = 1; i <= n; ++i)
    if (deg[i] == 0) Q.push(i);
  while (Q.size()) {
    int x = Q.front();
    Q.pop();
    for (int i = head[x]; i; i = nxt[i]) {
      int y = to[i];
      if (!--deg[y]) Q.push(y);
    }
  }
  for (int i = 1; i <= n; ++i)
    if (deg[i] > 0) {
      puts("-1");
      exit(0);
    }
};
int ans = 0;
char p[N];
void dfs(int x, int w) {
  if ((vis[x] >> w) & 1) return;
  vis[x] |= (1 << w);
  for (int i = head[w][x]; i; i = nxt[i]) {
    int y = to[i];
    dfs(y, w);
  }
}
int main() {
  n = read(), m = read();
  while (m--) {
    int x = read(), y = read();
    addedge(head[0], x, y), addedge(head[1], y, x);
    deg[y]++;
  }
  check(head[0]);
  for (int i = 1; i <= n; ++i) {
    if (vis[i] == 0)
      p[i] = 'A', ans++;
    else
      p[i] = 'E';
    dfs(i, 0), dfs(i, 1);
  }
  printf("%d\n%s", ans, p + 1);
}
