#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<long long>;
template <class T>
using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T>
istream &operator>>(istream &, vector<T> &);
template <class T>
ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U>
istream &operator>>(istream &, pair<T, U> &);
template <class T, class U>
ostream &operator<<(ostream &, const pair<T, U> &);
template <class T>
struct Inf {
  static constexpr T inf() {
    return std::numeric_limits<T>::has_infinity
               ? std::numeric_limits<T>::infinity()
               : std::numeric_limits<T>::max();
  }
};
template <>
struct Inf<int> {
  static constexpr int inf() { return 0x3f3f3f3f; }
};
template <>
struct Inf<long long> {
  static constexpr long long inf() { return 0x3f3f3f3f3f3f3f3fLL; }
};
constexpr int INF = Inf<int>::inf();
constexpr ll BINF = Inf<ll>::inf();
int solve() {
  int n, m;
  cin >> n >> m;
  vvi g(n), gr(n);
  vi ind(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    g[u].push_back(v);
    gr[v].push_back(u);
    ind[v]++;
  }
  int popped = 0;
  queue<int> q;
  for (int i = 0; i < n; i++)
    if (ind[i] == 0) q.push(i);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    popped++;
    for (int v : g[u]) {
      ind[v]--;
      if (ind[v] == 0) q.push(v);
    }
  }
  if (popped != n) return cout << -1 << endl, 0;
  vi ans(n, -1);
  vi up(n), down(n);
  function<void(int)> progup = [&](int u) {
    if (up[u]) return;
    up[u] = 1;
    for (int v : gr[u]) {
      if (ans[v] == -1) ans[v] = 1;
      progup(v);
    }
  };
  function<void(int)> progdown = [&](int u) {
    if (down[u]) return;
    down[u] = 1;
    for (int v : g[u]) {
      if (ans[v] == -1) ans[v] = 1;
      progdown(v);
    }
  };
  for (int i = 0; i < n; i++) {
    if (ans[i] == -1) {
      ans[i] = 0;
    }
    progup(i);
    progdown(i);
  }
  cout << n - accumulate(ans.begin(), ans.end(), 0) << endl;
  for (int c : ans) cout << "AE"[c];
  cout << endl;
  return 0;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
template <class T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto it = v.begin(); it != v.end(); ++it) is >> *it;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (auto it = v.begin(); it != v.end();)
    os << *it, os << " \n"[++it == v.end()];
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  return is >> p.first >> p.second;
}
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  return os << p.first << ' ' << p.second;
}
