#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int N = 2e5;
int n, m, d[N + 7], f[N + 7], b[N + 7], sm, ans[N + 7];
vector<int> e[N + 7], g[N + 7];
int Bfs(vector<int>& q) {
  q.clear();
  for (int i = 1; i <= n; i++)
    if (!d[i]) q.push_back(i);
  for (int i = 0; i < int((q).size()); i++)
    for (int to : e[q[i]])
      if (!--d[to]) q.push_back(to);
  return int((q).size()) == n;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, u, v; i <= m; i++)
    scanf("%d%d", &u, &v), e[u].push_back(v), g[v].push_back(u);
  for (int i = 1; i <= n; i++) d[i] = int((g[i]).size());
  vector<int> tp;
  if (!Bfs(tp)) return puts("-1"), 0;
  iota(f + 1, f + n + 1, 1), iota(b + 1, b + n + 1, 1);
  for (int i = 0; i <= int((tp).size()) - 1; i++)
    for (int to : g[tp[i]]) f[tp[i]] = min(f[tp[i]], f[to]);
  for (int i = int((tp).size()) - 1; i >= 0; i--)
    for (int to : e[tp[i]]) b[tp[i]] = min(b[tp[i]], b[to]);
  for (int i = 1; i <= n; i++)
    if (min(f[i], b[i]) == i) sm++, ans[i] = 1;
  printf("%d\n", sm);
  for (int i = 1; i <= n; i++) putchar("EA"[ans[i]]);
  puts("");
  return 0;
}
