#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma G++ optimize(2)
using namespace std;
const int MAX_N = 2e5 + 5;
vector<int> g[MAX_N], rg[MAX_N];
bool vis1[MAX_N], vis2[MAX_N];
int out[MAX_N];
void init(int n) {
  for (register int i = 0; i <= n; ++i) out[i] = vis1[i] = vis2[i] = 0;
}
void dfs_1(int u) {
  vis1[u] = true;
  for (auto v : g[u])
    if (!vis1[v]) dfs_1(v);
}
void dfs_2(int u) {
  vis2[u] = true;
  for (auto v : rg[u])
    if (!vis2[v]) dfs_2(v);
}
bool ans[MAX_N];
int main() {
  int n, m;
  scanf("%d", &n), scanf("%d", &m);
  init(n);
  for (register int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d", &u), scanf("%d", &v);
    g[u].push_back(v), rg[v].push_back(u), out[u]++;
  }
  int cnt = 0;
  queue<int> q;
  for (register int i = 1; i <= n; ++i)
    if (!out[i]) q.push(i), cnt++;
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    for (auto v : rg[now])
      if (out[v]) {
        out[v]--;
        if (!out[v]) q.push(v), cnt++;
      }
  }
  if (cnt < n) {
    puts("-1");
    return 0;
  }
  memset(ans, 0, sizeof(ans));
  cnt = 0;
  for (register int i = 1; i <= n; ++i) {
    if (!vis1[i] && !vis2[i]) ans[i] = true, cnt++;
    if (!vis1[i]) dfs_1(i);
    if (!vis2[i]) dfs_2(i);
  }
  printf("%d\n", cnt);
  for (register int i = 1; i <= n; ++i) printf("%c", ans[i] ? 'A' : 'E');
  puts("");
  return 0;
}
