#include <bits/stdc++.h>
const int maxn = 2e5 + 3;
int n, m, d[maxn], cm[maxn], rcm[maxn];
std::vector<int> E[maxn], rE[maxn];
int topo[maxn], tl;
void addedge() {
  int u, v;
  scanf("%d%d", &u, &v);
  E[v].push_back(u);
  d[u] += 1;
  rE[u].push_back(v);
}
int ro[maxn], sid[maxn], rclk, ns;
bool vis[maxn];
void dfs(int u) {
  vis[u] = true;
  for (auto &&v : E[u]) {
    if (!vis[v]) {
      dfs(v);
    }
  }
  ro[rclk++] = u;
}
void rdfs(int u) {
  vis[u] = true;
  sid[u] = ns;
  for (auto &&v : rE[u]) {
    if (!vis[v]) {
      rdfs(v);
    }
  }
}
void kosaraju() {
  memset(vis, 0, sizeof(bool) * (n + 1));
  rclk = 0;
  for (int u = 1; u <= n; ++u) {
    if (!vis[u]) {
      dfs(u);
    }
  }
  memset(vis, 0, sizeof(bool) * (n + 1));
  ns = 0;
  for (int u = n - 1; u >= 0; --u) {
    if (!vis[ro[u]]) {
      rdfs(ro[u]);
      ++ns;
    }
  }
}
void tsort() {
  std::queue<int> q;
  for (int i = 1; i <= n; ++i) {
    if (d[i] == 0) {
      q.push(i);
    }
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    topo[tl++] = u;
    for (auto &&v : E[u]) {
      if ((--d[v]) == 0) {
        q.push(v);
      }
    }
  }
}
int ans;
char res[maxn];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) addedge();
  kosaraju();
  if (ns < n) {
    puts("-1");
    return 0;
  }
  memset(vis, 0, sizeof(bool) * (n + 1));
  tsort();
  for (int u = 1; u <= n; ++u) {
    cm[u] = u;
    rcm[u] = u;
  }
  for (int i = 0; i < n; ++i) {
    int u = topo[i];
    for (auto &&v : rE[u]) {
      cm[u] = std::min(cm[u], cm[v]);
    }
  }
  for (int i = n - 1; i >= 0; --i) {
    int u = topo[i];
    for (auto &&v : E[u]) {
      rcm[u] = std::min(rcm[u], rcm[v]);
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (cm[i] == rcm[i] && cm[i] == i) {
      res[i - 1] = 'A';
      ans += 1;
    } else {
      res[i - 1] = 'E';
    }
  }
  printf("%d\n%s\n", ans, res);
  return 0;
}
