#include <bits/stdc++.h>
using namespace ::std;
const long double PI = acos(-1);
const long long MOD = 1000000000 + 7;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long add(long long a, long long b, long long m = MOD) {
  if (a >= m) a %= m;
  if (b >= m) b %= m;
  if (a < 0) a += m;
  if (b < 0) b += m;
  long long res = a + b;
  if (res >= m or res <= -m) res %= m;
  if (res < 0) res += m;
  return res;
}
long long mul(long long a, long long b, long long m = MOD) {
  if (a >= m) a %= m;
  if (b >= m) b %= m;
  if (a < 0) a += m;
  if (b < 0) b += m;
  long long res = a * b;
  if (res >= m or res <= -m) res %= m;
  if (res < 0) res += m;
  return res;
}
long long pow_mod(long long a, long long b, long long m = MOD) {
  long long res = 1LL;
  a = a % m;
  while (b) {
    if (b & 1) res = mul(res, a, m);
    b >>= 1;
    a = mul(a, a, m);
  }
  return res;
}
long long fastexp(long long a, long long b) {
  long long res = 1LL;
  while (b) {
    if (b & 1) res = res * a;
    b >>= 1;
    a *= a;
  }
  return res;
}
int gcdExtendido(int a, int b, int *x, int *y) {
  if (a == 0) {
    *x = 0;
    *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtendido(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
int modInverso(int a, int m) {
  int x, y;
  int g = gcdExtendido(a, m, &x, &y);
  if (g != 1)
    return -1;
  else
    return (x % m + m) % m;
}
const int N = 200000 + 5;
int n;
int m;
vector<int> G[N];
char ans[N];
int TopoOrder[N];
bool TopoSort() {
  vector<int> deg(n, 0);
  for (int i = 0; i < n; i++) {
    for (int v : G[i]) {
      deg[v] += 1;
    }
  }
  int len = 0;
  for (int i = 0; i < n; i++) {
    if (deg[i] == 0) {
      TopoOrder[len++] = i;
    }
  }
  for (int i = 0; i < len; i++) {
    int u = TopoOrder[i];
    for (int v : G[u]) {
      deg[v] -= 1;
      if (deg[v] == 0) {
        TopoOrder[len++] = v;
      }
    }
  }
  if (len < n) return false;
  return true;
}
int main() {
  scanf("%d %d", &(n), &(m));
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &(u), &(v));
    u--;
    v--;
    G[u].emplace_back(v);
  }
  if (!TopoSort()) {
    puts("-1");
    return 0;
  }
  for (int i = 0; i < n; i++) ans[i] = 'A';
  vector<int> memo(n);
  iota((memo).begin(), (memo).end(), 0);
  for (int i = 0; i < n; i++) {
    int u = TopoOrder[i];
    for (int v : G[u]) {
      memo[v] = min(memo[v], memo[u]);
    }
  }
  for (int i = 0; i < n; i++) {
    if (memo[i] < i) ans[i] = 'E';
  }
  reverse(TopoOrder, TopoOrder + n);
  iota((memo).begin(), (memo).end(), 0);
  for (int i = 0; i < n; i++) {
    int u = TopoOrder[i];
    for (int v : G[u]) {
      memo[u] = min(memo[u], memo[v]);
    }
  }
  for (int i = 0; i < n; i++) {
    if (memo[i] < i) ans[i] = 'E';
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cnt += ans[i] == 'A';
  }
  ans[n] = '\0';
  printf("%d\n%s\n", cnt, ans);
  return 0;
}
