#include <bits/stdc++.h>
using namespace std;
const int INF = 1012345678;
vector<int> AdjList[200005];
vector<int> revAdjList[200005];
int dp[200005][2];
char ans[200005];
bool visited[200005];
int toposort[200005];
int cnt = 0;
void dfs2(int u) {
  if (visited[u]) {
    return;
  }
  visited[u] = true;
  for (int v : AdjList[u]) {
    if (!visited[v]) {
      dfs2(v);
    }
  }
  toposort[cnt++] = u;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    AdjList[a].push_back(b);
    revAdjList[b].push_back(a);
  }
  memset(visited, 0, sizeof(visited));
  for (int i = 1; i <= n; i++) {
    if (!visited[i]) {
      dfs2(i);
    }
  }
  memset(dp, -1, sizeof(dp));
  for (int i = 0; i < n; i++) {
    int u = toposort[i];
    dp[u][0] = u;
    for (int v : AdjList[u]) {
      if (dp[v][0] == -1) {
        printf("-1");
        return 0;
      }
      dp[u][0] = min(dp[u][0], dp[v][0]);
    }
  }
  reverse(toposort, toposort + n);
  for (int i = 0; i < n; i++) {
    int u = toposort[i];
    dp[u][1] = u;
    for (int v : revAdjList[u]) {
      if (dp[v][1] == -1) {
        printf("-1");
        return 0;
      }
      dp[u][1] = min(dp[u][1], dp[v][1]);
    }
  }
  int ans1 = 0;
  for (int i = 1; i <= n; i++) {
    if (min(dp[i][0], dp[i][1]) == i) {
      ans1++;
      ans[i - 1] = 'A';
    } else {
      ans[i - 1] = 'E';
    }
  }
  printf("%d\n%s", ans1, ans);
  return 0;
}
