#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18 + 1;
const long long N = 2e5 + 1;
const long long mod = 1e9 + 7;
vector<int> adj[N], adjr[N];
int ans[N], vis[N], instack[N], visr[N], instackr[N];
void quit() {
  cout << -1 << "\n";
  exit(0);
}
bool dfs(int node) {
  instack[node] = 1;
  for (int nxt : adj[node]) {
    if (instack[nxt]) {
      quit();
    } else if (!vis[nxt]) {
      dfs(nxt);
    }
  }
  instack[node] = 0;
  vis[node] = 1;
}
void dfsr(int node) {
  instackr[node] = 1;
  for (int nxt : adjr[node]) {
    if (instackr[nxt]) {
      quit();
    } else if (!visr[nxt]) {
      dfsr(nxt);
    }
  }
  instackr[node] = 0;
  visr[node] = 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  std::cout << std::fixed << std::setprecision(20);
  ;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adjr[v].push_back(u);
  }
  int cntr = 0;
  for (int i = 1; i <= n; i++) {
    if (!vis[i] && !visr[i]) {
      ans[i] = 1;
      cntr++;
    }
    if (!vis[i]) {
      dfs(i);
    }
    if (!visr[i]) {
      dfsr(i);
    }
  }
  cout << cntr << "\n";
  for (int i = 1; i <= n; i++) {
    if (ans[i]) {
      cout << 'A';
    } else {
      cout << 'E';
    }
  }
  cout << "\n";
}
