#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
int n, m, ji, ki;
vector<int> g[MAXN], gr[MAXN];
int col[MAXN];
bool dfs(int u) {
  col[u] = 1;
  for (int v : g[u]) {
    if (col[v] == 1) return true;
    if (col[v] == 2) continue;
    if (dfs(v)) return true;
  }
  col[u] = 2;
  return false;
}
bool vis1[MAXN], vis2[MAXN];
void dfs1(int u) {
  vis1[u] = true;
  for (int v : g[u]) {
    if (vis1[v]) continue;
    dfs1(v);
  }
}
void dfs2(int u) {
  vis2[u] = true;
  for (int v : gr[u]) {
    if (vis2[v]) continue;
    dfs2(v);
  }
}
char ans[MAXN];
int main() {
  scanf("%d %d", &n, &m);
  while (m--) {
    scanf("%d %d", &ji, &ki);
    ji--, ki--;
    g[ji].push_back(ki);
    gr[ki].push_back(ji);
  }
  for (int i = 0; i < n; i++) {
    if (col[i] == 2) continue;
    if (dfs(i)) {
      printf("-1\n");
      return 0;
    }
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (vis1[i] || vis2[i]) {
      ans[i] = 'E';
    } else {
      res++;
      ans[i] = 'A';
    }
    dfs1(i);
    dfs2(i);
  }
  ans[n] = 0;
  printf("%d\n%s\n", res, ans);
  return 0;
}
