#include <bits/stdc++.h>
using namespace std;
vector<int> g[2][200200];
int _was[2][200200];
int ans[200200];
bool dfsX(int i, int k) {
  if (_was[k][i] == 1) {
    return false;
  }
  if (_was[k][i] == 2) {
    return true;
  }
  _was[k][i] = 1;
  for (auto u : g[k][i]) {
    if (!dfsX(u, k)) {
      return false;
    }
  }
  _was[k][i] = 2;
  return true;
}
int main() {
  int n;
  scanf("%d", &n);
  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--;
    y--;
    g[0][x].push_back(y);
    g[1][y].push_back(x);
  }
  int nA = 0;
  for (int i = 0; i < n; ++i) {
    if (_was[0][i] == 0 && _was[1][i] == 0) {
      ans[i] = 1;
      nA++;
    } else {
      ans[i] = 0;
    }
    for (int k = 0; k < 2; ++k) {
      if (_was[k][i] > 0) {
        continue;
      }
      if (!dfsX(i, k)) {
        printf("-1\n");
        return 0;
      }
    }
  }
  printf("%d\n", nA);
  for (int i = 0; i < n; ++i) {
    printf(ans[i] == 1 ? "A" : "E");
  }
  printf("\n");
  return 0;
}
