#include <bits/stdc++.h>
using namespace std;
const int N = 1 + 2e5;
vector<int> one[N], two[N], *graph;
int ord[N], wt[N], nr;
char ans[N];
void dfs(int x) {
  ord[x] = ++nr;
  if (wt[x] < x) ans[x - 1] = 'E';
  for (int y : graph[x]) {
    wt[y] = min(wt[x], wt[y]);
    ord[y]--;
    if (!ord[y]) dfs(y);
  }
}
void run_dfs(vector<int>* G, int n) {
  graph = G;
  memset(ord, 0, sizeof(ord));
  for (int x = 1; x <= n; x++) {
    wt[x] = x;
    for (int y : graph[x]) {
      ord[y]++;
    }
  }
  for (int x = 1; x <= n; x++) {
    if (!ord[x]) dfs(x);
  }
}
int solve(int n) {
  memset(ans, 'A', n * sizeof(*ans));
  run_dfs(one, n);
  for (int x = 1; x <= n; x++) {
    for (int y : graph[x]) {
      if (ord[y] <= ord[x]) return -1;
    }
  }
  run_dfs(two, n);
  int q = 0;
  for (int i = 0; i < n; i++) q += ans[i] == 'A';
  return q;
}
int main() {
  int n, m, x, y;
  scanf("%d%d", &n, &m);
  while (m--) {
    scanf("%d%d", &x, &y);
    one[x].push_back(y);
    two[y].push_back(x);
  }
  int q = solve(n);
  printf("%d\n", q);
  if (q != -1) puts(ans);
  return 0;
}
