#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 9;
vector<int> g[MAXN], rev_g[MAXN];
bool reached[MAXN], visited[MAXN], cycle_present = false;
int color[MAXN];
vector<int> v;
char fans[MAXN];
void dfs(int pos, int id) {
  reached[pos] = true;
  v.push_back(pos);
  for (int i = 0; i < g[pos].size(); i++) {
    if (!reached[g[pos][i]]) {
      dfs(g[pos][i], id);
    }
  }
}
void rdfs(int pos, int id) {
  visited[pos] = true;
  v.push_back(pos);
  for (int i = 0; i < rev_g[pos].size(); i++) {
    if (!visited[rev_g[pos][i]]) {
      rdfs(rev_g[pos][i], id);
    }
  }
}
void find_cycle(int pos) {
  color[pos] = 1;
  for (int i = 0; i < g[pos].size(); i++) {
    if (!color[g[pos][i]]) {
      find_cycle(g[pos][i]);
    } else if (color[g[pos][i]] == 1) {
      cycle_present = true;
    }
  }
  color[pos] = 2;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    rev_g[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    if (!color[i]) {
      find_cycle(i);
    }
  }
  if (cycle_present) {
    cout << -1 << endl;
    return 0;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    fans[i] = 'Z';
  }
  for (int i = 1; i <= n; i++) {
    int flag = 0;
    if (!reached[i]) {
      flag++;
      dfs(i, i);
      for (int j = 0; j < v.size(); j++) {
        fans[v[j]] = 'E';
      }
      v.clear();
    }
    if (!visited[i]) {
      flag++;
      rdfs(i, i);
      for (int j = 0; j < v.size(); j++) {
        fans[v[j]] = 'E';
      }
      v.clear();
    }
    if (flag == 2) {
      ans++;
      fans[i] = 'A';
    }
  }
  cout << ans << endl;
  for (int i = 1; i <= n; i++) {
    cout << fans[i];
  }
  cout << endl;
  return 0;
}
