#include <bits/stdc++.h>
using namespace std;
const int max_n = 200005;
int n, m;
vector<int> G1[max_n], G2[max_n];
bool vis1[max_n], vis2[max_n];
void dfs1(int u) {
  vis1[u] = true;
  for (auto v : G1[u]) {
    if (!vis1[v]) dfs1(v);
  }
}
void dfs2(int u) {
  vis2[u] = true;
  for (auto v : G2[u]) {
    if (!vis2[v]) dfs2(v);
  }
}
int in[max_n];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G1[u].push_back(v), G2[v].push_back(u);
    in[v]++;
  }
  int cnt = 0;
  queue<int> que;
  for (int i = 1; i <= n; i++)
    if (in[i] == 0) que.push(i);
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    cnt++;
    for (auto v : G1[u]) {
      in[v]--;
      if (in[v] == 0) que.push(v);
    }
  }
  if (cnt != n)
    printf("-1\n");
  else {
    int ans = 0;
    string s;
    for (int i = 1; i <= n; i++) {
      if (!vis1[i] && !vis2[i]) {
        ans++;
        s += 'A';
      } else
        s += 'E';
      dfs1(i);
      dfs2(i);
    }
    printf("%d\n", ans);
    printf("%s\n", s.c_str());
  }
  return 0;
}
