#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int vis[N] = {0}, vis1[N] = {0}, visa[N] = {0}, visb[N] = {0};
char c[N];
vector<int> a[N], b[N];
bool dfsa(int i, int k) {
  if (visa[i]) return false;
  if (vis1[i]) return true;
  vis[i] = vis1[i] = 1;
  for (int j = 0; j < a[i].size(); j++) {
    if (a[i][j] >= k) {
      if (dfsa(a[i][j], k)) return true;
    }
  }
  vis1[i] = 0;
  visa[i] = 1;
  return false;
}
bool dfsb(int i, int k) {
  if (visb[i]) return false;
  if (vis1[i]) return true;
  vis[i] = vis1[i] = 1;
  for (int j = 0; j < b[i].size(); j++) {
    if (b[i][j] >= k) {
      if (dfsb(b[i][j], k)) return true;
    }
  }
  vis1[i] = 0;
  visb[i] = 1;
  return false;
}
int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int j, k;
    cin >> j >> k;
    a[j].push_back(k);
    b[k].push_back(j);
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i]) {
      c[i] = 'E';
    } else {
      c[i] = 'A';
      ans++;
    }
    if (dfsa(i, i)) {
      cout << "-1" << endl;
      return 0;
    }
    if (dfsb(i, i)) {
      cout << "-1" << endl;
      return 0;
    }
  }
  c[n + 1] = 0;
  cout << ans << endl;
  cout << c + 1 << endl;
  return 0;
}
