#include <bits/stdc++.h>
using namespace std;
vector<array<vector<int>, 2>> al;
vector<bitset<2>> b;
vector<bool> stk;
bool impossible = false;
void f(int u, bool d) {
  if (stk[u]) {
    impossible = true;
    return;
  }
  if (b[u][d]) return;
  b[u][d] = true;
  stk[u] = true;
  for (int v : al[u][d]) {
    f(v, d);
  }
  stk[u] = false;
};
void solve() {
  int n, m;
  cin >> n >> m;
  al.resize(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    al[x][0].push_back(y);
    al[y][1].push_back(x);
  }
  vector<bool> ans(n);
  b.resize(n);
  stk.resize(n);
  for (int i = 0; i < n; i++) {
    if (b[i].none()) {
      ans[i] = true;
    }
    f(i, false);
    if (impossible) break;
    f(i, true);
    if (impossible) break;
  }
  if (impossible) {
    cout << "-1\n";
    return;
  }
  cout << count(begin(ans), end(ans), true) << '\n';
  for (int i = 0; i < n; i++) {
    cout << (ans[i] ? 'A' : 'E');
  }
  cout << '\n';
}
int main() {
  solve();
  return 0;
}
