#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 5;
int n, m;
vector<int> g[N], rg[N];
int in[N], mn[N], t[N], ans[N];
bool vis[2][N];
void dfs(int u, vector<int> g[], int id) {
  vis[id][u] = true;
  for (auto v : g[u]) {
    if (vis[id][v]) continue;
    ans[v] = 0;
    dfs(v, g, id);
  }
}
bool tp() {
  queue<int> q;
  int cnt = 0;
  for (int i = (1); i < (n + 1); i++)
    if (!in[i]) q.push(i);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    cnt++;
    for (auto v : g[u]) {
      in[v]--;
      if (!in[v]) q.push(v);
    }
  }
  return (cnt == n);
}
vector<int> p[N];
int main() {
  cin >> n >> m;
  int u, v;
  for (int i = (1); i < (m + 1); i++) {
    cin >> u >> v;
    g[u].push_back(v);
    in[v]++;
    t[v]++;
    rg[v].push_back(u);
  }
  if (!tp()) {
    cout << -1;
    return 0;
  }
  int cnt = 0;
  for (int i = (1); i < (n + 1); i++) {
    if (!vis[0][i] && !vis[1][i]) {
      cnt++;
      ans[i] = 1;
    }
    if (!vis[0][i]) dfs(i, g, 0);
    if (!vis[1][i]) dfs(i, rg, 1);
  }
  cout << cnt << "\n";
  for (int i = (1); i < (n + 1); i++)
    if (ans[i])
      cout << "A";
    else
      cout << "E";
  return 0;
}
