#include <bits/stdc++.h>
using namespace std;
int top(vector<vector<int>> &e) {
  int n = e.size();
  vector<int> ing(n), seen(n);
  queue<int> q;
  for (auto s : e) {
    for (auto v : s) {
      ing[v]++;
    }
  }
  for (int i = 0; i < n; i++)
    if (ing[i] == 0) q.push(i);
  while (!q.empty()) {
    int c = q.front();
    q.pop();
    seen[c] = 1;
    for (int v : e[c]) {
      ing[v]--;
      if (ing[v] == 0) q.push(v);
    }
  }
  for (int i = 0; i < n; i++)
    if (seen[i] == 0) return 0;
  return 1;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> as(n);
  vector<vector<int>> e(n), be(n);
  for (int i = 0; i < m; i++) {
    int j, k;
    cin >> j >> k;
    j--, k--;
    e[j].push_back(k);
    be[k].push_back(j);
  }
  if (!top(e)) {
    cout << -1 << endl;
    return 0;
  }
  vector<int> sf(n), sb(n);
  for (int i = 0; i < n; i++) {
    if (as[i] == 0) as[i] = 1;
    queue<int> q;
    q.push(i);
    sf[i] = sb[i] = 1;
    while (!q.empty()) {
      int cur = q.front();
      q.pop();
      for (int v : e[cur]) {
        if (sf[v]) continue;
        sf[v] = 1;
        q.push(v);
        as[v] = 2;
      }
    }
    q = queue<int>();
    q.push(i);
    while (!q.empty()) {
      int cur = q.front();
      q.pop();
      for (int v : be[cur]) {
        if (sb[v]) continue;
        sb[v] = 1;
        q.push(v);
        as[v] = 2;
      }
    }
  }
  int cnt = 0;
  string s;
  for (int k : as) {
    if (k == 1)
      cnt++, s += "A";
    else
      s += "E";
  }
  cout << cnt << endl << s << endl;
}
