#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 7;
struct Edge {
  int to, next;
} edge[MAXN * 2];
int edge_head[MAXN];
int edge_head2[MAXN];
int edge_cnt = 0;
void AddEdge(int form, int to) {
  edge[++edge_cnt].to = to;
  edge[edge_cnt].next = edge_head[form];
  edge_head[form] = edge_cnt;
}
void AddEdge2(int form, int to) {
  edge[++edge_cnt].to = to;
  edge[edge_cnt].next = edge_head2[form];
  edge_head2[form] = edge_cnt;
}
int n, m;
int in[MAXN];
int que[MAXN];
bool visit[MAXN];
bool visit2[MAXN];
int answer[MAXN];
void DFS2(int now) {
  if (visit2[now]) {
    return;
  }
  visit2[now] = 1;
  for (int edge_i = edge_head2[now]; edge_i; edge_i = edge[edge_i].next) {
    DFS2(edge[edge_i].to);
  }
}
void DFS(int now) {
  if (visit[now]) {
    return;
  }
  visit[now] = 1;
  for (int edge_i = edge_head[now]; edge_i; edge_i = edge[edge_i].next) {
    DFS(edge[edge_i].to);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  int f, t;
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &f, &t);
    AddEdge(f, t);
    in[t]++;
    AddEdge2(t, f);
  }
  int tail = 0, head = 0;
  for (int i = 1; i <= n; ++i) {
    if (!in[i]) {
      que[++tail] = i;
    }
  }
  while (++head <= tail) {
    for (int edge_i = edge_head[que[head]]; edge_i;
         edge_i = edge[edge_i].next) {
      --in[edge[edge_i].to];
      if (!in[edge[edge_i].to]) {
        que[++tail] = edge[edge_i].to;
      }
    }
  }
  if (tail ^ n) {
    printf("-1");
    return 0;
  }
  int sum = 0;
  for (int i = 1; i <= n; ++i) {
    if (!visit[i] && !visit2[i]) {
      answer[i] = 1;
      sum++;
    }
    DFS(i);
    DFS2(i);
  }
  printf("%d\n", sum);
  for (int i = 1; i <= n; ++i) {
    printf("%c", "EA"[answer[i]]);
  }
  return 0;
}
