#include <bits/stdc++.h>
using namespace std;
vector<int> num;
vector<int> used;
vector<bool> ans;
int dfs(vector<vector<int>> &g, int v, int mn) {
  if (used[v] == 2) return num[v];
  if (used[v] == 1) return -1;
  used[v] = 1;
  ans[v] = ans[v] || mn < v;
  for (auto i : g[v]) {
    num[v] = min(num[v], dfs(g, i, min(v, mn)));
  }
  ans[v] = ans[v] || num[v] < v;
  used[v] = 2;
  return num[v];
}
int main() {
  int n, m;
  cin >> n >> m;
  num.resize(n);
  ans.resize(n, 0);
  for (int i = 0; i < n; i++) num[i] = i;
  used.resize(n, 0);
  vector<vector<int>> g(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[b].push_back(a);
  }
  string ans2 = "";
  int an = 0;
  for (int i = 0; i < n; i++) {
    if (dfs(g, i, i) == -1) {
      cout << "-1\n";
      return 0;
    } else {
      ans2 += (ans[i]) ? "E" : "A";
      an = an + (ans2.back() == 'A' ? 1 : 0);
    }
  }
  cout << an << "\n";
  cout << ans2;
  return 0;
}
