#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, m, deg[N], vis[N];
vector<int> adj[N][2];
bool kt[N][2];
void dfs(int u) {
  vis[u] = 1;
  for (auto& v : adj[u][0]) {
    if (vis[v] == 1) {
      cout << -1;
      exit(0);
    } else if (!vis[v])
      dfs(v);
  }
  vis[u] = 2;
}
void go(int u, int type) {
  kt[u][type] = 1;
  for (auto& v : adj[u][type]) {
    if (!kt[v][type]) go(v, type);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m;
  while (m--) {
    int u, v;
    cin >> u >> v;
    adj[u][0].push_back(v);
    adj[v][1].push_back(u);
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i);
  string res;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (!kt[i][0] && !kt[i][1]) {
      cnt++;
      res += 'A';
    } else
      res += 'E';
    go(i, 0);
    go(i, 1);
  }
  cout << cnt << '\n' << res;
}
