#include <bits/stdc++.h>
using namespace std;
using li = long long;
using ld = long double;
void solve(bool);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(20);
  srand(time(0));
  solve(true);
  return 0;
}
const int maxn = 2e5 + 55;
int n, m;
vector<int> g[maxn], grev[maxn];
int t[maxn], trev[maxn];
bool cant[maxn];
int cycle = 0;
void dfs(int v) {
  if (t[v] == 1 || cycle) return;
  if (t[v] == -1) {
    cycle = 1;
    return;
  }
  cant[v] = 1;
  t[v] = -1;
  for (int to : g[v]) {
    dfs(to);
  }
  t[v] = 1;
}
void dfsrev(int v) {
  if (trev[v] == 1 || cycle) return;
  if (trev[v] == -1) {
    cycle = 1;
    return;
  }
  cant[v] = 1;
  trev[v] = -1;
  for (int to : grev[v]) {
    dfsrev(to);
  }
  trev[v] = 1;
}
void solve(bool __attribute__((unused)) read) {
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    g[x].push_back(y);
    grev[y].push_back(x);
  }
  int ans = 0;
  string st;
  for (int i = 0; i < n; ++i) {
    if (cant[i])
      st += "E";
    else
      st += "A";
    ans += !cant[i];
    dfs(i);
    dfsrev(i);
  }
  if (cycle) {
    cout << -1 << endl;
    return;
  }
  cout << ans << endl;
  cout << st << endl;
}
