#include <bits/stdc++.h>
using namespace ::std;
int n, m, cant = 0, dp[200005][2], visited[200005], cnt;
char val[200005];
vector<int> forw[200005], rev[200005];
void DFS(int i) {
  visited[i] = 1;
  for (auto a : forw[i])
    if (!visited[a])
      DFS(a);
    else if (visited[a] == 1)
      cant = 1;
  visited[i] = 2;
}
void DFS2(int i, int way) {
  dp[i][!way] = 1;
  if (!dp[i][way]) dp[i][way] = -1;
  for (auto a : (way ? forw[i] : rev[i])) {
    if (dp[a][way] == 1) cant = 1;
    if (dp[a][!way] != 1) DFS2(a, way);
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0, l, r; i < m; i++)
    cin >> l >> r, forw[l].push_back(r), rev[r].push_back(l);
  for (int i = 1; i <= n; i++)
    if (!visited[i]) DFS(i);
  if (cant) return cout << "-1\n", 0;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    cant = 0;
    DFS2(i, 0);
    DFS2(i, 1);
    if (cant)
      val[i] = 'E';
    else
      val[i] = 'A', ans++;
  }
  cout << ans << '\n';
  for (int i = 1; i <= n; i++) cout << val[i];
  cout << '\n';
}
