#include <bits/stdc++.h>
using namespace std;
vector<int> in[200005];
vector<int> out[200005];
vector<int> topp;
int ntt[200005];
bool visited[200005];
int dp1[200005];
int dp2[200005];
void topo(int node) {
  if (visited[node]) return;
  visited[node] = 1;
  for (int i = 0; i < out[node].size(); i++) {
    topo(out[node][i]);
  }
  topp.push_back(node);
  return;
}
void solve() {
  int n, m;
  cin >> n >> m;
  int u, v;
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    out[u].push_back(v);
    in[v].push_back(u);
  }
  memset(ntt, 0, sizeof(ntt));
  memset(visited, 0, sizeof(visited));
  memset(dp1, 0, sizeof(dp1));
  memset(dp2, 0, sizeof(dp2));
  for (int i = 1; i <= n; i++) topo(i);
  for (int i = n - 1; i >= 0; i--) {
    ntt[topp[i]] = n - i;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < out[i].size(); j++) {
      int u = i, v = out[i][j];
      if (ntt[u] > ntt[v]) {
        cout << -1 << "\n";
        return;
      }
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    int ans = n + 100;
    for (int j = 0; j < in[topp[i]].size(); j++) {
      ans = min(ans, dp1[in[topp[i]][j]]);
      ans = min(ans, in[topp[i]][j]);
    }
    dp1[topp[i]] = ans;
  }
  for (int i = 0; i <= n - 1; i++) {
    int ans = n + 100;
    for (int j = 0; j < out[topp[i]].size(); j++) {
      ans = min(ans, dp2[out[topp[i]][j]]);
      ans = min(ans, out[topp[i]][j]);
    }
    dp2[topp[i]] = ans;
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if ((dp1[i] > i) && (dp2[i] > i)) cnt++;
  }
  cout << cnt << "\n";
  for (int i = 1; i <= n; i++) {
    if ((dp1[i] > i) && (dp2[i] > i))
      cout << 'A';
    else
      cout << 'E';
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  while (t--) {
    solve();
  }
}
