#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> g[2];
vector<int> _was[2];
bool dfsX(int i, const vector<vector<int>> &gg, vector<int> &was) {
  if (was[i] == 1) {
    return false;
  }
  if (was[i] == 2) {
    return true;
  }
  was[i] = 1;
  for (auto u : gg[i]) {
    if (!dfsX(u, gg, was)) {
      return false;
    }
  }
  was[i] = 2;
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int m;
  cin >> m;
  for (int k = 0; k < 2; ++k) g[k].resize(n);
  for (int k = 0; k < 2; ++k) _was[k].resize(n, 0);
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    g[0][x].push_back(y);
    g[1][y].push_back(x);
  }
  string ans(n, 'E');
  for (int i = 0; i < n; ++i) {
    if (_was[0][i] + _was[1][i] == 0) {
      ans[i] = 'A';
    }
    for (int k = 0; k < 2; ++k) {
      if (_was[k][i] > 0) {
        continue;
      }
      if (!dfsX(i, g[k], _was[k])) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  int nA = 0;
  for (int i = 0; i < n; ++i)
    if (ans[i] == 'A') nA++;
  cout << nA << endl;
  cout << ans << endl;
  return 0;
}
