#include <bits/stdc++.h>
using namespace std;
const int MX = 2e5 + 5;
vector<int> adj[MX], rev_adj[MX];
int chk[MX], universal[MX], fdp[MX], bdp[MX], cur[MX];
bool cycle(int node) {
  chk[node] = 1;
  cur[node] = 1;
  int flag = 0;
  for (auto x : adj[node]) {
    if (!chk[x])
      flag = flag | cycle(x);
    else if (cur[x])
      flag = 1;
  }
  cur[node] = 0;
  return flag;
}
int forward_dp(int node) {
  int &r = fdp[node];
  if (r) return r;
  r = node;
  for (auto x : adj[node]) r = min(r, forward_dp(x));
  return r;
}
int backward_dp(int node) {
  int &r = bdp[node];
  if (r) return r;
  r = node;
  for (auto x : rev_adj[node]) r = min(r, backward_dp(x));
  return r;
}
int main() {
  int i, j, k;
  int n, m;
  cin >> n >> m;
  for (i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    rev_adj[v].push_back(u);
  }
  string ans = "";
  int cnt = 0;
  for (i = 1; i <= n; ++i) {
    if (!chk[i] && cycle(i)) return puts("-1");
    if (forward_dp(i) < i || backward_dp(i) < i)
      ans += "E";
    else
      ans += "A", cnt++;
  }
  cout << cnt << endl << ans << endl;
}
