#include <bits/stdc++.h>
using namespace std;
int n, m;
const int N = 2e5 + 10;
int in_deg[N], out_deg[N];
bool vis[N], rvis[N];
vector<int> G[N], rG[N];
int temp[N];
bool check() {
  memcpy(temp, in_deg, sizeof(in_deg));
  queue<int> q;
  int o = n;
  for (int i = 1; i <= n; i++) {
    if (temp[i] == 0) q.push(i), o--;
  }
  while (!q.empty()) {
    int r = q.front();
    q.pop();
    for (auto v : G[r]) {
      temp[v]--;
      if (temp[v] == 0) {
        q.push(v), o--;
      }
    }
  }
  return o;
}
void dfs(vector<int> G[], int x, bool vis[]) {
  vis[x] = 1;
  for (auto y : G[x]) {
    if (!vis[y]) {
      dfs(G, y, vis);
    }
  }
}
int main() {
  set<int> S;
  scanf("%d%d", &n, &m);
  for (int i = 0, u, v; i < m; i++) {
    scanf("%d%d", &u, &v);
    G[v].push_back(u);
    rG[u].push_back(v);
    in_deg[u]++;
    out_deg[v]++;
  }
  if (check()) {
    puts("-1");
    return 0;
  }
  int cnt = 0;
  string ans;
  for (int i = 1; i <= n; i++) {
    if (vis[i] || rvis[i]) {
      ans += 'E';
    } else {
      ans += 'A';
      cnt++;
    }
    dfs(G, i, vis);
    dfs(rG, i, rvis);
  }
  printf("%d\n%s\n", cnt, ans.c_str());
  return 0;
}
