#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, m, vis[N], ans, mark[2][N];
vector<int> go[N], to[N];
string s;
void dfs_ts(int u) {
  vis[u] = 2;
  for (int v : go[u]) {
    if (vis[v] == 2) {
      cout << -1 << endl;
      exit(0);
    }
    if (vis[v] == 0) dfs_ts(v);
  }
  vis[u] = 1;
}
void dfs_go(int u) {
  mark[0][u] = 1;
  for (int v : go[u])
    if (mark[0][v] == 0) dfs_go(v);
}
void dfs_to(int u) {
  mark[1][u] = 1;
  for (int v : to[u])
    if (mark[1][v] == 0) dfs_to(v);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n >> m;
  for (int i = 0, u, v; i < m; i++) {
    cin >> u >> v;
    u--, v--;
    go[u].push_back(v);
    to[v].push_back(u);
  }
  for (int u = 0; u < n; u++)
    if (vis[u] == 0) dfs_ts(u);
  for (int u = 0; u < n; u++) {
    s += (mark[0][u] + mark[1][u] == 0 ? "A" : "E");
    ans += s[u] == 'A';
    dfs_go(u);
    dfs_to(u);
  }
  cout << ans << endl << s << endl;
}
