#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template <typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  mti e(n), re(n);
  vi deg(n, 0);
  int u, v;
  for (int i = 0; i < (m); i++) {
    cin >> u >> v;
    u--, v--;
    e[u].push_back(v);
    re[v].push_back(u);
    deg[v]++;
  }
  vi ord(n);
  queue<int> q;
  for (int i = 0; i < (n); i++)
    if (deg[i] == 0) q.push(i);
  for (int i = 0; i < (n); i++) {
    if (q.empty()) {
      cout << -1 << endl;
      return 0;
    }
    int now = q.front();
    q.pop();
    ord[i] = now;
    for (auto &nx : e[now]) {
      deg[nx]--;
      if (deg[nx] == 0) q.push(nx);
    }
  }
  string ans(n, 'E');
  vi dp(n), rdp(n);
  iota((dp).begin(), (dp).end(), 0);
  iota((rdp).begin(), (rdp).end(), 0);
  for (int i = 0; i < (n); i++) {
    int now = ord[i];
    for (auto &nx : re[now]) {
      dp[now] = min(dp[now], dp[nx]);
    }
  }
  for (int i = 0; i < (n); i++) {
    int now = ord[n - 1 - i];
    for (auto &nx : e[now]) {
      rdp[now] = min(rdp[now], rdp[nx]);
    }
  }
  int count = 0;
  for (int i = 0; i < (n); i++) {
    if (dp[i] == i && rdp[i] == i) {
      count++;
      ans[i] = 'A';
    }
  }
  cout << count << "\n" << ans << endl;
  return 0;
}
