#include <bits/stdc++.h>
using namespace std;
vector<int> v1[200009], v2[200009];
int vis1[200009], vis2[200009];
bool dfs1(int x) {
  vis1[x] = -1;
  for (auto it : v1[x]) {
    if (vis1[it] < 0) {
      return 0;
    } else {
      if (!vis1[it] && !dfs1(it)) {
        return 0;
      }
    }
  }
  vis1[x] = 1;
  return 1;
}
bool dfs2(int x) {
  vis2[x] = -1;
  for (auto it : v2[x]) {
    if (vis2[it] < 0) {
      return 0;
    } else {
      if (!vis2[it] && !dfs2(it)) {
        return 0;
      }
    }
  }
  vis2[x] = 1;
  return 1;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    v1[u].push_back(v);
    v2[v].push_back(u);
  }
  string ans;
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    if (!vis1[i] && !vis2[i]) {
      ans += 'A';
      cnt++;
    } else {
      ans += 'E';
    }
    if (!dfs1(i) || !dfs2(i)) {
      puts("-1");
      return 0;
    }
  }
  cout << cnt << "\n" << ans << "\n";
  return 0;
}
