#include <bits/stdc++.h>
using namespace std;
long long mod = 998244353;
long long fast_exp(long long a, long long b) {
  if (b <= 0)
    return 1;
  else {
    long long res = 1;
    res = fast_exp(a, b / 2);
    res = (res * res) % mod;
    if (b % 2 == 1) res = (res * a) % mod;
    return res;
  }
}
const long long N = 2e5 + 1;
vector<int> g[N], g_rev[N];
int vis[N], vrev[N];
int cur;
void dfs1(int v) {
  vis[v] = min(cur, vis[v]);
  for (auto e : g[v])
    if (vis[e] == 1e9) dfs1(e);
}
void dfs2(int v) {
  vrev[v] = min(cur, vrev[v]);
  for (auto e : g_rev[v])
    if (vrev[e] == 1e9) dfs2(e);
}
int visited[N] = {};
int cycle = 0;
void cycle_detect(int v) {
  visited[v] = 1;
  for (auto e : g[v]) {
    if (visited[e] == 0) cycle_detect(e);
    if (visited[e] == 1) cycle = 1;
  }
  visited[v] = 2;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int u, v;
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    g[u].push_back(v);
    g_rev[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    vis[i] = 1e9, vrev[i] = 1e9;
    if (visited[i] == 0) cycle_detect(i);
  }
  if (cycle == 0) {
    for (int i = 1; i <= n; i++) {
      if (vis[i] == 1e9) {
        cur = i;
        dfs1(i);
      }
    }
    for (int i = 1; i <= n; i++) {
      if (vrev[i] == 1e9) {
        cur = i;
        dfs2(i);
      }
    }
  }
  string ans;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (min(vis[i], vrev[i]) == i) {
      ans += 'A';
      cnt++;
    } else
      ans += 'E';
  }
  if (cycle == 0)
    cout << cnt << '\n' << ans << '\n';
  else
    cout << -1 << '\n';
  return 0;
}
