#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
class DebugStream {
} LOG;
template <typename T>
DebugStream &operator<<(DebugStream &s, const T &) {
  return s;
}
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int maxN = 2e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20,
          bs = 29;
vector<int> adj[maxN], rev[maxN];
int n, m;
bool one[maxN], two[maxN], stc[maxN];
void dfs(bool vi[maxN], vector<int> adj[maxN], int nd) {
  vi[nd] = stc[nd] = 1;
  for (auto sn : adj[nd]) {
    if (stc[sn]) {
      cout << "-1\n";
      exit(0);
    }
    if (!vi[sn]) dfs(vi, adj, sn);
  }
  stc[nd] = 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0, u, v; i < m; i++) {
    cin >> u >> v;
    u--, v--;
    adj[u].push_back(v);
    rev[v].push_back(u);
  }
  int ans = 0;
  string str = "";
  for (int i = 0; i < n; i++) {
    if (!one[i] && !two[i])
      str += 'A', ans++;
    else
      str += 'E';
    if (!one[i]) dfs(one, adj, i);
    if (!two[i]) dfs(two, rev, i);
  }
  cout << ans << "\n" << str << '\n';
}
