#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 100;
const long long inf = 0x3f3f3f3f;
const long long iinf = 1 << 30;
const long long linf = 2e18;
const long long mod = 998244353;
const double eps = 1e-7;
template <class T = long long>
T chmin(T &a, T b) {
  return a = min(a, b);
}
template <class T = long long>
T chmax(T &a, T b) {
  return a = max(a, b);
}
template <class T = long long>
inline void red(T &x) {
  x -= mod, x += x >> 31 & mod;
}
template <class T = long long>
T read() {
  T f = 1, a = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    a = (a << 3) + (a << 1) + ch - '0';
    ch = getchar();
  }
  return a * f;
}
long long n, m;
long long out[maxn], in[maxn], f[maxn], g[maxn];
vector<long long> edge[maxn], rev[maxn];
char ans[maxn];
long long sum;
signed main() {
  n = read(), m = read();
  for (long long i = (1); i <= (m); ++i) {
    long long u = read(), v = read();
    edge[u].push_back(v), rev[v].push_back(u);
    out[v]++, in[u]++;
  }
  queue<long long> q;
  for (long long i = (1); i <= (n); ++i) {
    f[i] = i;
    if (!out[i]) q.push(i);
  }
  while (!q.empty()) {
    long long now = q.front();
    q.pop();
    for (long long to : edge[now]) {
      out[to]--;
      chmin(f[to], f[now]);
      if (!out[to]) q.push(to);
    }
  }
  for (long long i = (1); i <= (n); ++i)
    if (out[i]) return puts("-1"), 0;
  for (long long i = (1); i <= (n); ++i) {
    g[i] = i;
    if (!in[i]) q.push(i);
  }
  while (!q.empty()) {
    long long now = q.front();
    q.pop();
    for (long long to : rev[now]) {
      in[to]--;
      chmin(g[to], g[now]);
      if (!in[to]) q.push(to);
    }
  }
  for (long long i = (1); i <= (n); ++i) {
    if (min(f[i], g[i]) < i)
      ans[i] = 'E';
    else
      ans[i] = 'A', ++sum;
  }
  printf("%lld\n%s\n", sum, ans + 1);
  return 0;
}
