#include <bits/stdc++.h>
using namespace std;
int n, m;
unordered_map<int, vector<int>> E1, E2;
vector<bool> ivs, ovs;
bool dfs(int x) {
  if (ivs[x] && !ovs[x]) return true;
  if (ovs[x]) return false;
  ivs[x] = true;
  for (auto nx : E1[x])
    if (dfs(nx)) return true;
  ovs[x] = true;
  return false;
}
vector<int> dp1, dp2;
int dfs1(int x) {
  if (dp1[x] != -1) return dp1[x];
  dp1[x] = x;
  for (auto &nx : E1[x]) {
    dp1[x] = min(dp1[x], dfs1(nx));
  }
  return dp1[x];
}
int dfs2(int x) {
  if (dp2[x] != -1) return dp2[x];
  dp2[x] = x;
  for (auto &nx : E2[x]) {
    dp2[x] = min(dp2[x], dfs2(nx));
  }
  return dp2[x];
}
int main() {
  cin >> n >> m;
  ivs.resize(n, false);
  ovs.resize(n, false);
  dp1.resize(n, -1);
  dp2.resize(n, -1);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    E1[u].push_back(v);
    E2[v].push_back(u);
  }
  int cnt = 0;
  string sol = "";
  for (int i = 0; i < n; i++) {
    if (!ovs[i] && dfs(i)) {
      cout << -1 << endl;
      return 0;
    }
    int mini = min(dfs1(i), dfs2(i));
    if (mini == i) {
      cnt++;
      sol += "A";
    } else {
      sol += "E";
    }
  }
  cout << cnt << endl << sol << endl;
}
