#include <bits/stdc++.h>
using namespace std;
vector<int> adj[200005][2], ts;
int col[200005], dp[200005][2];
void dfs(int u) {
  col[u] = 1;
  for (int v : adj[u][0]) {
    if (col[v] == 1) {
      cout << -1 << '\n';
      exit(0);
    } else if (col[v] == 0)
      dfs(v);
  }
  ts.push_back(u);
  col[u] = 2;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  while (m--) {
    int u, v;
    cin >> u >> v;
    adj[u][0].push_back(v);
    adj[v][1].push_back(u);
  }
  for (int i = (1); (i <= (n)); ++i) {
    dp[i][0] = dp[i][1] = i;
    if (col[i] == 0) dfs(i);
  }
  for (int j = (0); (j <= (1)); ++j) {
    reverse(ts.begin(), ts.end());
    for (int u : ts) {
      for (int v : adj[u][j]) {
        dp[v][j] = min(dp[v][j], dp[u][j]);
      }
    }
  }
  int ans = 0;
  for (int i = (1); (i <= (n)); ++i) ans += (dp[i][0] == i && dp[i][1] == i);
  cout << ans << '\n';
  for (int i = (1); (i <= (n)); ++i) {
    if (dp[i][0] == i && dp[i][1] == i)
      cout << 'A';
    else
      cout << 'E';
  }
  cout << '\n';
}
