#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 2e5 + 4;
vector<int> v[N], vr[N];
int mark[N];
void dfs(int node) {
  mark[node] = 1;
  for (int it : v[node]) {
    if (mark[it] == 1) {
      printf("%d", -1);
      exit(0);
    } else if (mark[it] == 0)
      dfs(it);
  }
  mark[node] = 2;
}
void dfs1(int node) {
  mark[node] = 0;
  for (int it : vr[node])
    if (mark[it]) {
      dfs1(it);
    }
}
int none_smaller[N];
int main() {
  int n, m;
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d", &a);
    scanf("%d", &b);
    v[a].push_back(b);
    vr[b].push_back(a);
  }
  for (int i = 1; i < n + 1; i++)
    if (mark[i] == 0) dfs(i), none_smaller[i]++;
  for (int i = 1; i < n + 1; i++)
    if (mark[i]) dfs1(i), none_smaller[i]++;
  string ans = "";
  int cnt = 0;
  for (int i = 1; i < n + 1; i++)
    if (none_smaller[i] == 2)
      cnt++, ans.push_back('A');
    else
      ans.push_back('E');
  printf("%d\n", cnt);
  cout << ans;
  return 0;
}
