#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> g, tg;
vector<int> color;
vector<bool> used1, used2;
void dfs(int v) {
  color[v] = 1;
  for (auto to : g[v]) {
    if (color[to] == 1) {
      cout << -1 << "\n";
      exit(0);
    } else if (color[to] != 2) {
      dfs(to);
    }
  }
  color[v] = 2;
}
void dfs1(int v) {
  used1[v] = true;
  for (auto to : g[v]) {
    if (!used1[to]) dfs1(to);
  }
}
void dfs2(int v) {
  used2[v] = true;
  for (auto to : tg[v]) {
    if (!used2[to]) dfs2(to);
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  g = vector<vector<int>>(n + 1);
  tg = vector<vector<int>>(n + 1);
  used1 = vector<bool>(n + 1, 0);
  used2 = vector<bool>(n + 1, 0);
  color = vector<int>(n + 1);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    tg[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    if (!color[i]) dfs(i);
  }
  vector<char> ans(n + 1, 'E');
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (!used1[i] && !used2[i]) {
      ans[i] = 'A';
      cnt++;
    }
    dfs1(i);
    dfs2(i);
  }
  cout << cnt << "\n";
  for (int i = 1; i <= n; i++) {
    cout << ans[i];
  }
  cout << "\n";
  return 0;
}
