#include <bits/stdc++.h>
using namespace std;
template <typename T>
const T MAX = std::numeric_limits<T>::max();
template <typename T>
const T MIN = std::numeric_limits<T>::min();
template <typename T>
std::ostream& operator<<(std::ostream& out, const std::vector<T>& cont) {
  for (auto a : cont) {
    out << a << " ";
  }
  return out;
}
vector<vector<int> > succ;
vector<int> order;
vector<int> active;
bool top_order(int u, int& i) {
  active[u] = 1;
  for (auto v : succ[u]) {
    if (active[v] == 1) {
      return false;
    }
    if (active[v] != 2 && !top_order(v, i)) {
      return false;
    }
  }
  active[u] = 2;
  order[i--] = u;
  return true;
}
int main(int argc, char** argv) {
  int n, m;
  cin >> n >> m;
  succ.resize(n);
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    succ[x - 1].push_back(y - 1);
  }
  order.resize(n);
  active.resize(n);
  int a = n - 1;
  for (int u = 0; u < n; ++u) {
    if (active[u] == 0) {
      if (!top_order(u, a)) {
        cout << -1 << "\n";
        return 0;
      }
    }
  }
  vector<char> ans(n, 'A');
  vector<int> asc(n, n);
  for (int i = 0; i < n; i++) {
    int u = order[i];
    int b = min(asc[u], u);
    for (auto v : succ[u]) {
      asc[v] = min(b, asc[v]);
    }
  }
  vector<int> dsc(n, n);
  for (int i = n - 1; i >= 0; i--) {
    int u = order[i];
    for (auto v : succ[u]) {
      int x = min(v, dsc[v]);
      dsc[u] = min(x, dsc[u]);
    }
  }
  for (int i = 0; i < n; ++i) {
    if (asc[i] < i || dsc[i] < i) {
      ans[i] = 'E';
    }
  }
  int cnt = 0;
  for (auto c : ans) {
    if (c == 'A') cnt++;
  }
  cout << cnt << "\n";
  for (auto c : ans) {
    cout << c;
  }
  cout << "\n";
}
