#include <bits/stdc++.h>
using namespace std;
const int MAXN = 202020;
int n, m, indeg[MAXN];
vector<int> G[MAXN], iG[MAXN];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    static int x, y;
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    iG[y].push_back(x);
    indeg[y]++;
  }
  vector<int> topo;
  queue<int> q;
  for (int i = 1; i <= n; ++i)
    if (indeg[i] == 0) q.push(i);
  while (!q.empty()) {
    int f = q.front();
    q.pop();
    topo.push_back(f);
    for (auto g : G[f]) {
      if (--indeg[g] == 0) q.push(g);
    }
  }
  vector<int> seen1(n + 1), seen2(n + 1);
  if (topo.size() < n) {
    puts("-1");
    return 0;
  }
  string s;
  int ac = 0;
  for (int i = 1; i <= n; ++i) {
    if (!seen1[i] && !seen2[i]) {
      s += 'A';
      ac++;
    } else {
      s += 'E';
    }
    q.push(i), seen1[i] = 1;
    while (!q.empty()) {
      int f = q.front();
      q.pop();
      for (auto g : G[f])
        if (!seen1[g]) {
          seen1[g] = 1;
          q.push(g);
        }
    }
    q.push(i), seen2[i] = 1;
    while (!q.empty()) {
      int f = q.front();
      q.pop();
      for (auto g : iG[f])
        if (!seen2[g]) {
          seen2[g] = 1;
          q.push(g);
        }
    }
  }
  cout << ac << '\n' << s << '\n';
  return 0;
}
