#include <bits/stdc++.h>
using namespace std;
const int MAX = 200001;
int n, m;
vector<int> adj[MAX], adj2[MAX];
int f[MAX], fcnt, sn[MAX], scnt;
stack<int> s;
bool is_end[MAX], impa, in[MAX];
int dfs(int cur) {
  int result = f[cur] = ++fcnt;
  s.push(cur);
  for (int next : adj[cur]) {
    if (!f[next])
      result = min(dfs(next), result);
    else if (!is_end[next])
      result = min(f[next], result);
  }
  if (result == f[cur]) {
    int size = 0;
    while (1) {
      int temp = s.top();
      s.pop();
      size++;
      is_end[temp] = 1;
      if (temp == cur) break;
    }
    if (size > 1) impa = 1;
  }
  return result;
}
int low[MAX], low2[MAX];
bool vis[MAX];
int get_min(int cur) {
  int &result = low[cur];
  result = cur;
  vis[cur] = 1;
  for (int next : adj[cur])
    if (!vis[next])
      result = min(result, get_min(next));
    else
      result = min(result, low[next]);
  return result;
}
int get_min2(int cur) {
  int &result = low2[cur];
  result = cur;
  vis[cur] = 1;
  for (int next : adj2[cur])
    if (!vis[next])
      result = min(result, get_min2(next));
    else
      result = min(result, low2[next]);
  return result;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    adj[a - 1].push_back(b - 1);
    adj2[b - 1].push_back(a - 1);
    in[b - 1] = 1;
  }
  for (int i = 0; i < n; i++)
    if (!f[i]) dfs(i);
  if (impa) {
    cout << -1;
    return 0;
  }
  string ans;
  int cnt = 0;
  for (int i = 0; i < n; i++)
    if (!vis[i]) get_min(i);
  fill(vis, vis + MAX, 0);
  for (int i = 0; i < n; i++)
    if (!vis[i]) get_min2(i);
  for (int i = 0; i < n; i++)
    if (min(low[i], low2[i]) == i)
      cnt++, ans.push_back('A');
    else
      ans.push_back('E');
  cout << cnt << endl;
  cout << ans;
  return 0;
}
