#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
const int kMaxN = 3e5;
int n, m;
vector<pii> edges;
vi adj[kMaxN];
int min_in[kMaxN];
int min_out[kMaxN];
bool vis[kMaxN];
vi order;
int in_order[kMaxN];
void Dfs(int v) {
  vis[v] = true;
  for (int s : adj[v]) {
    if (!vis[s]) {
      Dfs(s);
    }
  }
  order.push_back(v);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    edges.emplace_back(u, v);
  }
  for (int i = 1; i <= n; ++i) {
    if (!vis[i]) {
      Dfs(i);
    }
  }
  reverse((order).begin(), (order).end());
  for (int i = 0; i < n; ++i) {
    in_order[order[i]] = i;
  }
  for (auto [u, v] : edges) {
    if (in_order[u] > in_order[v]) {
      cout << "-1\n";
      return 0;
    }
  }
  for (int i = 1; i <= n; ++i) {
    min_in[i] = min_out[i] = i;
  }
  for (int v : order) {
    for (int s : adj[v]) {
      min_in[s] = min(min_in[s], min_in[v]);
    }
  }
  reverse((order).begin(), (order).end());
  for (int v : order) {
    for (int s : adj[v]) {
      min_out[v] = min(min_out[v], min_out[s]);
    }
  }
  string ans(n, 'E');
  int cntans = 0;
  for (int i = 1; i <= n; ++i) {
    if (min_in[i] == i && min_out[i] == i) {
      ans[i - 1] = 'A';
      ++cntans;
    }
  }
  cout << cntans << "\n";
  cout << ans << "\n";
}
