#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const int mod = 1000007;
vector<int> G[maxn], RG[maxn];
queue<int> Top;
char result[maxn];
int id[maxn], od[maxn], pre[maxn], lst[maxn];
int n, m;
int vis[maxn];
bool dfs(int u) {
  vis[u] = 1;
  for (int i = 0, len = G[u].size(); i < len; ++i) {
    if (vis[G[u][i]] == 1 || vis[G[u][i]] != 2 && dfs(G[u][i]) == false)
      return false;
  }
  vis[u] = 2;
  return true;
}
int tps[maxn];
bool topsort() {
  for (int i = 1; i <= n; ++i)
    if (od[i] == 0) Top.push(i);
  int pos = 0, cur;
  while (!Top.empty()) {
    cur = Top.front();
    Top.pop();
    tps[++pos] = cur;
    for (int j = 0, len = RG[cur].size(); j < len; ++j) {
      if (--od[RG[cur][j]] == 0) {
        Top.push(RG[cur][j]);
      }
    }
  }
  return pos == n;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, u, v; i <= m; ++i) {
    scanf("%d%d", &u, &v);
    G[v].emplace_back(u);
    RG[u].emplace_back(v);
    ++id[u];
    ++od[v];
  }
  bool flag = true;
  for (int i = 1; i <= n; ++i) {
    if (!vis[i]) {
      if (dfs(i) == false) {
        flag = false;
        break;
      }
    }
  }
  if (!flag) {
    printf("-1");
    return 0;
  }
  topsort();
  for (int _ = 1, i, j; _ <= n; ++_) {
    i = tps[_];
    pre[i] = i;
    for (j = 0; j < G[i].size(); ++j) {
      pre[i] = min(pre[i], pre[G[i][j]]);
    }
  }
  int ans = 0;
  for (int _ = n, i, j; _ >= 1; --_) {
    i = tps[_];
    lst[i] = i;
    for (j = 0; j < RG[i].size(); ++j) {
      lst[i] = min(lst[i], lst[RG[i][j]]);
    }
    if (pre[i] == lst[i]) ans++;
  }
  printf("%d\n", ans);
  for (int i = 1; i <= n; ++i) {
    if (pre[i] == lst[i])
      printf("A");
    else
      printf("E");
  }
}
