#include <bits/stdc++.h>
using namespace std;
istream& operator>>(istream& in, pair<long long, long long>& b) {
  in >> b.first >> b.second;
  return in;
}
ostream& operator<<(ostream& out, const pair<long long, long long>& b) {
  out << "{" << b.first << ", " << b.second << "}";
  return out;
}
template <typename T>
ostream& operator<<(ostream& out, const vector<T>& a) {
  for (auto k : a) out << k << " ";
  return out;
}
template <typename T1, typename T2>
inline bool chkmin(T1& x, const T2& y) {
  if (x > y) {
    x = y;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
inline bool chkmax(T1& x, const T2& y) {
  if (x < y) {
    x = y;
    return 1;
  }
  return 0;
}
const long long INF = 1e18;
const long double PI = 4 * atan(1);
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
const long long N = 2e5 + 10;
long long n, m;
vector<long long> g[N], rg[N];
long long mn[N];
long long dp1[N], dp2[N];
long long used[N];
void dfsc(long long v) {
  used[v] = 1;
  for (auto u : g[v]) {
    if (!used[u]) {
      dfsc(u);
    } else if (used[u] == 1) {
      cout << "-1\n";
      exit(0);
    }
  }
  used[v] = 2;
}
vector<long long> ts;
void dfs(long long v) {
  used[v] = 1;
  for (auto u : g[v]) {
    if (!used[u]) {
      dfs(u);
    }
  }
  ts.push_back(v);
}
void rdfs(long long v) {
  used[v] = 1;
  for (auto u : rg[v]) {
    if (!used[u]) {
      rdfs(u);
    }
  }
  ts.push_back(v);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  for (long long i = 0; i < N; i++) {
    mn[i] = INF;
  }
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long u, v;
    cin >> u >> v;
    u--, v--;
    g[u].push_back(v);
    rg[v].push_back(u);
  }
  for (long long i = 0; i < n; i++) {
    if (!used[i]) {
      dfsc(i);
    }
  }
  for (long long i = 0; i < n; i++) {
    used[i] = 0;
  }
  for (long long i = 0; i < n; i++) {
    if (!used[i]) {
      dfs(i);
    }
  }
  for (long long i = 0; i < n; i++) {
    long long v = ts[i];
    dp1[v] = v;
    for (auto u : g[v]) {
      chkmin(dp1[v], dp1[u]);
    }
  }
  ts.clear();
  for (long long i = 0; i < n; i++) {
    used[i] = 0;
  }
  for (long long i = 0; i < n; i++) {
    if (!used[i]) {
      rdfs(i);
    }
  }
  for (long long i = 0; i < n; i++) {
    long long v = ts[i];
    dp2[v] = v;
    for (auto u : rg[v]) {
      chkmin(dp2[v], dp2[u]);
    }
  }
  string ans(n, 'E');
  long long cnt = 0;
  for (long long i = 0; i < n; i++) {
    if (min(dp1[i], dp2[i]) == i) {
      ans[i] = 'A';
      cnt++;
    }
  }
  cout << cnt << "\n" << ans << "\n";
}
