#include <bits/stdc++.h>
using namespace std;
vector<long long int> adj[2][200005];
long long int vis[2][200005];
long long int dfs(long long int dx, long long int node) {
  if (vis[dx][node] == 1) {
    return 0;
  }
  if (vis[dx][node] == 2) {
    return 1;
  }
  vis[dx][node] = 1;
  for (auto it : adj[dx][node]) {
    if (!dfs(dx, it)) {
      return 0;
    }
  }
  vis[dx][node] = 2;
  return 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, m;
  cin >> n >> m;
  for (long long int i = 1; i <= m; i++) {
    long long int u, v;
    cin >> u >> v;
    adj[0][u].push_back(v);
    adj[1][v].push_back(u);
  }
  string s;
  bool flg = 0;
  long long int cnt = 0;
  for (long long int i = 1; i <= n; i++) {
    if (!vis[0][i] && !vis[1][i]) {
      s += "A";
      cnt++;
    } else {
      s += "E";
    }
    bool down = dfs(0, i);
    bool up = dfs(1, i);
    if (!down || !up) {
      flg = 1;
      break;
    }
  }
  if (flg) {
    cout << "-1"
         << "\n";
  } else {
    cout << cnt << "\n";
    cout << s << "\n";
  }
}
