#include <bits/stdc++.h>
using namespace std;
int n, m;
int mn1[200003], mn2[200003];
int visited[200003], cnt[200003];
char ans[200003];
vector<int> nxt[200003], bck[200003];
bool cycle = 0;
void cek_cycle(int u) {
  visited[u] = 1;
  for (int v : nxt[u]) {
    if (visited[v] == 1) cycle = 1;
    if (visited[v] == 0) cek_cycle(v);
  }
  visited[u] = 2;
}
void topo() {
  queue<int> q;
  memset(cnt, 0, sizeof cnt);
  for (int i = 1; i <= n; i++) {
    if (nxt[i].size() == 0) q.push(i);
  }
  while (q.size()) {
    int u = q.front();
    q.pop();
    for (int v : nxt[u]) mn1[u] = min(mn1[v], mn1[u]);
    for (int v : bck[u]) {
      cnt[v]++;
      if (cnt[v] == nxt[v].size()) q.push(v);
    }
  }
  memset(cnt, 0, sizeof cnt);
  for (int i = 1; i <= n; i++) {
    if (bck[i].size() == 0) q.push(i);
  }
  while (q.size()) {
    int u = q.front();
    q.pop();
    for (int v : bck[u]) mn2[u] = min(mn2[v], mn2[u]);
    for (int v : nxt[u]) {
      cnt[v]++;
      if (cnt[v] == bck[v].size()) q.push(v);
    }
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) mn1[i] = mn2[i] = i;
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    nxt[u].push_back(v);
    bck[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    if (visited[i] == 0) cek_cycle(i);
  }
  if (cycle) {
    printf("-1\n");
    return 0;
  }
  topo();
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (mn1[i] == i && mn2[i] == i) {
      ans[i] = 'A';
      cnt++;
    } else
      ans[i] = 'E';
  }
  printf("%d\n", cnt);
  for (int i = 1; i <= n; i++) printf("%c", ans[i]);
  printf("\n");
}
