#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> graph(200005), revGraph(200005);
vector<int> vis(200005, 0), revVis(200005, 0);
bool dfs(int u, vector<vector<int>> &curGraph, vector<int> &curVis) {
  curVis[u] = -1;
  for (auto v : curGraph[u]) {
    if (curVis[v] == -1) return false;
    if (curVis[v] == 1) continue;
    if (!dfs(v, curGraph, curVis)) return false;
  }
  curVis[u] = 1;
  return true;
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n, edges;
  cin >> n >> edges;
  int first, second;
  for (int i = 0; i < edges; ++i) {
    cin >> first >> second;
    graph[first].push_back(second);
    revGraph[second].push_back(first);
  }
  int qtt = 0;
  string ans = "";
  for (int i = 1; i <= n; ++i) {
    if (!vis[i] && !revVis[i]) {
      ++qtt;
      ans.push_back('A');
    } else {
      ans.push_back('E');
    }
    if (!dfs(i, graph, vis) || !dfs(i, revGraph, revVis)) {
      qtt = -1;
      break;
    }
  }
  cout << qtt << '\n';
  if (qtt != -1) {
    cout << ans << '\n';
  }
  return 0;
}
