#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
int dfs(vector<vector<int> >& adj, vector<int>& vis, int u) {
  if (vis[u] != INF) return vis[u];
  vis[u] = u;
  for (int v : adj[u]) {
    int t = dfs(adj, vis, v);
    vis[u] = min(vis[u], t);
  }
  return vis[u];
}
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  vector<vector<int> > adj(N);
  for (int j = 0, _n = (M); j < _n; ++j) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    adj[u].push_back(v);
  }
  int nedges = 0;
  vector<int> in_deg(N);
  for (int u = 0; u < N; ++u) {
    for (int v : adj[u]) {
      ++in_deg[v];
      ++nedges;
    }
  }
  queue<int> q;
  for (int u = 0; u < N; ++u) {
    if (in_deg[u] == 0) q.push(u);
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int v : adj[u]) {
      if (--in_deg[v] == 0) q.push(v);
      --nedges;
    }
  }
  if (nedges > 0) {
    cout << -1 << '\n';
  } else {
    vector<int> vis(N, INF);
    int res = 0;
    string S(N, 'E');
    for (int u = 0, _n = (N); u < _n; ++u) {
      if (vis[u] != INF) continue;
      int t = dfs(adj, vis, u);
      ;
      if (t == u) {
        ++res;
        S[u] = 'A';
      }
    }
    cout << res << endl;
    cout << S << endl;
  }
  return 0;
}
