#include <bits/stdc++.h>
using namespace std;
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
const long long mod = 1e9 + 7;
long long power(long long a, long long b, long long m = mod) {
  if (b < 0) {
    return power(power(a, -b), mod - 2);
  }
  long long x = 1;
  while (b) {
    if (b & 1) {
      x = 1ll * x * a % m;
    }
    a = 1ll * a * a % m;
    b /= 2;
  }
  return x;
}
const int N = 2e5 + 9;
vector<int> g[N], gr[N];
vector<int> topo;
void bye() {
  cout << "-1\n";
  exit(0);
}
int col[N];
void dfs(int u) {
  col[u] = 1;
  for (int v : g[u]) {
    if (col[v] == 2) continue;
    if (col[v] == 1) {
      bye();
    }
    dfs(v);
  }
  col[u] = 2;
  topo.push_back(u);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[v].push_back(u);
    gr[u].push_back(v);
  }
  for (int i = 0; i < n; i++) {
    if (col[i] == 0) {
      dfs(i);
    }
  }
  vector<int> f1(n + 2, n + 10), f2(n + 2, n + 10);
  for (int u : topo) {
    f1[u] = u;
    for (int v : g[u]) {
      f1[u] = min(f1[v], f1[u]);
    }
  }
  reverse(topo.begin(), topo.end());
  for (int u : topo) {
    f2[u] = u;
    for (int v : gr[u]) {
      f2[u] = min(f2[v], f2[u]);
    }
  }
  string ans;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (min(f1[i], f2[i]) >= i) {
      ans += 'A';
      cnt++;
    } else
      ans += 'E';
  }
  cout << cnt << endl << ans << endl;
  return 0;
}
