#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int nax = 2e5 + 5;
void add(int a, int b) {
  a = (a + b) % mod;
  if (mod < 0) a += mod;
}
vector<int> g[nax];
vector<int> visit(nax);
vector<int> order;
bool cycle(int root) {
  visit[root] = 1;
  bool ans = true;
  for (int child : g[root]) {
    if (visit[child] == 1) return false;
    if (visit[child] == 2) continue;
    ans &= cycle(child);
  }
  visit[root] = 2;
  order.push_back(root);
  return ans;
}
vector<int> find_topo(int n) {
  vector<int> in(n + 1);
  for (int i = 1; i < n + 1; i++) {
    for (auto child : g[i]) in[child]++;
  }
  vector<int> ans;
  for (int i = 1; i < n + 1; i++) {
    if (!in[i]) ans.push_back(i);
  }
  for (int i = 0; i < ans.size(); i++) {
    int x = ans[i];
    for (int child : g[x]) {
      if (--in[child] == 0) ans.push_back(child);
    }
  }
  if (ans.size() == n) return ans;
  return vector<int>{};
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, e;
  cin >> n >> e;
  while (e--) {
    int p, c;
    cin >> p >> c;
    g[p].push_back(c);
  }
  order = find_topo(n);
  if (!order.size()) {
    cout << -1 << endl;
    return 0;
  }
  reverse(order.begin(), order.end());
  string res(n + 1, 'A');
  vector<int> mn(n + 1);
  iota(mn.begin(), mn.end(), 0);
  for (int i = 0; i < n; i++) {
    int node = order[i];
    for (int child : g[node]) {
      mn[node] = min(mn[node], mn[child]);
    }
  }
  for (int i = 1; i < n + 1; i++) {
    if (mn[i] < i) res[i] = 'E';
  }
  reverse(order.begin(), order.end());
  iota(mn.begin(), mn.end(), 0);
  for (int i = 0; i < n; i++) {
    int node = order[i];
    for (int child : g[node]) {
      mn[child] = min(mn[child], mn[node]);
    }
  }
  for (int i = 1; i < n + 1; i++) {
    if (mn[i] < i) res[i] = 'E';
  }
  int ans = 0;
  for (int i = 1; i < n + 1; i++)
    if (res[i] == 'A') ans++;
  cout << ans << endl;
  cout << res.substr(1, n) << endl;
  return 0;
}
