#include <bits/stdc++.h>
using namespace std;
const long long oo = 2e18;
template <typename... Args>
void db(Args... args) {}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long N, M;
  cin >> N >> M;
  vector<vector<long long>> L(N + 1);
  vector<long long> men(N + 1);
  for (long long i = 1; i <= M; i++) {
    long long a, b;
    cin >> a >> b;
    L[a].push_back(b);
  }
  vector<bool> marcado(N + 1);
  function<void(long long)> ddd = [&](long long nodo) {
    marcado[nodo] = true;
    men[nodo] = nodo;
    db(nodo);
    for (auto v : L[nodo]) {
      if (!marcado[v]) {
        ddd(v);
      }
      men[nodo] = min(men[nodo], men[v]);
      db(v);
    }
  };
  for (long long i = 1; i <= N; i++) {
    if (!marcado[i]) {
      ddd(i);
      db(men[i]);
    }
  }
  vector<bool> mark(N + 1);
  vector<bool> in(N + 1);
  bool cycle = false;
  function<void(long long)> dfscy = [&](long long nodo) {
    mark[nodo] = true;
    in[nodo] = true;
    for (auto v : L[nodo]) {
      if (in[v]) {
        cycle = true;
      }
      if (!mark[v]) {
        dfscy(v);
      }
    }
    in[nodo] = false;
  };
  for (long long i = 1; i <= N; i++) {
    if (!mark[i]) {
      dfscy(i);
    }
  }
  if (cycle) {
    cout << -1 << '\n';
    return 0;
  }
  string cad;
  vector<bool> mk(N + 1);
  function<void(long long)> DFS = [&](long long nodo) {
    mk[nodo] = true;
    for (auto v : L[nodo]) {
      if (!mk[v]) {
        DFS(v);
      }
    }
  };
  long long cont = 0;
  for (long long i = 1; i <= N; i++) {
    if (!mk[i]) {
      if (men[i] == i) {
        cad += "A";
        cont++;
      } else
        cad += "E";
      DFS(i);
    } else
      cad += "E";
  }
  db(men);
  cout << cont << '\n';
  cout << cad << '\n';
  return 0;
}
