#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <class C>
void mini(C &a4, C b4) {
  a4 = min(a4, b4);
}
template <class C>
void maxi(C &a4, C b4) {
  a4 = max(a4, b4);
}
template <class TH>
void _dbg(const char *sdbg, TH h) {
  cerr << sdbg << '=' << h << endl;
}
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << '=' << h << ',';
  _dbg(sdbg + 1, a...);
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[";
  for (auto vv : V) os << vv << ",";
  return os << "]";
}
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
const long long MAX = 200010;
long long n, m;
vector<long long> d[MAX];
vector<long long> drev[MAX];
long long visd[MAX], visrev[MAX];
void nope() {
  cout << "-1\n";
  exit(0);
}
void dfsd(long long v) {
  if (visd[v]) {
    if (visd[v] == 2) nope();
    return;
  }
  visd[v] = 2;
  for (long long el : d[v]) {
    dfsd(el);
  }
  visd[v] = 1;
}
void dfsrev(long long v) {
  if (visrev[v]) return;
  visrev[v] = 1;
  for (long long el : drev[v]) {
    dfsrev(el);
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  if (0) cout << fixed << setprecision(6);
  cin >> n >> m;
  for (long long i = (0); i <= ((long long)(m)-1); i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    d[a].push_back(b);
    drev[b].push_back(a);
  }
  long long wyn = 0;
  string res(n, 'E');
  for (long long i = (0); i <= ((long long)(n)-1); i++) {
    if (visd[i] == 0 && visrev[i] == 0) {
      res[i] = 'A';
      wyn++;
    }
    dfsd(i);
    dfsrev(i);
  }
  cout << wyn << "\n";
  cout << res << "\n";
}
