#include <bits/stdc++.h>
using namespace std;
using namespace std;
struct sch {
  long long int s, e, t;
};
bool sortinrev(const struct sch &a, const struct sch &b) { return (a.s < b.s); }
vector<long long int> graph[200010];
vector<long long int> graphr[200010];
long long int vis[200010], visf[200010], visr[200010];
char ans[200010];
int flag;
void cycle(long long int cur) {
  if (!flag) return;
  vis[cur] = 1;
  for (long long int i = 0; i < graph[cur].size(); i++) {
    long long int u = graph[cur][i];
    if (vis[u] == 1) {
      flag = 0;
      return;
    } else if (vis[u] == 2) {
      continue;
    } else {
      cycle(u);
    }
  }
  vis[cur] = 2;
  return;
}
void dfs_front(long long int cur, long long int s) {
  visf[cur] = 1;
  for (long long int i = 0; i < graph[cur].size(); i++) {
    long long int u = graph[cur][i];
    if (visf[u] == 1) {
      continue;
    }
    if (ans[u] == 'z') ans[u] = 'E';
    dfs_front(u, s);
  }
}
void dfs_back(long long int cur, long long int s) {
  visr[cur] = 1;
  for (long long int i = 0; i < graphr[cur].size(); i++) {
    long long int u = graphr[cur][i];
    if (visr[u] == 1) {
      continue;
    }
    if (ans[u] == 'z') ans[u] = 'E';
    dfs_back(u, s);
  }
}
int main() {
  long long int n, m;
  cin >> n >> m;
  flag = 1;
  for (long long int i = 0; i < n; i++) ans[i] = 'z';
  for (long long int i = 0; i < m; i++) {
    long long int u, v;
    cin >> u >> v;
    graph[u - 1].push_back(v - 1);
    graphr[v - 1].push_back(u - 1);
  }
  for (long long int i = 0; i < n; i++) {
    if (!vis[i]) cycle(i);
  }
  if (flag == 0) {
    cout << -1 << endl;
    return 0;
  }
  memset(visf, 0, sizeof(visf));
  memset(visr, 0, sizeof(visr));
  for (long long int i = 0; i < n; i++) {
    if (ans[i] == 'z') {
      ans[i] = 'A';
      dfs_front(i, i);
      dfs_back(i, i);
    } else if (ans[i] == 'E') {
      if (visf[i] == 0) dfs_front(i, i);
      if (visr[i] == 0) dfs_back(i, i);
    }
  }
  long long int cnt = 0;
  for (long long int i = 0; i < n; i++) {
    if (ans[i] == 'A') cnt++;
  }
  cout << cnt << endl;
  for (long long int i = 0; i < n; i++) {
    cout << ans[i];
  }
  cout << endl;
}
