#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long mx = 2e5 + 4;
long long n, m;
vector<long long> adj[mx];
vector<long long> adj_rev[mx];
long long visited[mx], in_deg[mx], out_deg[mx];
long long fl = 0;
long long up[mx], down[mx];
long long expo_pow(long long x, long long y) {
  if (y == 0) return 1;
  y = y % (mod - 1);
  x %= mod;
  if (y == 0) y = mod - 1;
  long long res = 1;
  while (y) {
    if (y & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    y >>= 1;
  }
  return res;
}
void dfs(long long cur) {
  visited[cur] = 1;
  for (auto u : adj[cur]) {
    if (visited[u] == 1) {
      fl = 1;
    } else if (visited[u] == 0) {
      dfs(u);
    }
  }
  visited[cur] = 2;
}
long long dfs1(long long cur) {
  if (up[cur] != 0) return up[cur];
  up[cur] = cur;
  for (auto u : adj_rev[cur]) {
    up[cur] = min(up[cur], dfs1(u));
  }
  return up[cur];
}
long long dfs2(long long cur) {
  if (down[cur] != 0) return down[cur];
  down[cur] = cur;
  for (auto u : adj[cur]) {
    down[cur] = min(down[cur], dfs2(u));
  }
  return down[cur];
}
void solve() {
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long p, q;
    cin >> p >> q;
    adj[q].push_back(p);
    adj_rev[p].push_back(q);
    in_deg[p]++;
    out_deg[q]++;
  }
  for (long long i = 1; i <= n; i++) {
    if (visited[i] == 0) {
      dfs(i);
      if (fl == 1) {
        cout << "-1\n";
        return;
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    if (up[i] == 0) dfs1(i);
  }
  for (long long i = 1; i <= n; i++) {
    if (down[i] == 0) dfs2(i);
  }
  long long cnt = 0;
  for (long long i = 1; i <= n; i++) {
    if (up[i] == i and down[i] == i) cnt++;
  }
  cout << cnt << "\n";
  for (long long i = 1; i <= n; i++) {
    if (up[i] == i and down[i] == i)
      cout << "A";
    else
      cout << "E";
  }
  cout << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long test = 1;
  long long i = 1;
  while (test--) {
    solve();
  }
}
