#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const int N = 200005;
int vis[N], tab[N], i, a, b, sum, n, m, vis0[N], vis1[N];
vector<int> graf0[N], graf1[N];
string s;
bool cyc(int w) {
  vis[w] = 1;
  for (auto& w2 : graf0[w])
    if (vis[w2] == 1)
      return true;
    else if (vis[w2] == 0 && cyc(w2))
      return true;
  vis[w] = 2;
  return false;
}
void go(int w, vector<int> graf[N], int* vis) {
  tab[w] = 1;
  vis[w] = 1;
  for (auto& w2 : graf[w])
    if (!vis[w2]) go(w2, graf, vis);
}
int main() {
  scanf("%d %d", &n, &m);
  while (m--) {
    scanf("%d %d", &a, &b);
    graf0[a].push_back(b);
    graf1[b].push_back(a);
  }
  for (i = 1; i <= n; i++)
    if (vis[i] == 0 && cyc(i)) {
      printf("-1\n");
      return 0;
    }
  sum = 0;
  for (i = 1; i <= n; i++)
    if (tab[i] == 0) {
      go(i, graf0, vis0);
      go(i, graf1, vis1);
      s += 'A';
      sum++;
    } else {
      s += 'E';
      go(i, graf0, vis0);
      go(i, graf1, vis1);
    }
  printf("%d\n%s\n", sum, s.c_str());
  return 0;
}
