#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> f(n);
  vector<vector<int>> b(n);
  for (int i = 0; i < m; i++) {
    int j, k;
    cin >> j >> k;
    j--;
    k--;
    f[j].push_back(k);
    b[k].push_back(j);
  }
  bool ok = true;
  vector<bool> inpath(n);
  vector<bool> fvis(n);
  vector<int> fmin(n);
  function<void(int)> fdfs = [&](int v) {
    fvis[v] = true;
    inpath[v] = true;
    fmin[v] = v;
    for (int w : f[v]) {
      if (inpath[w]) ok = false;
      if (!ok) break;
      if (!fvis[w]) {
        fdfs(w);
      }
      fmin[v] = min(fmin[v], fmin[w]);
    }
    inpath[v] = false;
  };
  for (int i = 0; i < n && ok; i++) {
    if (!fvis[i]) fdfs(i);
  }
  if (!ok) {
    cout << -1 << endl;
    return 0;
  }
  vector<bool> bvis(n);
  vector<int> bmin(n);
  function<void(int)> bdfs = [&](int v) {
    bvis[v] = true;
    inpath[v] = true;
    bmin[v] = v;
    for (int w : b[v]) {
      if (inpath[w]) ok = false;
      if (!ok) break;
      if (!bvis[w]) {
        bdfs(w);
      }
      bmin[v] = min(bmin[v], bmin[w]);
    }
    inpath[v] = false;
  };
  for (int i = 0; i < n && ok; i++) {
    if (!bvis[i]) bdfs(i);
  }
  int cnt = 0;
  string res(n, ' ');
  for (int i = 0; i < n; i++) {
    bool isA = (bmin[i] == i) && (fmin[i] == i);
    res[i] = "EA"[isA];
    cnt += isA;
  }
  cout << cnt << endl;
  cout << res << endl;
  return 0;
}
