#include <bits/stdc++.h>
using namespace std;
inline void prep() {
  cin.tie(0);
  cin.sync_with_stdio(0);
};
const double pi = acos(-1.);
long long mod = 998244353;
long long mymod(long long num) {
  if (num < 0 && !(num % mod == 0)) {
    if (mod == 1) {
      return 0;
    }
    return mod - abs(num) % mod;
  } else {
    return num % mod;
  }
}
const int biggg = 2000000000;
const long long bigggest = 1000000000000000000LL;
const double eps = .0000000001;
vector<int> graph[2][200001];
bool res[200001];
bool active[200001];
int subtrees[2][200001];
bool vis[2][200001];
int acnt = 0;
int func(int node, int w) {
  if (active[node]) {
    cout << "-1";
    exit(0);
  }
  if (vis[w][node]) return min(node, subtrees[w][node]);
  vis[w][node] = true;
  int mymin = biggg;
  active[node] = true;
  for (int i : graph[w][node]) {
    mymin = min(mymin, func(i, w));
  }
  active[node] = false;
  subtrees[w][node] = mymin;
  return min(node, mymin);
}
int main() {
  prep();
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    graph[0][a].push_back(b);
    graph[1][b].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    func(i, 0);
    func(i, 1);
  }
  for (int i = 1; i <= n; i++) {
    if (subtrees[0][i] > i && subtrees[1][i] > i) {
      res[i] = true;
      acnt++;
    }
  }
  cout << acnt << '\n';
  for (int i = 0; i < n; i++)
    if (res[i + 1])
      cout << 'A';
    else
      cout << 'E';
  return 0;
}
