#include <bits/stdc++.h>
using namespace std;
vector<long long> g[200005];
vector<long long> h[200005];
long long vis[200005] = {0};
long long rec[200005] = {0};
long long ans[200005] = {0};
long long f = 1;
void dfs1(long long x) {
  vis[x] = 2;
  rec[x] = 1;
  for (auto y : g[x]) {
    if (vis[y] == 0) {
      dfs1(y);
    } else if (rec[y] == 1)
      f = 0;
  }
  rec[x] = 0;
}
void dfs2(long long x) {
  vis[x] = 1;
  for (auto y : h[x]) {
    if (vis[y] == 0) {
      dfs2(y);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  long long m, n, i, j, k;
  cin >> n >> m;
  long long x, y;
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    g[y].push_back(x);
    h[x].push_back(y);
  }
  for (i = 1; i < n + 1; i++) {
    if (vis[i] == 0) {
      dfs1(i);
      ans[i]++;
    }
  }
  for (i = 1; i < n + 1; i++) {
    vis[i] = 0;
  }
  for (i = 1; i < n + 1; i++) {
    if (vis[i] == 0) {
      dfs2(i);
      ans[i]++;
    }
  }
  if (f == 0)
    cout << -1;
  else {
    string s = "";
    k = 0;
    for (i = 1; i < n + 1; i++) {
      if (ans[i] == 2) {
        k++;
        s += 'A';
      } else
        s += 'E';
    }
    cout << k << "\n";
    cout << s;
  }
  return 0;
}
