#include <bits/stdc++.h>
using namespace std;
int cnt = 0;
int head[200005], nxt[200005], to[200005];
int head2[200005], nxt2[200005], to2[200005];
bool checked[200005] = {0}, ondfs[200005] = {0};
int dp1[200005] = {0}, dp2[200005] = {0};
bool dfs(int no) {
  if (ondfs[no] == 1) return false;
  if (checked[no] == 1) return true;
  checked[no] = 1;
  int flag = 0;
  for (int i = head[no]; i != -1; i = nxt[i]) {
    ondfs[no] = 1;
    int b = to[i];
    if (!dfs(b)) flag = 1;
    ondfs[no] = 0;
  }
  if (flag == 1)
    return false;
  else
    return true;
}
int dfs1(int no) {
  if (dp1[no] != 0) {
    return dp1[no];
  }
  dp1[no] = no;
  for (int i = head[no]; i != -1; i = nxt[i]) {
    dp1[no] = min(dp1[no], dfs1(to[i]));
  }
  return dp1[no];
}
int dfs2(int no) {
  if (dp2[no] != 0) {
    return dp2[no];
  }
  dp2[no] = no;
  for (int i = head2[no]; i != -1; i = nxt2[i]) {
    dp2[no] = min(dp2[no], dfs2(to2[i]));
  }
  return dp2[no];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  memset(head, -1, sizeof(head));
  memset(head2, -1, sizeof(head2));
  int n, m;
  cin >> n >> m;
  int a, b;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    nxt[cnt] = head[a];
    to[cnt] = b;
    head[a] = cnt;
    nxt2[cnt] = head2[b];
    to2[cnt] = a;
    head2[b] = cnt;
    cnt++;
  }
  int ans = 0;
  bool flag = 0;
  for (int i = 1; i <= n; i++) {
    if (!checked[i]) {
      if (flag == 0 && !dfs(i)) flag = 1;
    }
  }
  if (flag == 1) {
    cout << -1;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    dfs1(i);
    dfs2(i);
  }
  for (int i = 1; i <= n; i++) {
    dp1[i] = min(dp1[i], dp2[i]);
    if (dp1[i] >= i) ans++;
  }
  cout << ans << endl;
  for (int i = 1; i <= n; i++) {
    if (dp1[i] < i) {
      cout << 'E';
    } else
      cout << 'A';
  }
  return 0;
}
