#include <bits/stdc++.h>
using namespace std;
void runtime() {
  cout << fixed << setprecision(5) << 1.0 * clock() / CLOCKS_PER_SEC << endl;
}
template <class T>
void read(vector<T> &a, int n) {
  T x;
  a.clear();
  for (int i = 0; i < n; i++) {
    cin >> x;
    a.push_back(x);
  }
}
template <class T>
void write(vector<T> &a) {
  for (T x : a) cout << x << ' ';
  cout << '\n';
}
const int N = 200005;
int n, m;
char ans[N];
vector<int> g[N];
vector<int> gr[N];
int used[N], used1[N], used2[N];
vector<int> top;
int cc;
void dfs1(int u) {
  used1[u] = 1;
  used[u] = 1;
  for (int i = 0; i < g[u].size(); i++)
    if (!used1[g[u][i]]) dfs1(g[u][i]);
  top.push_back(u);
}
void dfs2(int u) {
  used2[u] = 1;
  used[u] = 1;
  for (int i = 0; i < gr[u].size(); i++)
    if (!used2[gr[u][i]]) dfs2(gr[u][i]);
}
int main() {
  ios_base::sync_with_stdio(0);
  for (int i = 0; i < N; i++) ans[i] = 'E';
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    gr[b].push_back(a);
  }
  for (int i = 1; i <= n; i++)
    if (!used[i]) dfs1(i);
  memset(used, 0, sizeof(used));
  reverse(top.begin(), top.end());
  for (int i = 0; i < top.size(); i++)
    if (!used2[top[i]]) {
      cc++;
      dfs2(top[i]);
    }
  if (cc != n) {
    cout << -1;
    return 0;
  }
  int res = 0;
  memset(used, 0, sizeof(used));
  memset(used1, 0, sizeof(used1));
  memset(used2, 0, sizeof(used2));
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      res++;
      ans[i] = 'A';
    }
    dfs1(i);
    dfs2(i);
  }
  cout << res << "\n";
  for (int i = 1; i <= n; i++) cout << ans[i];
  cout << "\n";
}
