#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<pair<int, int> > equ;
vector<vector<int> > cEdge, pEdge;
vector<int> traceDown(200005);
vector<int> traceUp(200005);
vector<int> gray(200005);
vector<int> visited(200005);
bool hasLoop = false;
int cnt = 0;
string res = "";
void initEdge() {
  for (int i = 0; i < n + 1; ++i) {
    vector<int> tmp(0);
    pEdge.push_back(tmp);
    cEdge.push_back(tmp);
  }
}
void constructEdge() {
  for (int i = 0; i < m; ++i) {
    cEdge[equ[i].second].push_back(equ[i].first);
    pEdge[equ[i].first].push_back(equ[i].second);
  }
}
bool dfs(int root) {
  bool hasLoop = false;
  gray[root] = 1;
  traceDown[root] = root;
  visited[root] = 1;
  for (auto nb : cEdge[root]) {
    if (traceUp[nb] == 0) {
      if (nb < traceUp[root])
        traceUp[nb] = nb;
      else
        traceUp[nb] = traceUp[root];
    } else if (traceUp[nb] > traceUp[root])
      traceUp[nb] = traceUp[root];
    if (gray[nb] == 1) hasLoop = true;
    if (hasLoop == true) break;
    if (visited[nb] == 0) {
      hasLoop = dfs(nb);
    }
    if (hasLoop == true) break;
    if (traceDown[nb] < traceDown[root]) traceDown[root] = traceDown[nb];
  }
  gray[root] = 0;
  return hasLoop;
}
bool HaveQuantifier() {
  bool hasLoop = false;
  for (int i = 1; i <= n; ++i) {
    if (visited[i] == 0) {
      traceUp[i] = i;
      bool hasLoop2 = dfs(i);
      if (hasLoop2 == true) {
        hasLoop = true;
        break;
      }
    }
  }
  return !hasLoop;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    equ.push_back(pair<int, int>(tmp1, tmp2));
  }
  initEdge();
  constructEdge();
  for (int i = 0; i < n; ++i) res += "E";
  if (HaveQuantifier() == true) {
    for (int i = 1; i <= n; ++i) {
      if (traceUp[i] == i && traceDown[i] == i) {
        cnt++;
        res[i - 1] = 'A';
      }
    }
    cout << cnt << endl;
    cout << res << endl;
  } else
    cout << -1 << endl;
  return 0;
}
