#include <bits/stdc++.h>
using namespace std;
const int inv = 1000000000;
const int minv = -inv;
const int max_n = 200000 + 5;
int n, m;
vector<int> adjl[2][max_n];
vector<int> tsort;
int xtsort[max_n];
bool visited[2][max_n] = {0};
int ures;
string res;
void DFS(int t, int vt, bool f) {
  visited[t][vt] = true;
  for (int i = 0; i < (int)adjl[t][vt].size(); ++i) {
    int nb = adjl[t][vt][i];
    if (not visited[t][nb]) DFS(t, nb, f);
  }
  if (f) tsort.push_back(vt);
}
int main() {
  scanf("%d", &n);
  scanf("%d", &m);
  int u, v;
  for (int i = 0; i < m; ++i) {
    scanf("%d", &u);
    scanf("%d", &v);
    --u;
    --v;
    adjl[0][u].push_back(v);
    adjl[1][v].push_back(u);
  }
  for (int vt = 0; vt < n; ++vt)
    if (not visited[0][vt]) DFS(0, vt, true);
  reverse(tsort.begin(), tsort.end());
  for (int i = 0; i < n; ++i) xtsort[tsort[i]] = i;
  for (int i = 0; i < n; ++i) {
    int vt = tsort[i];
    for (int j = 0; j < (int)adjl[0][vt].size(); ++j) {
      int nb = adjl[0][vt][j];
      if (xtsort[nb] < xtsort[vt]) {
        printf("%d\n", -1);
        return 0;
      }
    }
  }
  fill(visited[0], visited[0] + n, false);
  ures = 0;
  res = "";
  for (int vt = 0; vt < n; ++vt) {
    if (visited[0][vt] or visited[1][vt])
      res += "E";
    else {
      res += "A";
      ++ures;
    }
    for (int t = 0; t < 2; ++t)
      if (not visited[t][vt]) DFS(t, vt, false);
  }
  printf("%d\n", ures);
  cout << res << "\n";
  return 0;
}
