#include <bits/stdc++.h>
using namespace std;
long long n, m, ans, u, v, start;
string opz;
int vis[2][200005];
vector<int> grafo[2][200005];
void dfs(int nodo, int mode) {
  vis[mode][nodo] = 1;
  for (auto i : grafo[mode][nodo]) {
    if (vis[mode][i] == 1) {
      cout << "-1\n";
      exit(0);
    }
    if (vis[mode][i] == 0) {
      dfs(i, mode);
    }
  }
  vis[mode][nodo] = 2;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  opz.resize(n);
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    grafo[0][u].push_back(v);
    grafo[1][v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    if (vis[0][i] == 0 && vis[1][i] == 0) {
      opz[i - 1] = 'A';
      ans++;
    } else {
      opz[i - 1] = 'E';
    }
    if (vis[0][i] == false) dfs(i, 0);
    if (vis[1][i] == false) dfs(i, 1);
  }
  cout << ans << "\n" << opz << "\n";
  return 0;
}
