#include <bits/stdc++.h>
using namespace std;
template <class IT>
inline void cmax(IT &a, IT b) {
  if (a < b) a = b;
}
template <class IT>
inline void cmin(IT &a, IT b) {
  if (b < a) a = b;
}
template <class IT>
inline bool bmax(IT &a, IT b) {
  if (a < b) {
    a = b;
    return true;
  } else
    return false;
}
template <class IT>
inline bool bmin(IT &a, IT b) {
  if (a > b) {
    a = b;
    return true;
  } else
    return false;
}
const int N = 200005;
vector<int> E[N], E2[N];
int D[N], S[N], L[N], R[N], I[N];
inline void ac() {
  int n, i, j, v, u, t = 0, tp = 0, s;
  cin >> n >> i;
  s = n;
  while (i--) {
    cin >> v >> u;
    E[v].push_back(u);
    E2[u].push_back(v);
    ++I[u];
  }
  for (v = (1); v <= (n); ++v)
    if (!I[v]) S[++tp] = v;
  while (tp) {
    v = S[tp--];
    D[++t] = v;
    for (i = (0); i < (E[v].size()); ++i) {
      u = E[v][i];
      if (!(--I[u])) S[++tp] = u;
    }
  }
  if (t != n) {
    cout << "-1";
    return;
  }
  for (v = (1); v <= (n); ++v) L[v] = v;
  for (i = (n); i >= (1); --i) {
    v = D[i];
    for (j = (0); j < (E[v].size()); ++j) cmin(L[v], L[E[v][j]]);
  }
  for (v = (1); v <= (n); ++v) R[v] = v;
  for (i = (1); i <= (n); ++i) {
    v = D[i];
    for (j = (0); j < (E2[v].size()); ++j) cmin(R[v], R[E2[v][j]]);
  }
  for (v = (1); v <= (n); ++v)
    if (L[v] < v || R[v] < v) --s;
  cout << s << "\n";
  for (v = (1); v <= (n); ++v)
    if (L[v] < v || R[v] < v)
      cout << "E";
    else
      cout << "A";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ac();
  return 0;
}
