#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1, c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return f == 1 ? x : -x;
}
const int N = 2e5 + 4;
int n, m, ans[N];
struct QWQ {
  vector<int> e[N];
  int vis[N], in[N], f[N];
  void dfs(int x) {
    vis[x] = in[x] = 1;
    f[x] = x;
    for (auto v : e[x]) {
      if (in[v]) {
        puts("-1");
        exit(0);
      }
      if (!vis[v]) dfs(v);
      f[x] = min(f[x], f[v]);
    }
    in[x] = 0;
  }
  inline void solve() {
    for (int i = 1; i <= n; i++) dfs(i);
  }
} t1, t2;
int main() {
  n = read();
  m = read();
  for (int i = 1, u, v; i <= m; i++) {
    u = read();
    v = read();
    t1.e[u].push_back(v);
    t2.e[v].push_back(u);
  }
  t1.solve();
  t2.solve();
  for (int i = 1; i <= n; i++) {
    if (min(t1.f[i], t2.f[i]) == i) {
      ans[i] = 1;
      ans[0]++;
    }
  }
  cout << ans[0] << "\n";
  for (int i = 1; i <= n; i++) cout << (ans[i] ? 'A' : 'E');
  return (0 - 0);
}
