#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
template <class TH>
void _dbg(const char *sdbg, TH h) {
  cerr << sdbg << "=" << h << "\n";
}
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << "=" << h << ",";
  _dbg(sdbg + 1, a...);
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[";
  for (auto vv : V) os << vv << ",";
  return os << "]";
}
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}
const int MAXN = 1e6 + 6;
int n, m;
vector<int> G[MAXN];
vector<int> tG[MAXN];
int vis[MAXN];
int dp[2][MAXN];
vector<int> v;
void top(int w) {
  vis[w] = 1;
  for (auto u : G[w]) {
    if (!vis[u]) {
      top(u);
    }
    if (vis[u] == 1) {
      cout << -1;
      exit(0);
    }
  }
  v.push_back(w);
  vis[w] = 2;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    tG[b].push_back(a);
  }
  for (int i = 1; i <= n; ++i) {
    if (!vis[i]) {
      top(i);
    }
  }
  int res = 0;
  (v);
  reverse(v.begin(), v.end());
  for (int i = v.size() - 1; i >= 0; --i) {
    int w = v[i];
    dp[0][w] = w;
    for (auto u : G[w]) {
      dp[0][w] = min(dp[0][w], dp[0][u]);
    }
  }
  for (auto w : v) {
    dp[1][w] = w;
    for (auto u : tG[w]) {
      dp[1][w] = min(dp[1][w], dp[1][u]);
    }
    (w, dp[1][w], dp[0][w]);
    if (min(dp[1][w], dp[0][w]) >= w) {
      ++res;
    }
  }
  cout << res << endl;
  for (int i = 1; i <= n; ++i) {
    if (min(dp[1][i], dp[0][i]) >= i) {
      cout << "A";
      continue;
    }
    cout << "E";
  }
  cout << endl;
}
