#include <bits/stdc++.h>
using namespace std;
const int NMAX = 200005;
int N, M;
vector<int> graph[2][NMAX];
int indeg[NMAX];
int seen[2][NMAX];
void dfs(int node, int dir) {
  if (seen[dir][node]) return;
  seen[dir][node] = 1;
  for (auto& x : graph[dir][node]) dfs(x, dir);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> N >> M;
  for (int i = 1; i <= M; ++i) {
    int u, v;
    cin >> u >> v;
    ++indeg[v];
    graph[0][u].push_back(v);
    graph[1][v].push_back(u);
  }
  queue<int> q;
  for (int i = 1; i <= N; ++i)
    if (indeg[i] == 0) q.push(i);
  while (!q.empty()) {
    int node = q.front();
    q.pop();
    for (auto& x : graph[0][node])
      if (--indeg[x] == 0) q.push(x);
  }
  for (int i = 1; i <= N; ++i)
    if (indeg[i] > 0) {
      cout << "-1\n";
      return 0;
    }
  string answer(N, 'E');
  int cntanswer = 0;
  for (int i = 1; i <= N; ++i) {
    if (seen[0][i] == 0 && seen[1][i] == 0) {
      answer[i - 1] = 'A';
      ++cntanswer;
    }
    dfs(i, 0);
    dfs(i, 1);
  }
  cout << cntanswer << "\n" << answer << "\n";
  return 0;
}
