#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200200;
int n, m, deg[MAXN];
int mn[MAXN], rmn[MAXN];
vector<int> g[MAXN], rg[MAXN];
bool f(vector<int> adj[], int x[]) {
  queue<int> q;
  for (int i = 1; i <= n; ++i)
    for (const int& u : adj[i]) deg[u]++;
  for (int i = 1; i <= n; ++i)
    if (!deg[i]) q.push(i);
  iota(x + 1, x + n + 1, 1);
  int cnt = 0;
  while (!q.empty()) {
    int cur = q.front();
    cnt++;
    q.pop();
    for (const int& u : adj[cur]) {
      x[u] = min(x[u], x[cur]);
      if (--deg[u] == 0) q.push(u);
    }
  }
  if (cnt != n) return false;
  return true;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1, u, v; i <= m; ++i)
    scanf("%d %d", &u, &v), rg[u].push_back(v), g[v].push_back(u);
  if (!f(g, mn)) printf("-1\n"), exit(0);
  f(rg, rmn);
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    if (mn[i] == rmn[i] and mn[i] == i) ans++;
  printf("%d\n", ans);
  for (int i = 1; i <= n; ++i) printf("%c", "EA"[mn[i] == rmn[i]]);
}
