#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, m, deg1[N], deg2[N], lmin[N], rmin[N], ans[N];
int tot1, head1[N], ver1[N], nxt1[N];
int tot2, head2[N], ver2[N], nxt2[N];
queue<int> q;
void add1(int x, int y) {
  nxt1[++tot1] = head1[x];
  head1[x] = tot1;
  ver1[tot1] = y;
}
void add2(int x, int y) {
  nxt2[++tot2] = head2[x];
  head2[x] = tot2;
  ver2[tot2] = y;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    add1(x, y);
    add2(y, x);
    deg1[y]++;
    deg2[x]++;
  }
  memset(lmin, 0x3f, sizeof lmin);
  memset(rmin, 0x3f, sizeof rmin);
  for (int i = 1; i <= n; i++)
    if (!deg1[i]) q.push(i);
  while (q.size()) {
    int x = q.front();
    q.pop();
    for (int i = head1[x]; i; i = nxt1[i]) {
      int y = ver1[i];
      lmin[y] = min(lmin[y], min(x, lmin[x]));
      deg1[y]--;
      if (!deg1[y]) q.push(y);
    }
  }
  for (int i = 1; i <= n; i++)
    if (!deg2[i]) q.push(i);
  while (q.size()) {
    int x = q.front();
    q.pop();
    for (int i = head2[x]; i; i = nxt2[i]) {
      int y = ver2[i];
      rmin[y] = min(rmin[y], min(x, rmin[x]));
      deg2[y]--;
      if (!deg2[y]) q.push(y);
    }
  }
  bool f = true;
  for (int i = 1; i <= n; i++)
    if (deg1[i] or deg2[i]) f = false;
  if (not f) {
    printf("-1\n");
    return 0;
  }
  for (int i = 1; i <= n; i++)
    if (lmin[i] >= i && rmin[i] >= i) {
      ans[0]++;
      ans[i] = 1;
    }
  printf("%d\n", ans[0]);
  for (int i = 1; i <= n; i++) {
    if (ans[i])
      printf("A");
    else
      printf("E");
  }
  return 0;
}
