#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e5 + 123, inf = 1e9, mod = 1e9 + 7;
const long long INF = 1e18;
vector<int> g[N], gr[N];
int n, m, col[N], ans;
bool wt[N], wb[N], was[N];
void first(int v) {
  if (col[v] == 2) return;
  if (col[v] == 1) {
    printf("-1");
    exit(0);
  }
  col[v] = 1;
  for (auto to : g[v]) first(to);
  col[v] = 2;
}
void ft(int v) {
  if (wt[v]) return;
  wt[v] = 1;
  for (auto to : g[v]) ft(to);
}
void fb(int v) {
  if (wb[v]) return;
  wb[v] = 1;
  for (auto to : gr[v]) fb(to);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int v, u;
    scanf("%d%d", &v, &u);
    v--, u--;
    g[v].push_back(u);
    gr[u].push_back(v);
  }
  for (int i = 0; i < n; i++)
    if (col[i] == 0) first(i);
  for (int i = 0; i < n; i++) {
    if (!wt[i] && !wb[i]) {
      ans++;
      was[i] = 1;
    }
    ft(i);
    fb(i);
  }
  printf("%d\n", ans);
  for (int i = 0; i < n; i++) printf("%c", (was[i] ? 'A' : 'E'));
}
