#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;
vector<int> G[maxn];
vector<int> inv[maxn];
int n, m;
int vis[2][maxn];
int in[maxn];
inline int topo_sort(vector<int>* G, int* in) {
  stack<int> S;
  for (auto i = (0); i < (n); ++i) {
    if (in[i] == 0) S.push(i);
  }
  int cnt = 0;
  for (; !S.empty();) {
    int u = S.top();
    S.pop();
    ++cnt;
    for (auto v : G[u]) {
      if (--in[v] == 0) S.push(v);
    }
  }
  return cnt == n;
}
inline void dfs(int u, vector<int>* g, int* vis) {
  if (vis[u]) return;
  vis[u] = 1;
  for (auto v : g[u]) {
    if (vis[v]) continue;
    dfs(v, g, vis);
  }
}
inline void solve() {
  int ans = 0;
  string o;
  for (auto i = (0); i < (n); ++i) {
    if (!vis[0][i] && !vis[1][i]) {
      o.push_back('A');
      ans++;
    } else
      o.push_back('E');
    dfs(i, G, vis[0]);
    dfs(i, inv, vis[1]);
  }
  printf("%d\n%s\n", ans, o.c_str());
}
int main(void) {
  scanf("%d", &(n)), scanf("%d", &(m));
  for (auto i = (0); i < (m); ++i) {
    int u, v;
    scanf("%d", &(u)), scanf("%d", &(v));
    u--, v--;
    G[u].push_back(v);
    inv[v].push_back(u);
    in[v]++;
  }
  if (!topo_sort(G, in)) return puts("-1"), 0;
  solve();
  return 0;
}
