#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << "{" << p.first << "," << p.second << "}";
  return os;
}
const int N = 3e5 + 5;
const int oo = 1e9 + 7;
vector<int> g[N];
vector<int> g_r[N];
bool ex[N];
int vis[N];
bool pos(int u) {
  vis[u] = 1;
  for (int v : g[u]) {
    if (vis[v] == 1) return 0;
    if (vis[v] == 2) continue;
    if (pos(v) == 0) return 0;
  }
  vis[u] = 2;
  return 1;
}
int mn[N];
void dp(int u) {
  if (mn[u] != 0) return;
  mn[u] = u;
  for (int v : g[u]) {
    dp(v);
    mn[u] = min(mn[u], mn[v]);
  }
}
int mn_[N];
void dp_(int u) {
  if (mn_[u] != 0) return;
  mn_[u] = u;
  for (int v : g_r[u]) {
    dp_(v);
    mn_[u] = min(mn_[u], mn_[v]);
  }
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g_r[y].push_back(x);
  }
  bool ans = 1;
  for (int i = 1; i <= n; i++) {
    if (vis[i] != 0) continue;
    if (pos(i) == 0) {
      ans = 0;
      break;
    }
  }
  if (ans == 0) {
    cout << "-1\n";
  } else {
    for (int i = 1; i <= n; i++) dp(i), dp_(i);
    int ans = 0;
    string a;
    for (int i = 1; i <= n; i++) {
      int m = min(mn_[i], mn[i]);
      if (m < i) {
        a += 'E';
      } else {
        ans++;
        a += 'A';
      }
    }
    cout << ans << "\n";
    cout << a << "\n";
  }
}
