#include <bits/stdc++.h>
using namespace std;
vector<int> v[200001];
vector<int> v1[200001];
int vis[200001];
int rec[200001];
int exis[200001];
int exis1[200001];
int is_cyc;
void dfs1(int a) {
  vis[a] = 1;
  rec[a] = 1;
  for (int i = 0; i < v[a].size(); i++) {
    int temp = v[a][i];
    if (rec[temp]) {
      is_cyc = 1;
      return;
    } else if (!vis[temp]) {
      dfs1(temp);
    }
  }
  rec[a] = 0;
}
void dfs(int a, int m) {
  for (int i = 0; i < v[a].size(); i++) {
    int temp = v[a][i];
    if (temp < m) {
      exis[m] = 1;
    } else if (!exis[temp]) {
      exis[temp] = 1;
      dfs(temp, m);
    }
  }
}
void dfs2(int a, int m) {
  for (int i = 0; i < v1[a].size(); i++) {
    int temp = v1[a][i];
    if (temp < m) {
      exis1[m] = 1;
    } else if (!exis1[temp]) {
      exis1[temp] = 1;
      dfs2(temp, m);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    v[a].push_back(b);
    v1[b].push_back(a);
  }
  is_cyc = 0;
  for (int i = 0; i < n; ++i) {
    vis[i] = 0;
    rec[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    if (!vis[i]) {
      dfs1(i);
    }
  }
  if (is_cyc) {
    cout << "-1" << endl;
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    exis[i] = 0;
    exis1[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    if (!exis[i]) {
      dfs(i, i);
    }
  }
  for (int i = 0; i < n; i++) {
    if (!exis1[i]) {
      dfs2(i, i);
    }
  }
  for (int i = 0; i < n; i++) {
    exis[i] |= exis1[i];
  }
  int ct = 0;
  for (int i = 0; i < n; ++i) {
    if (!exis[i]) ct++;
  }
  cout << ct << endl;
  for (int i = 0; i < n; ++i) {
    if (exis[i])
      cout << "E";
    else
      cout << "A";
  }
  cout << endl;
}
