#include <bits/stdc++.h>
using namespace std;
vector<int> adj[220000], radj[220000];
;
int ind[220000], rind[220000];
int dp[220000], rdp[220000];
bool visited[220000];
bool done[220000];
bool acycled = 1;
void dfs(int nd) {
  visited[nd] = 1;
  for (int nxt : adj[nd]) {
    if (done[nxt]) continue;
    if (visited[nxt]) {
      acycled = 0;
      continue;
    }
    dfs(nxt);
  }
  done[nd] = 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    radj[b].push_back(a);
    ind[b]++;
    rind[a]++;
  }
  for (int i = 1; i <= N; i++)
    if (!visited[i]) dfs(i);
  if (!acycled) {
    cout << -1 << '\n';
    return 0;
  }
  queue<int> q;
  fill(dp, dp + N + 1, 1e9);
  for (int i = 1; i <= N; i++)
    if (ind[i] == 0) q.push(i);
  while (q.size()) {
    int cur = q.front();
    q.pop();
    for (int nxt : adj[cur]) {
      dp[nxt] = min(dp[nxt], min(dp[cur], cur));
      if (--ind[nxt] == 0) q.push(nxt);
    }
  }
  queue<int> rq;
  fill(rdp, rdp + N + 1, 1e9);
  for (int i = 1; i <= N; i++)
    if (rind[i] == 0) rq.push(i);
  while (rq.size()) {
    int cur = rq.front();
    rq.pop();
    for (int nxt : radj[cur]) {
      rdp[nxt] = min(rdp[nxt], min(rdp[cur], cur));
      if (--rind[nxt] == 0) rq.push(nxt);
    }
  }
  string ans = "";
  int cnt = 0;
  for (int i = 1; i <= N; i++) {
    if (dp[i] < i || rdp[i] < i)
      ans += "E";
    else
      ans += "A", cnt++;
  }
  cout << cnt << '\n';
  cout << ans << '\n';
  return 0;
}
