#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
const int inf = 0x3f3f3f3f;
int dfn[maxn], low[maxn], idx = 0, scnt = 0;
int rdfn[maxn], rlow[maxn];
stack<int> st;
bool vis[maxn];
vector<int> e[maxn], re[maxn];
bool ok = 1;
void dfs(int x, vector<int> *e, int *dfn, int *low) {
  dfn[x] = low[x] = ++idx;
  st.push(x);
  vis[x] = 1;
  for (auto v : e[x]) {
    if (!dfn[v]) {
      dfs(v, e, dfn, low);
      low[x] = min(low[x], low[v]);
    } else if (vis[v])
      low[x] = min(low[x], dfn[v]);
  }
  if (dfn[x] == low[x]) {
    int k = st.top();
    int num = 0;
    do {
      k = st.top();
      st.pop();
      ++num;
      vis[k] = 0;
    } while (k != x);
    if (num > 1) ok = 0;
  }
}
int in[maxn], rin[maxn];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    e[a].push_back(b);
    re[b].push_back(a);
    in[b]++;
    rin[a]++;
  }
  int cnta = 0, cntb = 0;
  string str;
  int res = 0;
  for (int i = 1; i <= n; i++) {
    if (!dfn[i] && !rdfn[i])
      str += "A", ++res;
    else
      str += "E";
    ok = 1;
    if (!dfn[i]) dfs(i, e, dfn, low);
    if (!ok) printf("-1\n"), exit(0);
    ok = 1;
    if (!rdfn[i]) dfs(i, re, rdfn, rlow);
    if (!ok) printf("-1\n"), exit(0);
  }
  cout << res << "\n" << str << endl;
  return 0;
}
