#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX = 1 << 20;
int go(int curr, vector<int>& from, vector<bool>& in,
       vector<vector<int>>& adj) {
  if (from[curr] != -1) return from[curr];
  from[curr] = curr;
  in[curr] = true;
  for (int j : adj[curr]) {
    if (from[j] == -1) {
      int res = go(j, from, in, adj);
      if (res == -1) return -1;
      from[curr] = min(from[curr], res);
    } else if (in[j]) {
      return -1;
    } else {
      from[curr] = min(from[curr], from[j]);
    }
  }
  in[curr] = false;
  return from[curr];
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> adj(N);
  vector<vector<int>> radj(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b, a--, b--;
    adj[a].emplace_back(b);
    radj[b].emplace_back(a);
  }
  vector<bool> in(N), in2(N);
  vector<int> from(N, -1), from2(N, -1);
  int cnt = 0;
  string s;
  for (int i = 0; i < N; i++) {
    int res = min(go(i, from, in, adj), go(i, from2, in2, radj));
    if (res == -1) {
      cout << -1 << endl;
      return 0;
    }
    if (res == i) {
      cnt++;
      s.append("A");
    } else {
      s.append("E");
    }
  }
  cout << cnt << endl;
  cout << s << endl;
}
