#include <bits/stdc++.h>
using namespace std;
const int N = 2E5 + 10;
vector<int> e[N], E[N];
int n, m, in[N];
queue<int> q;
bool tp() {
  int cnt = 0;
  for (int i = 1; i <= n; i++)
    if (in[i] == 0) q.push(i);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    cnt++;
    for (auto v : e[u]) {
      in[v]--;
      if (in[v] == 0) q.push(v);
    }
  }
  if (cnt == n) return true;
  return false;
}
int ANS[N];
bool vis1[N], vis2[N];
void dfs1(int u) {
  vis1[u] = 1;
  for (auto v : e[u]) {
    if (vis1[v]) continue;
    dfs1(v);
  }
}
void dfs2(int u) {
  vis2[u] = 1;
  for (auto v : E[u]) {
    if (vis2[v]) continue;
    dfs2(v);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    e[u].push_back(v);
    E[v].push_back(u);
    in[v]++;
  }
  if (!tp()) cout << "-1", exit(0);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!vis1[i] && !vis2[i]) {
      ans++;
      ANS[i] = 1;
    }
    if (!vis1[i]) dfs1(i);
    if (!vis2[i]) dfs2(i);
  }
  cout << ans << '\n';
  for (int i = 1; i <= n; i++)
    if (ANS[i])
      cout << 'A';
    else
      cout << 'E';
}
