#include <bits/stdc++.h>
using namespace std;
vector<int> adj[200005];
vector<int> iadj[200005];
map<int, bool> visited;
map<int, bool> ivisited;
void dfs(int a) {
  visited[a] = true;
  for (int i = 0; i < adj[a].size(); i++) {
    int nex = adj[a][i];
    if (!visited[nex]) {
      dfs(nex);
    }
  }
}
void dfs1(int a) {
  ivisited[a] = true;
  for (int i = 0; i < iadj[a].size(); i++) {
    int nex = iadj[a][i];
    if (!ivisited[nex]) {
      dfs1(nex);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int a, b;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    adj[a].push_back(b);
    iadj[b].push_back(a);
  }
  map<int, int> indegre;
  priority_queue<pair<int, int> > q;
  for (int i = 1; i <= n; i++) {
    indegre[i] = iadj[i].size();
    if (indegre[i] == 0) {
      q.push(make_pair(0, i));
    }
  }
  bool ok = true;
  for (int i = 0; i < n; i++) {
    if (q.size() == 0) {
      ok = false;
      break;
    }
    pair<int, int> current = q.top();
    q.pop();
    for (int j = 0; j < adj[current.second].size(); j++) {
      int nex = adj[current.second][j];
      indegre[nex]--;
      if (indegre[nex] == 0) {
        q.push(make_pair(0, nex));
      }
    }
  }
  if (!ok) {
    cout << -1 << '\n';
  } else {
    string result = "";
    int count = 0;
    for (int i = 1; i <= n; i++) {
      if (!visited[i] && !ivisited[i]) {
        result += "A";
        count++;
      } else {
        result += "E";
      }
      if (!visited[i]) dfs(i);
      if (!ivisited[i]) dfs1(i);
    }
    cout << count << '\n';
    cout << result << '\n';
  }
  return 0;
}
