#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
const int inf = 2147483647;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10ll + ch - '0', ch = getchar();
  return x * f;
}
int n, m, deg[N], b[N];
bool v1[N], v2[N];
vector<int> G[N], P[N];
queue<int> q;
int cnt = 0;
void dfs1(int x, int o) {
  v1[x] = true;
  if (x > o) b[x] = 0;
  for (int y : G[x]) {
    if (v1[y]) continue;
    dfs1(y, o);
  }
}
void dfs2(int x, int o) {
  v2[x] = true;
  if (x > o) b[x] = 0;
  for (int y : P[x]) {
    if (v2[y]) continue;
    dfs2(y, o);
  }
}
int main() {
  memset(b, -1, sizeof(b));
  n = read(), m = read();
  for (int i = 1; i <= m; i++) {
    int x = read(), y = read();
    G[x].push_back(y);
    deg[y]++;
    P[y].push_back(x);
  }
  for (int i = 1; i <= n; i++)
    if (!deg[i]) cnt++, q.push(i);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int y : G[x]) {
      deg[y]--;
      if (!deg[y]) cnt++, q.push(y);
    }
  }
  if (cnt != n) return puts("-1"), 0;
  for (int i = 1; i <= n; i++) {
    if (b[i] == -1) b[i] = 1;
    if (!v1[i]) dfs1(i, i);
    if (!v2[i]) dfs2(i, i);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) ans += b[i];
  printf("%d\n", ans);
  for (int i = 1; i <= n; i++) putchar(b[i] ? 'A' : 'E');
}
