#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
vector<int> g[2][N];
bool used[N];
vector<int> post;
vector<vector<int>> comps;
void dfs_inv(int v) {
  used[v] = 1;
  for (int u : g[1][v]) {
    if (!used[u]) dfs_inv(u);
  }
  post.push_back(v);
}
void dfs(int v, vector<int>& comp) {
  used[v] = 1;
  comp.push_back(v);
  for (int u : g[0][v]) {
    if (!used[u]) dfs(u, comp);
  }
}
void kosaraju(int n) {
  for (int i = 1; i <= n; i++) used[i] = 0;
  for (int i = 1; i <= n; i++) {
    if (!used[i]) dfs_inv(i);
  }
  reverse(post.begin(), post.end());
  for (int i = 1; i <= n; i++) used[i] = 0;
  for (int v : post) {
    if (!used[v]) {
      vector<int> comp;
      dfs(v, comp);
      comps.push_back(comp);
    }
  }
}
bool bad[2][N];
void dfs(int v, int d) {
  bad[d][v] = 1;
  for (int u : g[d][v]) {
    if (bad[d][u]) continue;
    dfs(u, d);
  }
}
void Solve() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    g[0][u].push_back(v);
    g[1][v].push_back(u);
  }
  kosaraju(n);
  for (auto& i : comps) {
    if (i.size() > 1) {
      cout << "-1\n";
      return;
    }
  }
  for (int i = 0; i < N; i++) used[i] = 0;
  int ans = 0;
  string s;
  for (int i = 1; i <= n; i++) {
    if (bad[0][i] || bad[1][i]) {
      s += 'E';
      dfs(i, 0);
      dfs(i, 1);
    } else {
      s += 'A';
      ans++;
      dfs(i, 0);
      dfs(i, 1);
    }
  }
  cout << ans << "\n";
  cout << s << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  Solve();
  return 0;
}
