#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int n, m, u, v;
vector<int> g[N], g2[N];
int vis[N], vis2[N];
string ans;
void DFS(int node) {
  if (vis[node] == 2) return;
  vis[node] = 1;
  for (int i = 0; i < (int)g[node].size(); i++) {
    if (vis[g[node][i]] == 1) {
      puts("-1");
      exit(0);
    } else if (vis[g[node][i]] == 0)
      DFS(g[node][i]);
  }
  vis[node] = 2;
}
void DFS2(int node) {
  if (vis2[node] == 2) return;
  vis2[node] = 1;
  for (int i = 0; i < (int)g2[node].size(); i++) {
    if (vis2[g2[node][i]] == 1) {
      puts("-1");
      exit(0);
    } else if (vis2[g2[node][i]] == 0)
      DFS2(g2[node][i]);
  }
  vis2[node] = 2;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &u, &v);
    g[v].push_back(u);
    g2[u].push_back(v);
  }
  ans.resize(n, 'E');
  int all = 0;
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0 && vis2[i] == 0) {
      all++;
      ans[i - 1] = 'A';
    }
    DFS(i);
    DFS2(i);
  }
  printf("%d\n", all);
  puts(ans.c_str());
  return 0;
}
