#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int n, m, u, v;
int p[maxn], q[maxn], in[maxn];
char ans[maxn];
vector<int> g[maxn], b[maxn], vc;
struct Edge {
  int to, nex;
} edge[maxn << 1];
int head[maxn], ecnt;
void add_edge(int u, int v) {
  edge[++ecnt] = {v, head[u]};
  head[u] = ecnt;
  g[u].push_back(v);
  b[v].push_back(u);
}
int sta[maxn], sta_top;
inline bool tp_check_circle() {
  memset(sta, 0, sizeof sta);
  sta_top = 0;
  for (int i = 1; i <= n; i++)
    if (!in[i]) sta[++sta_top] = i, vc.push_back(i);
  while (sta_top) {
    int now = sta[sta_top--];
    for (int i = head[now]; i; i = edge[i].nex) {
      int to = edge[i].to;
      in[to]--;
      if (in[to] == 0) sta[++sta_top] = to, vc.push_back(to);
    }
  }
  for (int i = 1; i <= n; i++)
    if (in[i]) return true;
  return false;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) scanf("%d %d", &u, &v), add_edge(u, v), in[v]++;
  for (int i = 1; i <= n; i++) q[i] = p[i] = i, ans[i] = 'E';
  if (tp_check_circle()) return puts("-1"), 0;
  for (int i = 0; i < vc.size(); i++) {
    int now = vc[i];
    for (auto to : b[now]) p[now] = min(p[now], p[to]);
  }
  for (int i = vc.size() - 1; i >= 0; i--) {
    int now = vc[i];
    for (auto to : g[now]) q[now] = min(q[now], q[to]);
  }
  int sz = 0;
  for (int i = 1; i <= n; i++)
    if (p[i] == i && q[i] == i) sz++, ans[i] = 'A';
  printf("%d\n", sz);
  for (int i = 1; i <= n; i++) printf("%c", ans[i]);
  puts("");
  return 0;
}
