#include <bits/stdc++.h>
using namespace std;
using namespace std;
void exit_routine() {
  printf("-1");
  exit(0);
}
bool chek1[200008], chek2[200008];
bool time1[200008], time2[200008];
vector<int> g1[200008], g2[200008];
void dfs(vector<int> *g, bool *chek, bool *time, int nd) {
  chek[nd] = 1;
  for (auto x : g[nd])
    if (!chek[x])
      dfs(g, chek, time, x);
    else if (!time[x])
      exit_routine();
  time[nd] = 1;
}
void solve(int tim) {
  int n, m;
  scanf("%d%d", &n, &m);
  while (m--) {
    int u, v;
    scanf("%d%d", &u, &v);
    g1[u].push_back(v);
    g2[v].push_back(u);
  }
  string ans;
  int acnt = 0;
  for (int i{1}; i < n + 1; i++) {
    if (chek1[i] || chek2[i])
      ans.push_back('E');
    else {
      ans.push_back('A');
      acnt++;
    }
    if (!chek1[i]) dfs(g1, chek1, time1, i);
    if (!chek2[i]) dfs(g2, chek2, time2, i);
  }
  cout << acnt << endl << ans;
}
int main() {
  int test = 1;
  for (int t{1}; t < test + 1; t++) {
    solve(t);
  }
}
