#include <bits/stdc++.h>
using namespace std;
vector<int> a[200002], b[200002];
int n, viz[200002], ok;
bool up[200002], down[200002];
char sol[200002];
void dfs(int x) {
  int i, l = a[x].size();
  viz[x] = 1;
  for (i = 0; i < l; i++) {
    if (viz[a[x][i]] == 1) {
      ok = 0;
      break;
    } else if (viz[a[x][i]] == 0)
      dfs(a[x][i]);
  }
  viz[x] = 2;
}
void cycle() {
  int i;
  for (i = 1; i <= n && ok == 1; i++)
    if (viz[i] == 0) dfs(i);
}
void dfs_jos(int x) {
  int i, l = a[x].size();
  down[x] = 1;
  for (i = 0; i < l; i++) {
    if (down[a[x][i]] == 0) {
      sol[a[x][i]] = 'E';
      dfs_jos(a[x][i]);
    }
  }
}
void dfs_sus(int x) {
  int i, l = b[x].size();
  up[x] = 1;
  for (i = 0; i < l; i++) {
    if (up[b[x][i]] == 0) {
      sol[b[x][i]] = 'E';
      dfs_sus(b[x][i]);
    }
  }
}
int main() {
  int m, i, x, y, k = 0;
  cin >> n >> m;
  for (i = 1; i <= m; i++) {
    cin >> x >> y;
    a[y].push_back(x);
    b[x].push_back(y);
  }
  ok = 1;
  cycle();
  if (ok == 0)
    cout << -1;
  else {
    for (i = 1; i <= n; i++) viz[i] = 0;
    for (i = 1; i <= n; i++) {
      if (up[i] == 0 && down[i] == 0) sol[i] = 'A';
      if (down[i] == 0) dfs_jos(i);
      if (up[i] == 0) dfs_sus(i);
    }
    for (i = 1; i <= n; i++)
      if (sol[i] == 'A') k++;
    cout << k << '\n';
    for (i = 1; i <= n; i++) cout << sol[i];
  }
  return 0;
}
