#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int n, m;
int din[N];
int pre[N], nex[N];
vector<int> to[N], from[N], Top;
bool st[N];
void topsort() {
  queue<int> que;
  for (int i = 1; i <= n; i++) {
    if (!din[i]) que.push(i);
  }
  while (que.size()) {
    int u = que.front();
    que.pop();
    for (auto i : to[u]) {
      if (--din[i] == 0) que.push(i);
    }
    Top.push_back(u);
  }
  if (Top.size() < n) puts("-1"), exit(0);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    to[a].push_back(b);
    from[b].push_back(a);
    din[b]++;
  }
  topsort();
  for (int i = 1; i <= n; i++) pre[i] = nex[i] = i;
  for (auto i : Top) {
    for (auto j : from[i]) {
      pre[i] = min(pre[i], pre[j]);
    }
  }
  for (int i = Top.size() - 1; i >= 0; i--) {
    int u = Top[i];
    for (int j = to[u].size() - 1; j >= 0; j--) {
      int v = to[u][j];
      nex[u] = min(nex[u], nex[v]);
    }
  }
  int res = 0;
  for (int i = 1; i <= n; i++)
    if (min(nex[i], pre[i]) == i) st[i] = true, res++;
  printf("%d\n", res);
  for (int i = 1; i <= n; i++) printf(st[i] ? "A" : "E");
}
