#include <bits/stdc++.h>
using namespace std;
int n, m, k;
vector<vector<int> > g;
vector<int> u, ord, t, x, y;
string s;
void dfs(int v) {
  u[v] = 1;
  for (auto to : g[v])
    if (!u[to]) dfs(to);
  ord.push_back(v);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  g.resize(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    g[a].push_back(b);
  }
  u.assign(n, 0);
  for (int i = 0; i < n; ++i)
    if (!u[i]) dfs(i);
  reverse(ord.begin(), ord.end());
  t.resize(n);
  for (int i = 0; i < n; ++i) t[ord[i]] = i;
  for (int v = 0; v < n; ++v) {
    for (int to : g[v]) {
      if (t[v] > t[to]) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  x = y = vector<int>(n);
  for (int i = 0; i < n; ++i) x[i] = y[i] = i;
  for (auto v : ord)
    for (auto to : g[v]) x[to] = min(x[to], x[v]);
  reverse(ord.begin(), ord.end());
  for (auto v : ord)
    for (auto to : g[v]) y[v] = min(y[v], y[to]);
  for (int i = 0; i < n; ++i) {
    if (x[i] == i && y[i] == i)
      s += 'A', ++k;
    else
      s += 'E';
  }
  cout << k << endl;
  cout << s << endl;
  return 0;
}
