#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#else
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
 public:
  int n, m;
  vector<int> V[maxn];
  pi save[maxn];
  int in[maxn];
  void solve() {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
      cin >> save[i].first >> save[i].second;
      V[save[i].first].push_back(save[i].second);
      in[save[i].second]++;
    }
    if (topo()) {
      cout << -1;
      return;
    }
    for (int i = 0; i < m; ++i) {
      V[save[i].second].push_back(save[i].first);
    }
    string ans;
    int anscount = 0;
    for (int i = 1; i <= n; ++i) {
      vector<int> tmp;
      for (int j : V[i]) {
        if (j > i) tmp.push_back(j);
      }
      swap(V[i], tmp);
    }
    for (int i = 1; i <= n; ++i) {
      if (!vis[i]) {
        ans += "A";
        anscount++;
        dfs(i);
      } else {
        ans += "E";
      }
    }
    cout << anscount << "\n"
         << ans;
  }
  bool vis[maxn];
  void dfs(int u) {
    if (vis[u]) return;
    vis[u] = 1;
    for (int v : V[u]) {
      dfs(v);
    }
  }
  bool topo() {
    vector<int> que;
    for (int i = 1; i <= n; ++i) {
      if (in[i] == 0) {
        que.push_back(i);
      }
    }
    for (int i = 0; i < que.size(); ++i) {
      for (int j : V[que[i]]) {
        in[j]--;
        if (in[j] == 0) {
          que.push_back(j);
        }
      }
    }
    if (que.size() != n) return true;
    return false;
  }
} NSPACE;
int main() {
  FPEN;
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  NSPACE.solve();
}


#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#else
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
 public:
  int n, m;
  vector<int> V[maxn];
  pi save[maxn];
  int in[maxn];
  void solve() {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
      cin >> save[i].first >> save[i].second;
      V[save[i].first].push_back(save[i].second);
      in[save[i].second]++;
    }
    if (topo()) {
      cout << -1;
      return;
    }
    for (int i = 0; i < m; ++i) {
      V[save[i].second].push_back(save[i].first);
    }
    string ans;
    int anscount = 0;
    for (int i = 1; i <= n; ++i) {
      if (!vis[i]) {
        ans += "A";
        anscount++;
        for (int j : V[i]) {
          vis[j] = 1;
        }
      } else {
        ans += "E";
      }
    }
    cout << anscount << "\n"
         << ans;
  }
  bool vis[maxn];
  bool topo() {
    vector<int> que;
    for (int i = 1; i <= n; ++i) {
      if (in[i] == 0) {
        que.push_back(i);
      }
    }
    for (int i = 0; i < que.size(); ++i) {
      for (int j : V[que[i]]) {
        in[j]--;
        if (in[j] == 0) {
          que.push_back(j);
        }
      }
    }
    if (que.size() != n) return true;
    return false;
  }
} NSPACE;
int main() {
  FPEN;
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  NSPACE.solve();
}


#include <bits/stdc++.h>
using namespace std;
#define pb  push_back
#define ll  long long
#define vi  vector<int>
#define vvi vector<vi >
#define all(x) x.begin(), x.end()

int n, m, k;
vvi g;
vi  u, ord, t, x, y;
string s;

void dfs(int v) {
    u[v] = 1;
    for (auto to : g[v])
        if (!u[to])
            dfs(to);
    ord.pb(v);
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m;
    g.resize(n);
    for (int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b; --a; --b;
        g[a].pb(b);
    }
    u.assign(n, 0);
    for (int i = 0; i < n; ++i)
        if (!u[i]) dfs(i);
    reverse(all(ord));
    t.resize(n);
    for (int i = 0; i < n; ++i)
        t[ord[i]] = i;
    for (int v = 0; v < n; ++v) {
        for (int to : g[v]) {
            if (t[v] > t[to]) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    x = y = vi(n);
    for (int i = 0; i < n; ++i)
        x[i] = y[i] = i;
    for (auto v : ord)
        for (auto to : g[v])
            x[to] = min(x[to], x[v]);
    reverse(all(ord));
    for (auto v : ord)
        for (auto to : g[v])
            y[v] = min(y[v], y[to]);
    for (int i = 0; i < n; ++i) {
        if (x[i] == i && y[i] == i)
            s += 'A', ++k;
        else
            s += 'E';
    }
    cout << k << endl;
    cout << s << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb  push_back
#define ll  long long
#define vi  vector<int>
#define vvi vector<vi >
#define all(x) x.begin(), x.end()

int n, m, k;
vvi g;
vi  u, ord, t;
string s;

void dfs(int v) {
    u[v] = 1;
    for (auto to : g[v])
        if (!u[to])
            dfs(to);
    ord.pb(v);
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m;
    g.resize(n);
    for (int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b; --a; --b;
        g[a].pb(b);
    }
    u.assign(n, 0);
    for (int i = 0; i < n; ++i)
        if (!u[i]) dfs(i);
    reverse(all(ord));
    t.resize(n);
    for (int i = 0; i < n; ++i)
        t[ord[i]] = i;
    for (int v = 0; v < n; ++v) {
        for (int to : g[v]) {
            if (t[v] > t[to]) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    u.assign(n, 0);
    for (int i = 0; i < n; ++i) {
        if (!u[i]) {
            s += 'A'; ++k;
            dfs(i);
        }
        else
            s += 'E';
    }
    cout << k << endl;
    cout << s << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb  push_back
#define ll  long long
#define vi  vector<int>
#define vvi vector<vi >
#define all(x) x.begin(), x.end()

int n, m, k;
vvi g, h;
vi  u, ord, t;
string s;

void dfs(int v) {
    u[v] = 1;
    for (auto to : h[v])
        if (!u[to])
            dfs(to);
    ord.pb(v);
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m;
    h.resize(n);
    g.resize(n);
    for (int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b; --a; --b;
        h[b].pb(a);
        if (a > b) swap(a, b);
        g[b].pb(a);
    }
    u.assign(n, 0);
    for (int i = 0; i < n; ++i)
        if (!u[i]) dfs(i);
    reverse(all(ord));
    t.resize(n);
    for (int i = 0; i < n; ++i)
        t[ord[i]] = i;
    for (int v = 0; v < n; ++v) {
        for (int to : h[v]) {
            if (t[v] > t[to]) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        if (g[i].empty()) {
            s += 'A';
            ++k;
        }
        else
            s += 'E';
    }
    cout << k << endl;
    cout << s << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb  push_back
#define ll  long long
#define vi  vector<int>
#define vvi vector<vi >
#define all(x) x.begin(), x.end()

int n, m, k;
vvi g;
vi  u, ord, t;
string s;

void dfs(int v) {
    u[v] = 1;
    for (auto to : g[v])
        if (!u[to])
            dfs(to);
    ord.pb(v);
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m;
    g.resize(n);
    for (int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b; --a; --b;
        g[b].pb(a);
    }
    u.assign(n, 0);
    for (int i = 0; i < n; ++i)
        if (!u[i]) dfs(i);
    reverse(all(ord));
    t.resize(n);
    for (int i = 0; i < n; ++i)
        t[ord[i]] = i;
    for (int v = 0; v < n; ++v) {
        for (int to : g[v]) {
            if (t[v] > t[to]) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        if (g[i].empty()) {
            s += 'A';
            ++k;
        }
        else
            s += 'E';
    }
    cout << k << endl;
    cout << s << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb  push_back
#define ll  long long
#define vi  vector<int>
#define vvi vector<vi >
#define all(x) x.begin(), x.end()

int n, m, k;
vvi g;
vi  u, ord, t;
string s;

void dfs(int v) {
    u[v] = 1;
    for (auto to : g[v])
        if (!u[to])
            dfs(to);
    ord.pb(v);
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m;
    g.resize(n);
    for (int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b; --a; --b;
        if (a > b) swap(a, b);
        g[b].pb(a);
    }
    u.assign(n, 0);
    for (int i = 0; i < n; ++i)
        if (!u[i]) dfs(i);
    reverse(all(ord));
    t.resize(n);
    for (int i = 0; i < n; ++i)
        t[ord[i]] = i;
    for (int v = 0; v < n; ++v) {
        for (int to : g[v]) {
            if (t[v] > t[to]) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        if (g[i].empty())
            s += 'A', ++k;
        else
            s += 'E';
    }
    cout << k << endl;
    cout << s << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vd> vvd;
const int mod = 1000000007;
const vi mods = {998244353,1000000007,1000000009};
const ll inf = 3e18;
const double pi = acos(-1.0);
const double eps = 0.0000001;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define trav(a,x) for(auto&a:x)
#define all(x) begin(x),end(x)
#define sz(x) ((int)(x).size())
#define fll(xs,x,a) fill(&x,&x+sizeof(xs)/sizeof(x)-1,a)//fll(dp,dp[0][0],inf)
#define has(x,a) (x.find(a)!=end(x))
#define pc(x) __builtin_popcountll(x)
#define pb push_back
#define fi first
#define se second
template<class...K> using umap = unordered_map<K...>;
template<class...K> using uset = unordered_set<K...>;

const int N=200100;
ll n,m,dead[N],deg[N],vis[N][10];
umap<ll,vll>g;
umap<ll,vl>r;
queue<ll>q;

void ff(ll x,ll p,ll dir){
  if(vis[x][dir+5])return;
  dead[x]=1;
  vis[x][dir+5]=1;
  trav(nx,g[x]){
    if(nx.fi==p||nx.se!=dir)continue;
    ff(nx.fi,x,dir);
  }
}

void solve(int _t){

  cin>>n>>m;
  rep(i,0,m){
    ll u,v;
    cin>>u>>v;
    u--;v--;
    r[u].pb(v);
    deg[v]++;
    g[u].pb({v,1});
    g[v].pb({u,-1});
  }
  rep(i,0,n)if(!deg[i])q.push(i);
  ll seen=0;
  while(sz(q)){
    ll node=q.front();q.pop();
    seen++;
    trav(nx,r[node]){
      if(!--deg[nx])q.push(nx);
    }
  }
  if(seen!=n){
    cout<<"-1\n";
    return;
  }
  ll res=0;
  vl r;
  rep(i,0,n){
    res+=!dead[i];
    r.pb(!dead[i]);
    ff(i,-1,1);
    ff(i,-1,-1);
  }
  cout<<res<<"\n";
  rep(i,0,sz(r))cout<<(r[i]?"A":"E");
  cout<<"\n";
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cout.precision(13);
  int t=1;
  while(t--)solve(t);
  return 0;
}


  #include <bits/stdc++.h>
  using namespace std;
  typedef long long ll;
  typedef long double ld;
  typedef pair<int,int> pii;
  typedef pair<ll,ll> pll;
  typedef pair<double,double> pdd;
  typedef vector<int> vi;
  typedef vector<ll> vl;
  typedef vector<double> vd;
  typedef vector<string> vs;
  typedef vector<pii> vii;
  typedef vector<pll> vll;
  typedef vector<pdd> vdd;
  typedef vector<vi> vvi;
  typedef vector<vl> vvl;
  typedef vector<vd> vvd;
  const int mod = 1000000007;
  const vi mods = {998244353,1000000007,1000000009};
  const ll inf = 3e18;
  const double pi = acos(-1.0);
  const double eps = 0.0000001;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  #define rep(i,a,b) for(int i=(a);i<(b);++i)
  #define trav(a,x) for(auto&a:x)
  #define all(x) begin(x),end(x)
  #define sz(x) ((int)(x).size())
  #define fll(xs,x,a) fill(&x,&x+sizeof(xs)/sizeof(x)-1,a)//fll(dp,dp[0][0],inf)
  #define has(x,a) (x.find(a)!=end(x))
  #define pc(x) __builtin_popcountll(x)
  #define pb push_back
  #define fi first
  #define se second
  template<class...K> using umap = unordered_map<K...>;
  template<class...K> using uset = unordered_set<K...>;

  const int N=200100;
  int n,m,dead[N],deg[N],vis[2*N],q[N],sq,eq;
  vector<array<int,2>> g[N];
  vector<int> r[N];
  bool wk;

  void ff(int x,int p,int dir){
    int vx=x+N*(dir==1);
    if(vis[vx])return;
    vis[vx]=1;
    if(p!=-1)dead[x]=1;
    trav(nx,g[x]){
      if(nx[0]==p||nx[1]!=dir)continue;
      ff(nx[0],x,dir);
    }
  }

  void solve(int _t){

    wk=1;
    cin>>n>>m;
    rep(i,0,m){
      int u,v;
      cin>>u>>v;
      u--;v--;
      r[u].pb(v);
      deg[v]++;
      dead[max(u,v)]=1;
      g[u].pb({v,1});
      g[v].pb({u,-1});
    }
    rep(i,0,n){
      if(!deg[i])q[eq++]=i;
    }
    int seen=0;
    while(sq<eq){
      int node=q[sq++];
      seen++;
      trav(nx,r[node]){
        if(!--deg[nx])q[eq++]=nx;
      }
    }
    if(seen!=n){
      cout<<"-1\n";
      return;
    }
    int res=0;
    rep(i,0,n){
      res+=!dead[i];
      ff(i,-1,1);
      ff(i,-1,-1);
    }
    cout<<res<<'\n';
    rep(i,0,n)cout<<(dead[i]?'E':'A');
  }

  int main() {
    cin.tie(0)->sync_with_stdio(0);
    cout.precision(13);
    int t=1;
    while(t--)solve(t);
    return 0;
  }


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vd> vvd;
const int mod = 1000000007;
const vi mods = {998244353,1000000007,1000000009};
const ll inf = 3e18;
const double pi = acos(-1.0);
const double eps = 0.0000001;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define trav(a,x) for(auto&a:x)
#define all(x) begin(x),end(x)
#define sz(x) ((int)(x).size())
#define fll(xs,x,a) fill(&x,&x+sizeof(xs)/sizeof(x)-1,a)//fll(dp,dp[0][0],inf)
#define has(x,a) (x.find(a)!=end(x))
#define pc(x) __builtin_popcountll(x)
#define pb push_back
#define fi first
#define se second
template<class...K> using umap = unordered_map<K...>;
template<class...K> using uset = unordered_set<K...>;

const int N=200100;
ll n,m,dead[N],deg[N],vis[N][10];
umap<ll,vll>g;
umap<ll,vl>r;
queue<ll>q;

void ff(ll x,ll p,ll dir){
  if(vis[x][dir+5])return;
  dead[x]=1;
  vis[x][dir+5]=1;
  trav(nx,g[x]){
    if(nx.fi==p||nx.se!=dir)continue;
    ff(nx.fi,x,dir);
  }
}

void solve(int _t){

  cin>>n>>m;
  rep(i,0,m){
    ll u,v;
    cin>>u>>v;
    u--;v--;
    r[u].pb(v);
    deg[v]++;
    g[u].pb({v,1});
    g[v].pb({u,-1});
  }
  rep(i,0,n)if(!deg[i])q.push(i);
  ll seen=0;
  while(sz(q)){
    ll node=q.front();q.pop();
    seen++;
    trav(nx,r[node]){
      if(!--deg[nx])q.push(nx);
    }
  }
  if(seen!=n){
    cout<<"-1\n";
    return;
  }
  ll res=0;
  vl r;
  rep(i,0,n){
    res+=!dead[i];
    r.pb(!dead[i]);
    if(!dead[i]){
      ff(i,-1,1);
      ff(i,-1,-1);
    }
  }
  cout<<res<<"\n";
  rep(i,0,sz(r))cout<<(r[i]?"A":"E");
  cout<<"\n";
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cout.precision(13);
  int t=1;
  while(t--)solve(t);
  return 0;
}


  #include <bits/stdc++.h>
  using namespace std;
  typedef long long ll;
  typedef long double ld;
  typedef pair<int,int> pii;
  typedef pair<ll,ll> pll;
  typedef pair<double,double> pdd;
  typedef vector<int> vi;
  typedef vector<ll> vl;
  typedef vector<double> vd;
  typedef vector<string> vs;
  typedef vector<pii> vii;
  typedef vector<pll> vll;
  typedef vector<pdd> vdd;
  typedef vector<vi> vvi;
  typedef vector<vl> vvl;
  typedef vector<vd> vvd;
  const int mod = 1000000007;
  const vi mods = {998244353,1000000007,1000000009};
  const ll inf = 3e18;
  const double pi = acos(-1.0);
  const double eps = 0.0000001;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  #define rep(i,a,b) for(int i=(a);i<(b);++i)
  #define trav(a,x) for(auto&a:x)
  #define all(x) begin(x),end(x)
  #define sz(x) ((int)(x).size())
  #define fll(xs,x,a) fill(&x,&x+sizeof(xs)/sizeof(x)-1,a)//fll(dp,dp[0][0],inf)
  #define has(x,a) (x.find(a)!=end(x))
  #define pc(x) __builtin_popcountll(x)
  #define pb push_back
  #define fi first
  #define se second
  template<class...K> using umap = unordered_map<K...>;
  template<class...K> using uset = unordered_set<K...>;

  const int N=200100;
  int n,m,dead[N],deg[N],vis[N][5],q[N],sq,eq;
  vector<int> g[N][2];
  vector<int> r[N];

  void ff(int x,int p,int dir){
    if(vis[x][dir+1])return;
    vis[x][dir+1]=1;
    if(p!=-1)dead[x]=1;
    trav(nx,g[x]){
      if(nx[0]==p||nx[1]!=dir)continue;
      ff(nx[0],x,dir);
    }
  }

  void solve(int _t){

    cin>>n>>m;
    rep(i,0,m){
      int u,v;
      cin>>u>>v;
      u--;v--;
      r[u].pb(v);
      deg[v]++;
      g[u][1].pb(v);
      g[v][0].pb(u);
    }
    rep(i,0,n){
      if(!deg[i])q[eq++]=i;
    }
    int seen=0;
    while(sq<eq){
      int node=q[sq++];
      seen++;
      trav(nx,r[node]){
        if(!--deg[nx])q[eq++]=nx;
      }
    }
    if(seen!=n){
      cout<<"-1\n";
      return;
    }
    int res=0;
    rep(i,0,n){
      res+=!dead[i];
      ff(i,-1,1);
      ff(i,-1,-1);
    }
    cout<<res<<'\n';
    rep(i,0,n)cout<<(dead[i]?'E':'A');
  }

  int main() {
    cin.tie(0)->sync_with_stdio(0);
    cout.precision(13);
    int t=1;
    while(t--)solve(t);
    return 0;
  }


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vd> vvd;
const int mod = 1000000007;
const vi mods = {998244353,1000000007,1000000009};
const ll inf = 3e18;
const double pi = acos(-1.0);
const double eps = 0.0000001;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define trav(a,x) for(auto&a:x)
#define all(x) begin(x),end(x)
#define sz(x) ((int)(x).size())
#define fll(xs,x,a) fill(&x,&x+sizeof(xs)/sizeof(x)-1,a)//fll(dp,dp[0][0],inf)
#define has(x,a) (x.find(a)!=end(x))
#define pc(x) __builtin_popcountll(x)
#define pb push_back
#define fi first
#define se second
template<class...K> using umap = unordered_map<K...>;
template<class...K> using uset = unordered_set<K...>;

const int N=200100;
ll n,m,dead[N],deg[N];
umap<ll,vll>g;
umap<ll,vl>r;
queue<ll>q;
bool wk;

void ff(ll x,ll p,ll dir){
  dead[x]=1;
  trav(nx,g[x]){
    if(nx.fi==p||nx.se!=dir)continue;
    ff(nx.fi,x,dir);
  }
}

void solve(int _t){

  wk=1;
  cin>>n>>m;
  rep(i,0,m){
    ll u,v;
    cin>>u>>v;
    u--;v--;
    r[u].pb(v);
    deg[v]++;
    dead[max(u,v)]=1;
    g[u].pb({v,1});
    g[v].pb({u,-1});
  }
  rep(i,0,n){
    if(!deg[i])q.push(i);
  }
  ll seen=0;
  while(sz(q)){
    ll node=q.front();q.pop();
    seen++;
    trav(nx,r[node]){
      if(!--deg[nx])q.push(nx);
    }
  }
  if(seen!=n){
    cout<<"-1\n";
    return;
  }
  ll res=0;
  vl r;
  rep(i,0,n){
    res+=!dead[i];
    r.pb(!dead[i]);
    ff(i,-1,1);
    ff(i,-1,-1);
  }
  cout<<res<<"\n";
  rep(i,0,sz(r))cout<<(r[i]?"A":"E");
  cout<<"\n";
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cout.precision(13);
  int t=1;
  while(t--)solve(t);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vd> vvd;
const int mod = 1000000007;
const vi mods = {998244353,1000000007,1000000009};
const ll inf = 3e18;
const double pi = acos(-1.0);
const double eps = 0.0000001;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define trav(a,x) for(auto&a:x)
#define all(x) begin(x),end(x)
#define sz(x) ((int)(x).size())
#define fll(xs,x,a) fill(&x,&x+sizeof(xs)/sizeof(x)-1,a)//fll(dp,dp[0][0],inf)
#define has(x,a) (x.find(a)!=end(x))
#define pc(x) __builtin_popcountll(x)
#define pb push_back
#define fi first
#define se second
template<class...K> using umap = unordered_map<K...>;
template<class...K> using uset = unordered_set<K...>;

const int N=200100;
ll n,m,dead[N],deg[N],vis[N][5];
umap<ll,vll>g;
umap<ll,vl>r;
queue<ll>q;
bool wk;

void ff(ll x,ll p,ll dir){
  if(vis[x][dir+1])return;
  vis[x][dir+1]=1;
  dead[x]=1;
  trav(nx,g[x]){
    if(nx.fi==p||nx.se!=dir)continue;
    ff(nx.fi,x,dir);
  }
}

void solve(int _t){

  wk=1;
  cin>>n>>m;
  rep(i,0,m){
    ll u,v;
    cin>>u>>v;
    u--;v--;
    r[u].pb(v);
    deg[v]++;
    dead[max(u,v)]=1;
    g[u].pb({v,1});
    g[v].pb({u,-1});
  }
  rep(i,0,n){
    if(!deg[i])q.push(i);
  }
  ll seen=0;
  while(sz(q)){
    ll node=q.front();q.pop();
    seen++;
    trav(nx,r[node]){
      if(!--deg[nx])q.push(nx);
    }
  }
  if(seen!=n){
    cout<<"-1\n";
    return;
  }
  ll res=0;
  vl r;
  rep(i,0,n){
    res+=!dead[i];
    r.pb(!dead[i]);
    ff(i,-1,1);
    ff(i,-1,-1);
  }
  cout<<res<<"\n";
  rep(i,0,sz(r))cout<<(r[i]?"A":"E");
  cout<<"\n";
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cout.precision(13);
  int t=1;
  while(t--)solve(t);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vd> vvd;
const int mod = 1000000007;
const vi mods = {998244353,1000000007,1000000009};
const ll inf = 3e18;
const double pi = acos(-1.0);
const double eps = 0.0000001;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define trav(a,x) for(auto&a:x)
#define all(x) begin(x),end(x)
#define sz(x) ((int)(x).size())
#define fll(xs,x,a) fill(&x,&x+sizeof(xs)/sizeof(x)-1,a)//fll(dp,dp[0][0],inf)
#define has(x,a) (x.find(a)!=end(x))
#define pc(x) __builtin_popcountll(x)
#define pb push_back
#define fi first
#define se second
template<class...K> using umap = unordered_map<K...>;
template<class...K> using uset = unordered_set<K...>;

const int N=200100;
ll n,m,dead[N],deg[N],vis[N][2];
umap<ll,vll>g;
umap<ll,vl>r;
queue<ll>q;
bool wk;

void ff(ll x,ll p,ll dir){
  if(vis[x][!dir])return;
  vis[x][!dir]=1;
  dead[x]=1;
  trav(nx,g[x]){
    if(nx.fi==p||nx.se!=dir)continue;
    ff(nx.fi,x,dir);
  }
}

void solve(int _t){

  wk=1;
  cin>>n>>m;
  rep(i,0,m){
    ll u,v;
    cin>>u>>v;
    u--;v--;
    r[u].pb(v);
    deg[v]++;
    dead[max(u,v)]=1;
    g[u].pb({v,1});
    g[v].pb({u,-1});
  }
  rep(i,0,n){
    if(!deg[i])q.push(i);
  }
  ll seen=0;
  while(sz(q)){
    ll node=q.front();q.pop();
    seen++;
    trav(nx,r[node]){
      if(!--deg[nx])q.push(nx);
    }
  }
  if(seen!=n){
    cout<<"-1\n";
    return;
  }
  ll res=0;
  vl r;
  rep(i,0,n){
    res+=!dead[i];
    r.pb(!dead[i]);
    ff(i,-1,1);
    ff(i,-1,-1);
  }
  cout<<res<<"\n";
  rep(i,0,sz(r))cout<<(r[i]?"A":"E");
  cout<<"\n";
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cout.precision(13);
  int t=1;
  while(t--)solve(t);
  return 0;
}


  #include <bits/stdc++.h>
  using namespace std;
  typedef long long ll;
  typedef long double ld;
  typedef pair<int,int> pii;
  typedef pair<ll,ll> pll;
  typedef pair<double,double> pdd;
  typedef vector<int> vi;
  typedef vector<ll> vl;
  typedef vector<double> vd;
  typedef vector<string> vs;
  typedef vector<pii> vii;
  typedef vector<pll> vll;
  typedef vector<pdd> vdd;
  typedef vector<vi> vvi;
  typedef vector<vl> vvl;
  typedef vector<vd> vvd;
  const int mod = 1000000007;
  const vi mods = {998244353,1000000007,1000000009};
  const ll inf = 3e18;
  const double pi = acos(-1.0);
  const double eps = 0.0000001;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  #define rep(i,a,b) for(int i=(a);i<(b);++i)
  #define trav(a,x) for(auto&a:x)
  #define all(x) begin(x),end(x)
  #define sz(x) ((int)(x).size())
  #define fll(xs,x,a) fill(&x,&x+sizeof(xs)/sizeof(x)-1,a)//fll(dp,dp[0][0],inf)
  #define has(x,a) (x.find(a)!=end(x))
  #define pc(x) __builtin_popcountll(x)
  #define pb push_back
  #define fi first
  #define se second
  template<class...K> using umap = unordered_map<K...>;
  template<class...K> using uset = unordered_set<K...>;

  const int N=200100;
  int n,m,dead[N],deg[N],vis[N][5],q[N],sq,eq;
  vector<array<int,2>> g[N];
  vector<int> r[N];
  bool wk;

  void ff(int x,int p,int dir){
    if(vis[x][dir+1])return;
    vis[x][dir+1]=1;
    dead[x]=1;
    trav(nx,g[x]){
      if(nx[0]==p||nx[1]!=dir)continue;
      ff(nx[0],x,dir);
    }
  }

  void solve(int _t){

    wk=1;
    cin>>n>>m;
    rep(i,0,m){
      int u,v;
      cin>>u>>v;
      u--;v--;
      r[u].pb(v);
      deg[v]++;
      dead[max(u,v)]=1;
      g[u].pb({v,1});
      g[v].pb({u,-1});
    }
    rep(i,0,n){
      if(!deg[i])q[eq++]=i;
    }
    int seen=0;
    while(sq<eq){
      int node=q[sq++];
      seen++;
      trav(nx,r[node]){
        if(!--deg[nx])q[eq++]=nx;
      }
    }
    if(seen!=n){
      cout<<"-1\n";
      return;
    }
    int res=0;
    vector<int> r;
    rep(i,0,n){
      res+=!dead[i];
      r.pb(!dead[i]);
      ff(i,-1,1);
      ff(i,-1,-1);
    }
    cout<<res<<"\n";
    rep(i,0,sz(r))cout<<(r[i]?"A":"E");
    cout<<"\n";
  }

  int main() {
    cin.tie(0)->sync_with_stdio(0);
    cout.precision(13);
    int t=1;
    while(t--)solve(t);
    return 0;
  }


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vd> vvd;
const int mod = 1000000007;
const vi mods = {998244353,1000000007,1000000009};
const ll inf = 3e18;
const double pi = acos(-1.0);
const double eps = 0.0000001;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define trav(a,x) for(auto&a:x)
#define all(x) begin(x),end(x)
#define sz(x) ((int)(x).size())
#define fll(xs,x,a) fill(&x,&x+sizeof(xs)/sizeof(x)-1,a)//fll(dp,dp[0][0],inf)
#define has(x,a) (x.find(a)!=end(x))
#define pc(x) __builtin_popcountll(x)
#define pb push_back
#define fi first
#define se second
template<class...K> using umap = unordered_map<K...>;
template<class...K> using uset = unordered_set<K...>;

const int N=200100;
int n,m,dead[N],deg[N],vis[N][5],q[N],sq,eq;
vector<pair<int,int>> g[N];
vector<int> r[N];
bool wk;

void ff(int x,int p,int dir){
  if(vis[x][dir+1])return;
  vis[x][dir+1]=1;
  dead[x]=1;
  trav(nx,g[x]){
    if(nx.fi==p||nx.se!=dir)continue;
    ff(nx.fi,x,dir);
  }
}

void solve(int _t){

  wk=1;
  cin>>n>>m;
  rep(i,0,m){
    int u,v;
    cin>>u>>v;
    u--;v--;
    r[u].pb(v);
    deg[v]++;
    dead[max(u,v)]=1;
    g[u].pb({v,1});
    g[v].pb({u,-1});
  }
  rep(i,0,n){
    if(!deg[i])q[eq++]=i;
  }
  int seen=0;
  while(sq<eq){
    int node=q[sq++];
    seen++;
    trav(nx,r[node]){
      if(!--deg[nx])q[eq++]=nx;
    }
  }
  if(seen!=n){
    cout<<"-1\n";
    return;
  }
  int res=0;
  vector<int> r;;
  rep(i,0,n){
    res+=!dead[i];
    r.pb(!dead[i]);
    ff(i,-1,1);
    ff(i,-1,-1);
  }
  cout<<res<<"\n";
  rep(i,0,sz(r))cout<<(r[i]?"A":"E");
  cout<<"\n";
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cout.precision(13);
  int t=1;
  while(t--)solve(t);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vd> vvd;
const int mod = 1000000007;
const vi mods = {998244353,1000000007,1000000009};
const ll inf = 3e18;
const double pi = acos(-1.0);
const double eps = 0.0000001;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define trav(a,x) for(auto&a:x)
#define all(x) begin(x),end(x)
#define sz(x) ((int)(x).size())
#define fll(xs,x,a) fill(&x,&x+sizeof(xs)/sizeof(x)-1,a)//fll(dp,dp[0][0],inf)
#define has(x,a) (x.find(a)!=end(x))
#define pc(x) __builtin_popcountll(x)
#define pb push_back
#define fi first
#define se second
template<class...K> using umap = unordered_map<K...>;
template<class...K> using uset = unordered_set<K...>;

const int N=200100;
ll n,m,dead[N],deg[N],vis[N][5];
vll g[N];
vl r[N];
queue<ll>q;
bool wk;

void ff(ll x,ll p,ll dir){
  if(vis[x][dir+1])return;
  vis[x][dir+1]=1;
  dead[x]=1;
  trav(nx,g[x]){
    if(nx.fi==p||nx.se!=dir)continue;
    ff(nx.fi,x,dir);
  }
}

void solve(int _t){

  wk=1;
  cin>>n>>m;
  rep(i,0,m){
    ll u,v;
    cin>>u>>v;
    u--;v--;
    r[u].pb(v);
    deg[v]++;
    dead[max(u,v)]=1;
    g[u].pb({v,1});
    g[v].pb({u,-1});
  }
  rep(i,0,n){
    if(!deg[i])q.push(i);
  }
  ll seen=0;
  while(sz(q)){
    ll node=q.front();q.pop();
    seen++;
    trav(nx,r[node]){
      if(!--deg[nx])q.push(nx);
    }
  }
  if(seen!=n){
    cout<<"-1\n";
    return;
  }
  ll res=0;
  vl r;
  rep(i,0,n){
    res+=!dead[i];
    r.pb(!dead[i]);
    ff(i,-1,1);
    ff(i,-1,-1);
  }
  cout<<res<<"\n";
  rep(i,0,sz(r))cout<<(r[i]?"A":"E");
  cout<<"\n";
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cout.precision(13);
  int t=1;
  while(t--)solve(t);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vd> vvd;
const int mod = 1000000007;
const vi mods = {998244353,1000000007,1000000009};
const ll inf = 3e18;
const double pi = acos(-1.0);
const double eps = 0.0000001;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define trav(a,x) for(auto&a:x)
#define all(x) begin(x),end(x)
#define sz(x) ((int)(x).size())
#define fll(xs,x,a) fill(&x,&x+sizeof(xs)/sizeof(x)-1,a)//fll(dp,dp[0][0],inf)
#define has(x,a) (x.find(a)!=end(x))
#define pc(x) __builtin_popcountll(x)
#define pb push_back
#define fi first
#define se second
template<class...K> using umap = unordered_map<K...>;
template<class...K> using uset = unordered_set<K...>;

const int N=200100;
ll n,m,dead[N],deg[N];
umap<ll,vll>g;
umap<ll,vl>r;
queue<ll>q;

void ff(ll x,ll p,ll dir){
  dead[x]=1;
  trav(nx,g[x]){
    if(nx.fi==p||nx.se!=dir)continue;
    ff(nx.fi,x,dir);
  }
}

void solve(int _t){

  cin>>n>>m;
  rep(i,0,m){
    ll u,v;
    cin>>u>>v;
    u--;v--;
    r[u].pb(v);
    deg[v]++;
    g[u].pb({v,1});
    g[v].pb({u,-1});
  }
  rep(i,0,n)if(!deg[i])q.push(i);
  ll seen=0;
  while(sz(q)){
    ll node=q.front();q.pop();
    seen++;
    trav(nx,r[node]){
      if(!--deg[nx])q.push(nx);
    }
  }
  if(seen!=n){
    cout<<"-1\n";
    return;
  }
  ll res=0;
  vl r;
  rep(i,0,n){
    res+=!dead[i];
    r.pb(!dead[i]);
    ff(i,-1,1);
    ff(i,-1,-1);
  }
  cout<<res<<"\n";
  rep(i,0,sz(r))cout<<(r[i]?"A":"E");
  cout<<"\n";
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cout.precision(13);
  int t=1;
  while(t--)solve(t);
  return 0;
}


  #include <bits/stdc++.h>
  using namespace std;
  typedef long long ll;
  typedef long double ld;
  typedef pair<int,int> pii;
  typedef pair<ll,ll> pll;
  typedef pair<double,double> pdd;
  typedef vector<int> vi;
  typedef vector<ll> vl;
  typedef vector<double> vd;
  typedef vector<string> vs;
  typedef vector<pii> vii;
  typedef vector<pll> vll;
  typedef vector<pdd> vdd;
  typedef vector<vi> vvi;
  typedef vector<vl> vvl;
  typedef vector<vd> vvd;
  const int mod = 1000000007;
  const vi mods = {998244353,1000000007,1000000009};
  const ll inf = 3e18;
  const double pi = acos(-1.0);
  const double eps = 0.0000001;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  #define rep(i,a,b) for(int i=(a);i<(b);++i)
  #define trav(a,x) for(auto&a:x)
  #define all(x) begin(x),end(x)
  #define sz(x) ((int)(x).size())
  #define fll(xs,x,a) fill(&x,&x+sizeof(xs)/sizeof(x)-1,a)//fll(dp,dp[0][0],inf)
  #define has(x,a) (x.find(a)!=end(x))
  #define pc(x) __builtin_popcountll(x)
  #define pb push_back
  #define fi first
  #define se second
  template<class...K> using umap = unordered_map<K...>;
  template<class...K> using uset = unordered_set<K...>;

  const int N=200100;
  int n,m,dead[N],deg[N],vis[N][5],q[N],sq,eq;
  vector<int> g[N][2];
  vector<int> r[N];

  void ff(int x,int p,int dir){
    if(vis[x][dir+1])return;
    vis[x][dir+1]=1;
    if(p!=-1)dead[x]=1;
    trav(nx,g[x][dir]){
      ff(nx,x,dir);
    }
  }

  void solve(int _t){

    cin>>n>>m;
    rep(i,0,m){
      int u,v;
      cin>>u>>v;
      u--;v--;
      r[u].pb(v);
      deg[v]++;
      g[u][1].pb(v);
      g[v][0].pb(u);
    }
    rep(i,0,n){
      if(!deg[i])q[eq++]=i;
    }
    int seen=0;
    while(sq<eq){
      int node=q[sq++];
      seen++;
      trav(nx,r[node]){
        if(!--deg[nx])q[eq++]=nx;
      }
    }
    if(seen!=n){
      cout<<"-1\n";
      return;
    }
    int res=0;
    rep(i,0,n){
      res+=!dead[i];
      ff(i,1);
      ff(i,0);
    }
    cout<<res<<'\n';
    rep(i,0,n)cout<<(dead[i]?'E':'A');
  }

  int main() {
    cin.tie(0)->sync_with_stdio(0);
    cout.precision(13);
    int t=1;
    while(t--)solve(t);
    return 0;
  }


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vd> vvd;
const int mod = 1000000007;
const vi mods = {998244353,1000000007,1000000009};
const ll inf = 3e18;
const double pi = acos(-1.0);
const double eps = 0.0000001;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define trav(a,x) for(auto&a:x)
#define all(x) begin(x),end(x)
#define sz(x) ((int)(x).size())
#define fll(xs,x,a) fill(&x,&x+sizeof(xs)/sizeof(x)-1,a)//fll(dp,dp[0][0],inf)
#define has(x,a) (x.find(a)!=end(x))
#define pc(x) __builtin_popcountll(x)
#define pb push_back
#define fi first
#define se second
template<class...K> using umap = unordered_map<K...>;
template<class...K> using uset = unordered_set<K...>;

const int N=200100;
ll n,m,dead[N],deg[N],vis[N][5];
vll g[N];
umap<ll,vl>r;
queue<ll>q;
bool wk;

void ff(ll x,ll p,ll dir){
  if(vis[x][dir+1])return;
  vis[x][dir+1]=1;
  dead[x]=1;
  trav(nx,g[x]){
    if(nx.fi==p||nx.se!=dir)continue;
    ff(nx.fi,x,dir);
  }
}

void solve(int _t){

  wk=1;
  cin>>n>>m;
  rep(i,0,m){
    ll u,v;
    cin>>u>>v;
    u--;v--;
    r[u].pb(v);
    deg[v]++;
    dead[max(u,v)]=1;
    g[u].pb({v,1});
    g[v].pb({u,-1});
  }
  rep(i,0,n){
    if(!deg[i])q.push(i);
  }
  ll seen=0;
  while(sz(q)){
    ll node=q.front();q.pop();
    seen++;
    trav(nx,r[node]){
      if(!--deg[nx])q.push(nx);
    }
  }
  if(seen!=n){
    cout<<"-1\n";
    return;
  }
  ll res=0;
  vl r;
  rep(i,0,n){
    res+=!dead[i];
    r.pb(!dead[i]);
    ff(i,-1,1);
    ff(i,-1,-1);
  }
  cout<<res<<"\n";
  rep(i,0,sz(r))cout<<(r[i]?"A":"E");
  cout<<"\n";
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cout.precision(13);
  int t=1;
  while(t--)solve(t);
  return 0;
}


  #include <bits/stdc++.h>
  using namespace std;
  typedef long long ll;
  typedef long double ld;
  typedef pair<int,int> pii;
  typedef pair<ll,ll> pll;
  typedef pair<double,double> pdd;
  typedef vector<int> vi;
  typedef vector<ll> vl;
  typedef vector<double> vd;
  typedef vector<string> vs;
  typedef vector<pii> vii;
  typedef vector<pll> vll;
  typedef vector<pdd> vdd;
  typedef vector<vi> vvi;
  typedef vector<vl> vvl;
  typedef vector<vd> vvd;
  const int mod = 1000000007;
  const vi mods = {998244353,1000000007,1000000009};
  const ll inf = 3e18;
  const double pi = acos(-1.0);
  const double eps = 0.0000001;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  #define rep(i,a,b) for(int i=(a);i<(b);++i)
  #define trav(a,x) for(auto&a:x)
  #define all(x) begin(x),end(x)
  #define sz(x) ((int)(x).size())
  #define fll(xs,x,a) fill(&x,&x+sizeof(xs)/sizeof(x)-1,a)//fll(dp,dp[0][0],inf)
  #define has(x,a) (x.find(a)!=end(x))
  #define pc(x) __builtin_popcountll(x)
  #define pb push_back
  #define fi first
  #define se second
  template<class...K> using umap = unordered_map<K...>;
  template<class...K> using uset = unordered_set<K...>;

  const int N=200100;
  int n,m,dead[N],deg[N],vis[N][5],q[N],sq,eq;
  vector<int> g[N][2];
  vector<int> r[N];

  void ff(int x,int p,int dir){
    if(vis[x][dir+1])return;
    vis[x][dir+1]=1;
    if(p!=-1)dead[x]=1;
    trav(nx,g[x][dir]){
      ff(nx,x,dir);
    }
  }

  void solve(int _t){

    cin>>n>>m;
    rep(i,0,m){
      int u,v;
      cin>>u>>v;
      u--;v--;
      r[u].pb(v);
      deg[v]++;
      g[u][1].pb(v);
      g[v][0].pb(u);
    }
    rep(i,0,n){
      if(!deg[i])q[eq++]=i;
    }
    int seen=0;
    while(sq<eq){
      int node=q[sq++];
      seen++;
      trav(nx,r[node]){
        if(!--deg[nx])q[eq++]=nx;
      }
    }
    if(seen!=n){
      cout<<"-1\n";
      return;
    }
    int res=0;
    rep(i,0,n){
      res+=!dead[i];
      ff(i,-1,1);
      ff(i,-1,0);
    }
    cout<<res<<'\n';
    rep(i,0,n)cout<<(dead[i]?'E':'A');
  }

  int main() {
    cin.tie(0)->sync_with_stdio(0);
    cout.precision(13);
    int t=1;
    while(t--)solve(t);
    return 0;
  }


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vd> vvd;
const int mod = 1000000007;
const vi mods = {998244353,1000000007,1000000009};
const ll inf = 3e18;
const double pi = acos(-1.0);
const double eps = 0.0000001;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define trav(a,x) for(auto&a:x)
#define all(x) begin(x),end(x)
#define sz(x) ((int)(x).size())
#define fll(xs,x,a) fill(&x,&x+sizeof(xs)/sizeof(x)-1,a)//fll(dp,dp[0][0],inf)
#define has(x,a) (x.find(a)!=end(x))
#define pc(x) __builtin_popcountll(x)
#define pb push_back
#define fi first
#define se second
template<class...K> using umap = unordered_map<K...>;
template<class...K> using uset = unordered_set<K...>;

const int N=200100;
ll n,m,dead[N],deg[N],vis[N][5],q[N],sq,eq;
vll g[N];
vl r[N];
bool wk;

void ff(ll x,ll p,ll dir){
  if(vis[x][dir+1])return;
  vis[x][dir+1]=1;
  dead[x]=1;
  trav(nx,g[x]){
    if(nx.fi==p||nx.se!=dir)continue;
    ff(nx.fi,x,dir);
  }
}

void solve(int _t){

  wk=1;
  cin>>n>>m;
  rep(i,0,m){
    ll u,v;
    cin>>u>>v;
    u--;v--;
    r[u].pb(v);
    deg[v]++;
    dead[max(u,v)]=1;
    g[u].pb({v,1});
    g[v].pb({u,-1});
  }
  rep(i,0,n){
    if(!deg[i])q[eq++]=i;
  }
  ll seen=0;
  while(sq<eq){
    ll node=q[sq++];
    seen++;
    trav(nx,r[node]){
      if(!--deg[nx])q[eq++]=nx;
    }
  }
  if(seen!=n){
    cout<<"-1\n";
    return;
  }
  ll res=0;
  vl r;
  rep(i,0,n){
    res+=!dead[i];
    r.pb(!dead[i]);
    ff(i,-1,1);
    ff(i,-1,-1);
  }
  cout<<res<<"\n";
  rep(i,0,sz(r))cout<<(r[i]?"A":"E");
  cout<<"\n";
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cout.precision(13);
  int t=1;
  while(t--)solve(t);
  return 0;
}


  #include <bits/stdc++.h>
  using namespace std;
  typedef long long ll;
  typedef long double ld;
  typedef pair<int,int> pii;
  typedef pair<ll,ll> pll;
  typedef pair<double,double> pdd;
  typedef vector<int> vi;
  typedef vector<ll> vl;
  typedef vector<double> vd;
  typedef vector<string> vs;
  typedef vector<pii> vii;
  typedef vector<pll> vll;
  typedef vector<pdd> vdd;
  typedef vector<vi> vvi;
  typedef vector<vl> vvl;
  typedef vector<vd> vvd;
  const int mod = 1000000007;
  const vi mods = {998244353,1000000007,1000000009};
  const ll inf = 3e18;
  const double pi = acos(-1.0);
  const double eps = 0.0000001;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  #define rep(i,a,b) for(int i=(a);i<(b);++i)
  #define trav(a,x) for(auto&a:x)
  #define all(x) begin(x),end(x)
  #define sz(x) ((int)(x).size())
  #define fll(xs,x,a) fill(&x,&x+sizeof(xs)/sizeof(x)-1,a)//fll(dp,dp[0][0],inf)
  #define has(x,a) (x.find(a)!=end(x))
  #define pc(x) __builtin_popcountll(x)
  #define pb push_back
  #define fi first
  #define se second
  template<class...K> using umap = unordered_map<K...>;
  template<class...K> using uset = unordered_set<K...>;

  const int N=200100;
  int n,m,dead[N],deg[N],vis[N][5],q[N],sq,eq;
  vector<array<int,2>> g[N];
  vector<int> r[N];
  bool wk;

  void ff(int x,int p,int dir){
    if(vis[x][dir+1])return;
    vis[x][dir+1]=1;
    if(p!=-1)dead[x]=1;
    trav(nx,g[x]){
      if(nx[0]==p||nx[1]!=dir)continue;
      ff(nx[0],x,dir);
    }
  }

  void solve(int _t){

    wk=1;
    cin>>n>>m;
    rep(i,0,m){
      int u,v;
      cin>>u>>v;
      u--;v--;
      r[u].pb(v);
      deg[v]++;
      dead[max(u,v)]=1;
      g[u].pb({v,1});
      g[v].pb({u,-1});
    }
    rep(i,0,n){
      if(!deg[i])q[eq++]=i;
    }
    int seen=0;
    while(sq<eq){
      int node=q[sq++];
      seen++;
      trav(nx,r[node]){
        if(!--deg[nx])q[eq++]=nx;
      }
    }
    if(seen!=n){
      cout<<'-1\n';
      return;
    }
    int res=0;
    rep(i,0,n){
      res+=!dead[i];
      ff(i,-1,1);
      ff(i,-1,-1);
    }
    cout<<res<<'\n';
    rep(i,0,n)cout<<(dead[i]?'E':'A');
  }

  int main() {
    cin.tie(0)->sync_with_stdio(0);
    cout.precision(13);
    int t=1;
    while(t--)solve(t);
    return 0;
  }


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vd> vvd;
const int mod = 1000000007;
const vi mods = {998244353,1000000007,1000000009};
const ll inf = 3e18;
const double pi = acos(-1.0);
const double eps = 0.0000001;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define trav(a,x) for(auto&a:x)
#define all(x) begin(x),end(x)
#define sz(x) ((int)(x).size())
#define fll(xs,x,a) fill(&x,&x+sizeof(xs)/sizeof(x)-1,a)//fll(dp,dp[0][0],inf)
#define has(x,a) (x.find(a)!=end(x))
#define pc(x) __builtin_popcountll(x)
#define pb push_back
#define fi first
#define se second
template<class...K> using umap = unordered_map<K...>;
template<class...K> using uset = unordered_set<K...>;

const int N=200100;
int n,m,dead[N],deg[N],vis[N][5],q[N],sq,eq;
vector<pair<int,int>> g[N];
vector<int> r[N];
bool wk;

void ff(int x,int p,int dir){
  if(vis[x][dir+1])return;
  vis[x][dir+1]=1;
  dead[x]=1;
  trav(nx,g[x]){
    if(nx.fi==p||nx.se!=dir)continue;
    ff(nx.fi,x,dir);
  }
}

void solve(int _t){

  wk=1;
  cin>>n>>m;
  rep(i,0,m){
    int u,v;
    cin>>u>>v;
    u--;v--;
    r[u].pb(v);
    deg[v]++;
    dead[max(u,v)]=1;
    g[u].pb({v,1});
    g[v].pb({u,-1});
  }
  rep(i,0,n){
    if(!deg[i])q[eq++]=i;
  }
  int seen=0;
  while(sq<eq){
    int node=q[sq++];
    seen++;
    trav(nx,r[node]){
      if(!--deg[nx])q[eq++]=nx;
    }
  }
  if(seen!=n){
    cout<<"-1\n";
    return;
  }
  int res=0;
  vector<int> r;
  rep(i,0,n){
    res+=!dead[i];
    r.pb(!dead[i]);
    ff(i,-1,1);
    ff(i,-1,-1);
  }
  cout<<res<<"\n";
  rep(i,0,sz(r))cout<<(r[i]?"A":"E");
  cout<<"\n";
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cout.precision(13);
  int t=1;
  while(t--)solve(t);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vd> vvd;
const int mod = 1000000007;
const vi mods = {998244353,1000000007,1000000009};
const ll inf = 3e18;
const double pi = acos(-1.0);
const double eps = 0.0000001;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i,a,b) for(short i=(a);i<(b);++i)
#define trav(a,x) for(auto&a:x)
#define all(x) begin(x),end(x)
#define sz(x) ((int)(x).size())
#define fll(xs,x,a) fill(&x,&x+sizeof(xs)/sizeof(x)-1,a)//fll(dp,dp[0][0],inf)
#define has(x,a) (x.find(a)!=end(x))
#define pc(x) __builtin_popcountll(x)
#define pb push_back
#define fi first
#define se second
template<class...K> using umap = unordered_map<K...>;
template<class...K> using uset = unordered_set<K...>;

const int N=200100;
short n,m,dead[N],deg[N],vis[N][5],q[N],sq,eq;
vector<pair<short,short>> g[N];
vector<short> r[N];
bool wk;

void ff(short x,short p,short dir){
  if(vis[x][dir+1])return;
  vis[x][dir+1]=1;
  dead[x]=1;
  trav(nx,g[x]){
    if(nx.fi==p||nx.se!=dir)continue;
    ff(nx.fi,x,dir);
  }
}

void solve(int _t){

  wk=1;
  cin>>n>>m;
  rep(i,0,m){
    short u,v;
    cin>>u>>v;
    u--;v--;
    r[u].pb(v);
    deg[v]++;
    dead[max(u,v)]=1;
    g[u].pb({v,1});
    g[v].pb({u,-1});
  }
  rep(i,0,n){
    if(!deg[i])q[eq++]=i;
  }
  short seen=0;
  while(sq<eq){
    short node=q[sq++];
    seen++;
    trav(nx,r[node]){
      if(!--deg[nx])q[eq++]=nx;
    }
  }
  if(seen!=n){
    cout<<"-1\n";
    return;
  }
  short res=0;
  vector<short> r;
  rep(i,0,n){
    res+=!dead[i];
    r.pb(!dead[i]);
    ff(i,-1,1);
    ff(i,-1,-1);
  }
  cout<<res<<"\n";
  rep(i,0,sz(r))cout<<(r[i]?"A":"E");
  cout<<"\n";
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cout.precision(13);
  int t=1;
  while(t--)solve(t);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vd> vvd;
const int mod = 1000000007;
const vi mods = {998244353,1000000007,1000000009};
const ll inf = 3e18;
const double pi = acos(-1.0);
const double eps = 0.0000001;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i,a,b) for(signed short i=(a);i<(b);++i)
#define trav(a,x) for(auto&a:x)
#define all(x) begin(x),end(x)
#define sz(x) ((int)(x).size())
#define fll(xs,x,a) fill(&x,&x+sizeof(xs)/sizeof(x)-1,a)//fll(dp,dp[0][0],inf)
#define has(x,a) (x.find(a)!=end(x))
#define pc(x) __builtin_popcountll(x)
#define pb push_back
#define fi first
#define se second
template<class...K> using umap = unordered_map<K...>;
template<class...K> using uset = unordered_set<K...>;

const int N=200100;
signed short n,m,dead[N],deg[N],vis[N][5],q[N],sq,eq;
vector<pair<signed short,signed short>> g[N];
vector<signed short> r[N];
bool wk;

void ff(signed short x,signed short p,signed short dir){
  if(vis[x][dir+1])return;
  vis[x][dir+1]=1;
  dead[x]=1;
  trav(nx,g[x]){
    if(nx.fi==p||nx.se!=dir)continue;
    ff(nx.fi,x,dir);
  }
}

void solve(int _t){

  wk=1;
  cin>>n>>m;
  rep(i,0,m){
    signed short u,v;
    cin>>u>>v;
    u--;v--;
    r[u].pb(v);
    deg[v]++;
    dead[max(u,v)]=1;
    g[u].pb({v,1});
    g[v].pb({u,-1});
  }
  rep(i,0,n){
    if(!deg[i])q[eq++]=i;
  }
  signed short seen=0;
  while(sq<eq){
    signed short node=q[sq++];
    seen++;
    trav(nx,r[node]){
      if(!--deg[nx])q[eq++]=nx;
    }
  }
  if(seen!=n){
    cout<<"-1\n";
    return;
  }
  signed short res=0;
  vector<signed short> r;
  rep(i,0,n){
    res+=!dead[i];
    r.pb(!dead[i]);
    ff(i,-1,1);
    ff(i,-1,-1);
  }
  cout<<res<<"\n";
  rep(i,0,sz(r))cout<<(r[i]?"A":"E");
  cout<<"\n";
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cout.precision(13);
  int t=1;
  while(t--)solve(t);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vd> vvd;
const int mod = 1000000007;
const vi mods = {998244353,1000000007,1000000009};
const ll inf = 3e18;
const double pi = acos(-1.0);
const double eps = 0.0000001;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define trav(a,x) for(auto&a:x)
#define all(x) begin(x),end(x)
#define sz(x) ((int)(x).size())
#define fll(xs,x,a) fill(&x,&x+sizeof(xs)/sizeof(x)-1,a)//fll(dp,dp[0][0],inf)
#define has(x,a) (x.find(a)!=end(x))
#define pc(x) __builtin_popcountll(x)
#define pb push_back
#define fi first
#define se second
template<class...K> using umap = unordered_map<K...>;
template<class...K> using uset = unordered_set<K...>;

const int N=200100;
ll n,m,dead[N],deg[N];
umap<ll,vll>g;
umap<ll,vl>r;
queue<ll>q;
bool wk;

void ff(ll x,ll p,ll dir){
  dead[x]=1;
  trav(nx,g[x]){
    if(nx.fi==p||nx.se!=dir)continue;
    ff(nx.fi,x,dir);
  }
}

void solve(int _t){

  wk=1;
  cin>>n>>m;
  rep(i,0,m){
    ll u,v;
    cin>>u>>v;
    u--;v--;
    r[u].pb(v);
    deg[v]++;
    dead[max(u,v)]=1;
    g[u].pb({v,1});
    g[v].pb({u,-1});
  }
  rep(i,0,n){
    if(!deg[i])q.push(i);
  }
  ll seen=0;
  while(sz(q)){
    ll node=q.front();q.pop();
    seen++;
    trav(nx,r[node]){
      if(!--deg[nx])q.push(nx);
    }
  }
  if(seen!=n){
    cout<<"-1\n";
    return;
  }
  ll res=0;
  vl r;
  rep(i,0,n){
    res+=!dead[i];
    r.pb(!dead[i]);
    if(!dead[i]){
      ff(i,-1,1);
      ff(i,-1,-1);
    }
  }
  cout<<res<<"\n";
  rep(i,0,sz(r))cout<<(r[i]?"A":"E");
  cout<<"\n";
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cout.precision(13);
  int t=1;
  while(t--)solve(t);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vd> vvd;
const int mod = 1000000007;
const vi mods = {998244353,1000000007,1000000009};
const ll inf = 3e18;
const double pi = acos(-1.0);
const double eps = 0.0000001;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i,a,b) for(unsigned short i=(a);i<(b);++i)
#define trav(a,x) for(auto&a:x)
#define all(x) begin(x),end(x)
#define sz(x) ((int)(x).size())
#define fll(xs,x,a) fill(&x,&x+sizeof(xs)/sizeof(x)-1,a)//fll(dp,dp[0][0],inf)
#define has(x,a) (x.find(a)!=end(x))
#define pc(x) __builtin_popcountll(x)
#define pb push_back
#define fi first
#define se second
template<class...K> using umap = unordered_map<K...>;
template<class...K> using uset = unordered_set<K...>;

const int N=200100;
unsigned short n,m,dead[N],deg[N],vis[N][5],q[N],sq,eq;
vector<pair<unsigned short,unsigned short>> g[N];
vector<unsigned short> r[N];
bool wk;

void ff(unsigned short x,unsigned short p,unsigned short dir){
  if(vis[x][dir+1])return;
  vis[x][dir+1]=1;
  dead[x]=1;
  trav(nx,g[x]){
    if(nx.fi==p||nx.se!=dir)continue;
    ff(nx.fi,x,dir);
  }
}

void solve(int _t){

  wk=1;
  cin>>n>>m;
  rep(i,0,m){
    unsigned short u,v;
    cin>>u>>v;
    u--;v--;
    r[u].pb(v);
    deg[v]++;
    dead[max(u,v)]=1;
    g[u].pb({v,1});
    g[v].pb({u,-1});
  }
  rep(i,0,n){
    if(!deg[i])q[eq++]=i;
  }
  unsigned short seen=0;
  while(sq<eq){
    unsigned short node=q[sq++];
    seen++;
    trav(nx,r[node]){
      if(!--deg[nx])q[eq++]=nx;
    }
  }
  if(seen!=n){
    cout<<"-1\n";
    return;
  }
  unsigned short res=0;
  vector<unsigned short> r;
  rep(i,0,n){
    res+=!dead[i];
    r.pb(!dead[i]);
    ff(i,-1,1);
    ff(i,-1,-1);
  }
  cout<<res<<"\n";
  rep(i,0,sz(r))cout<<(r[i]?"A":"E");
  cout<<"\n";
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cout.precision(13);
  int t=1;
  while(t--)solve(t);
  return 0;
}


  #include <bits/stdc++.h>
  using namespace std;
  typedef long long ll;
  typedef long double ld;
  typedef pair<int,int> pii;
  typedef pair<ll,ll> pll;
  typedef pair<double,double> pdd;
  typedef vector<int> vi;
  typedef vector<ll> vl;
  typedef vector<double> vd;
  typedef vector<string> vs;
  typedef vector<pii> vii;
  typedef vector<pll> vll;
  typedef vector<pdd> vdd;
  typedef vector<vi> vvi;
  typedef vector<vl> vvl;
  typedef vector<vd> vvd;
  const int mod = 1000000007;
  const vi mods = {998244353,1000000007,1000000009};
  const ll inf = 3e18;
  const double pi = acos(-1.0);
  const double eps = 0.0000001;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  #define rep(i,a,b) for(int i=(a);i<(b);++i)
  #define trav(a,x) for(auto&a:x)
  #define all(x) begin(x),end(x)
  #define sz(x) ((int)(x).size())
  #define fll(xs,x,a) fill(&x,&x+sizeof(xs)/sizeof(x)-1,a)//fll(dp,dp[0][0],inf)
  #define has(x,a) (x.find(a)!=end(x))
  #define pc(x) __builtin_popcountll(x)
  #define pb push_back
  #define fi first
  #define se second
  template<class...K> using umap = unordered_map<K...>;
  template<class...K> using uset = unordered_set<K...>;

  const int N=200100;
  int n,m,dead[N],deg[N],vis[N][5],q[N],sq,eq;
  vector<array<int,2>> g[N];
  vector<int> r[N];
  bool wk;

  void ff(int x,int p,int dir){
    if(vis[x][dir+1])return;
    vis[x][dir+1]=1;
    if(p!=-1)dead[x]=1;
    trav(nx,g[x]){
      if(nx[0]==p||nx[1]!=dir)continue;
      ff(nx[0],x,dir);
    }
  }

  void solve(int _t){

    wk=1;
    cin>>n>>m;
    rep(i,0,m){
      int u,v;
      cin>>u>>v;
      u--;v--;
      r[u].pb(v);
      deg[v]++;
      dead[max(u,v)]=1;
      g[u].pb({v,1});
      g[v].pb({u,-1});
    }
    rep(i,0,n){
      if(!deg[i])q[eq++]=i;
    }
    int seen=0;
    while(sq<eq){
      int node=q[sq++];
      seen++;
      trav(nx,r[node]){
        if(!--deg[nx])q[eq++]=nx;
      }
    }
    if(seen!=n){
      cout<<"-1\n";
      return;
    }
    int res=0;
    rep(i,0,n){
      res+=!dead[i];
      ff(i,-1,1);
      ff(i,-1,-1);
    }
    cout<<res<<'\n';
    rep(i,0,n)cout<<(dead[i]?'E':'A');
  }

  int main() {
    cin.tie(0)->sync_with_stdio(0);
    cout.precision(13);
    int t=1;
    while(t--)solve(t);
    return 0;
  }


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vd> vvd;
const int mod = 1000000007;
const vi mods = {998244353,1000000007,1000000009};
const ll inf = 3e18;
const double pi = acos(-1.0);
const double eps = 0.0000001;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define trav(a,x) for(auto&a:x)
#define all(x) begin(x),end(x)
#define sz(x) ((int)(x).size())
#define fll(xs,x,a) fill(&x,&x+sizeof(xs)/sizeof(x)-1,a)//fll(dp,dp[0][0],inf)
#define has(x,a) (x.find(a)!=end(x))
#define pc(x) __builtin_popcountll(x)
#define pb push_back
#define fi first
#define se second
template<class...K> using umap = unordered_map<K...>;
template<class...K> using uset = unordered_set<K...>;

const int N=200100;
ll n,m,dead[N],deg[N],vis[N][10];
umap<ll,vll>g;
umap<ll,vl>r;
queue<ll>q;

void ff(ll x,ll p,ll dir){
  if(vis[x][dir+5])return;
  dead[x]=1;
  vis[x][dir+5]=1;
  trav(nx,g[x]){
    if(nx.fi==p||nx.se!=dir)continue;
    ff(nx.fi,x,dir);
  }
}

void solve(int _t){

  cin>>n>>m;
  vvl qff;
  rep(i,0,m){
    ll u,v;
    cin>>u>>v;
    u--;v--;
    r[u].pb(v);
    deg[v]++;
    ll lo=min(u,v),hi=max(u,v);
    qff.pb({hi,-1,hi==v?1:-1});
    g[u].pb({v,1});
    g[v].pb({u,-1});
  }
  trav(_q,qff){
    ff(_q[0],_q[1],_q[2]);
  }
  rep(i,0,n)if(!deg[i])q.push(i);
  ll seen=0;
  while(sz(q)){
    ll node=q.front();q.pop();
    seen++;
    trav(nx,r[node]){
      if(!--deg[nx])q.push(nx);
    }
  }
  if(seen!=n){
    cout<<"-1\n";
    return;
  }
  ll res=0;
  vl r;
  rep(i,0,n){
    res+=!dead[i];
    r.pb(!dead[i]);
    if(!dead[i]){
      ff(i,-1,1);
      ff(i,-1,-1);
    }
  }
  cout<<res<<"\n";
  rep(i,0,sz(r))cout<<(r[i]?"A":"E");
  cout<<"\n";
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cout.precision(13);
  int t=1;
  while(t--)solve(t);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vd> vvd;
const int mod = 1000000007;
const vi mods = {998244353,1000000007,1000000009};
const ll inf = 3e18;
const double pi = acos(-1.0);
const double eps = 0.0000001;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define trav(a,x) for(auto&a:x)
#define all(x) begin(x),end(x)
#define sz(x) ((int)(x).size())
#define fll(xs,x,a) fill(&x,&x+sizeof(xs)/sizeof(x)-1,a)//fll(dp,dp[0][0],inf)
#define has(x,a) (x.find(a)!=end(x))
#define pc(x) __builtin_popcountll(x)
#define pb push_back
#define fi first
#define se second
template<class...K> using umap = unordered_map<K...>;
template<class...K> using uset = unordered_set<K...>;

const int N=200100;
ll n,m,dead[N],deg[N],vis[N][2];
umap<ll,vll>g;
umap<ll,vl>r;
queue<ll>q;

void ff(ll x,ll p,ll dir){
  if(vis[x][dir])return;
  dead[x]=1;
  vis[x][dir]=1;
  trav(nx,g[x]){
    if(nx.fi==p||nx.se!=dir)continue;
    ff(nx.fi,x,dir);
  }
}

void solve(int _t){

  cin>>n>>m;
  rep(i,0,m){
    ll u,v;
    cin>>u>>v;
    u--;v--;
    r[u].pb(v);
    deg[v]++;
    ll lo=min(u,v),hi=max(u,v);
    ff(hi,-1,hi==v?1:-1);
    g[u].pb({v,1});
    g[v].pb({u,-1});
  }
  rep(i,0,n)if(!deg[i])q.push(i);
  ll seen=0;
  while(sz(q)){
    ll node=q.front();q.pop();
    seen++;
    trav(nx,r[node]){
      if(!--deg[nx])q.push(nx);
    }
  }
  if(seen!=n){
    cout<<"-1\n";
    return;
  }
  ll res=0;
  vl r;
  rep(i,0,n){
    res+=!dead[i];
    r.pb(!dead[i]);
    if(!dead[i]){
      ff(i,-1,1);
      ff(i,-1,-1);
    }
  }
  cout<<res<<"\n";
  rep(i,0,sz(r))cout<<(r[i]?"A":"E");
  cout<<"\n";
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cout.precision(13);
  int t=1;
  while(t--)solve(t);
  return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define sz(v) ((int)v.size())
#define all(v) (v).begin(), (v).end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
int n,m;
int ord[200010],ocnt;
char a[200010];
bool chk[200010];
vector<int> g[200010],gg[200010];
void f0(int u) {
	if(chk[u])return;
	chk[u]=true;
	for(auto& v:g[u])f0(v);
	ord[u]=++ocnt;
}
void f1(int u) {
	if(chk[u])return;
	chk[u]=true;
	for(auto& v:g[u])f1(v);
}
void f2(int u) {
	if(chk[u])return;
	chk[u]=true;
	for(auto& v:gg[u])f2(v);
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int i,j;
	cin>>n>>m;
	for(i=1;i<=m;i++) {
		int u,v;cin>>u>>v;
		g[u].pb(v);
		gg[v].pb(u);
	}
	for(i=1;i<=n;i++) {
		if(!chk[i]) {
			f0(i);
		}
	}
	for(i=1;i<=n;i++) {
		for(auto& v:g[i]) {
			if(ord[i]<ord[v]) {
				cout<<-1;
				return 0;
			}
		}
	}
	memset(chk,0,sizeof(chk));
	int ans=0;
	for(i=1;i<=n;i++) {
		if(chk[i])a[i]='E';
		else {
			ans++;
			a[i]='A';
			f1(i);
			f2(i);
		}
	}
	cout<<ans<<'\n'<<a+1;
	return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define sz(v) ((int)v.size())
#define all(v) (v).begin(), (v).end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
int n,m;
int ord[200010],ocnt;
char a[200010];
bool chk[200010];
vector<int> g[200010],gg[200010];
void f0(int u) {
	if(chk[u])return;
	chk[u]=true;
	for(auto& v:g[u])f0(v);
	ord[u]=++ocnt;
}
void f1(int u) {
	if(chk[u])return;
	chk[u]=true;
	for(auto& v:g[u])f1(v);
}
void f2(int u) {
	if(chk[u])return;
	chk[u]=true;
	for(auto& v:gg[u])f2(v);
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int i,j;
	cin>>n>>m;
	for(i=1;i<=m;i++) {
		int u,v;cin>>u>>v;
		g[u].pb(v);
		gg[v].pb(u);
	}
	for(i=1;i<=n;i++) {
		if(!chk[i]) {
			f0(i);
		}
	}
	for(i=1;i<=n;i++) {
		for(auto& v:g[i]) {
			if(ord[i]<ord[v]) {
				cout<<-1;
				return 0;
			}
		}
	}
	memset(chk,0,sizeof(chk));
	int ans=0;
	for(i=1;i<=n;i++) {
		if(chk[i])a[i]='E';
		else {
			ans++;
			a[i]='A';
			for(auto& v:g[i])f1(v);
			f2(i);
		}
	}
	cout<<ans<<'\n'<<a+1;
	return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define sz(v) ((int)v.size())
#define all(v) (v).begin(), (v).end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
int n,m;
int ord[200010],ocnt;
char a[200010];
bool c0[200010],c1[200010],c2[200010];
vector<int> g[200010],gg[200010];
void f0(int u) {
	if(c0[u])return;
	c0[u]=true;
	for(auto& v:g[u])f0(v);
	ord[u]=++ocnt;
}
void f1(int u) {
	if(c1[u])return;
	c1[u]=true;
	for(auto& v:g[u])f1(v);
}
void f2(int u) {
	if(c2[u])return;
	c2[u]=true;
	for(auto& v:gg[u])f2(v);
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int i,j;
	cin>>n>>m;
	for(i=1;i<=m;i++) {
		int u,v;cin>>u>>v;
		g[u].pb(v);
		gg[v].pb(u);
	}
	for(i=1;i<=n;i++) {
		if(!c0[i]) {
			f0(i);
		}
	}
	for(i=1;i<=n;i++) {
		for(auto& v:g[i]) {
			if(ord[i]<ord[v]) {
				cout<<-1;
				return 0;
			}
		}
	}
	int ans=0;
	for(i=1;i<=n;i++) {
		if(c1[i]||c2[i])a[i]='E';
		else {
			ans++;
			a[i]='A';
		}
		f1(i);
		f2(i);
	}
	cout<<ans<<'\n'<<a+1;
	return 0;
}


#include <bits/stdc++.h>
#define fi first
#define se second
#define sz(v) ((int)v.size())
#define all(v) (v).begin(), (v).end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
int n,m;
int ord[200010],ocnt;
char a[200010];
bool c0[200010],c1[200010],c2[200010];
vector<int> g[200010],gg[200010];
void f0(int u) {
	if(c0[u])return;
	c0[u]=true;
	for(auto& v:g[u])f0(v);
	ord[u]=++ocnt;
}
void f1(int u) {
	if(c1[u])return;
	c1[u]=true;
	for(auto& v:g[u])f1(v);
}
void f2(int u) {
	if(c2[u])return;
	c2[u]=true;
	for(auto& v:gg[u])f2(v);
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int i,j;
	cin>>n>>m;
	for(i=1;i<=m;i++) {
		int u,v;cin>>u>>v;
		g[u].pb(v);
		gg[v].pb(u);
	}
	for(i=1;i<=n;i++) {
		if(!c0[i]) {
			f0(i);
		}
	}
	for(i=1;i<=n;i++) {
		for(auto& v:g[i]) {
			if(ord[i]<ord[v]) {
				cout<<-1;
				return 0;
			}
		}
	}
	int ans=0;
	for(i=1;i<=n;i++) {
		if(c1[i]||c2[i])a[i]='E';
		else {
			ans++;
			a[i]='A';
			f1(i);
			f2(i);
		}
	}
	cout<<ans<<'\n'<<a+1;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fio ios::sync_with_stdio(false); cin.tie(); cout.tie();
#define fls cout.flush();
#define all(v) v.begin(), v.end()
#define uni(v) sort(all(v)); v.resize(unique(all(v))-v.begin());
#define scan(a, n) for(int i = 0; i < n; i++)cin >> a[i];
#define print(a, n) for(int i = 0; i < n; i++)cout << a[i] << ' '; cout << '\n';
#define fr first
#define sc second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int mod = int(1e9+7);
const int MN = int(2e5+7);

ll po(ll b, ll p){
    ll r =1;
    while(p){
        if(p&1)r = r*b%mod;
        p >>= 1;
        b = b*b%mod;
    }
}

int n, m, mark[MN], isa[MN];
vector<int> g[MN], comp, eg[MN];

void dfs(int nw){
    mark[nw] = 1;
    isa[nw] = 1;
    for(auto u : g[nw]){
        if(!mark[u])dfs(u);
        if(isa[u])isa[nw] = 0;
    }
}

void cyc(int nw){
    mark[nw] = 1;
    for(auto u : eg[nw]){
        if(mark[u] == 1){
            cout << "-1\n";
            exit(0);
        }
        if(!mark[u])cyc(u);
    }
    comp.push_back(nw);
}

void inp(){
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        u--; v--;
        eg[u].push_back(v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<int> a;
    for(int i = 0; i < n; i++){
        if(mark[i] == 0){cyc(i);}
        for(auto u : comp)mark[u] = 2;
        comp.clear();
    }

    for(int i = 0; i < n; i++)mark[i] = 0;

    for(int i = 0; i < n; i++){
        if(!mark[i])dfs(i);
    }

    string ans(n, 'E');
    for(int i = 0; i < n; i++)if(isa[i])ans[i] = 'A', a.push_back(i);
    cout << a.size() << '\n' << ans << '\n';
}

void slv(){
}

signed main(){
    fio;

    int t = 1;
    //cin >> t;
    while(t--){inp();slv();}
}


#include <bits/stdc++.h>

using namespace std;

#define fio ios::sync_with_stdio(false); cin.tie(); cout.tie();
#define fls cout.flush();
#define all(v) v.begin(), v.end()
#define uni(v) sort(all(v)); v.resize(unique(all(v))-v.begin());
#define scan(a, n) for(int i = 0; i < n; i++)cin >> a[i];
#define print(a, n) for(int i = 0; i < n; i++)cout << a[i] << ' '; cout << '\n';
#define fr first
#define sc second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int mod = int(1e9+7);
const int MN = int(2e5+7);

ll po(ll b, ll p){
    ll r =1;
    while(p){
        if(p&1)r = r*b%mod;
        p >>= 1;
        b = b*b%mod;
    }
}

int n, m, mark[MN];
vector<int> g[MN], comp, eg[MN];

void dfs(int nw){
    mark[nw] = 1;
    for(auto u : g[nw]){
        if(!mark[u])dfs(u);
    }
}

void cyc(int nw){
    mark[nw] = 1;
    for(auto u : eg[nw]){
        if(mark[u] == 1){
            cout << "-1\n";
            exit(0);
        }
        if(!mark[u])cyc(u);
    }
    comp.push_back(nw);
}

void inp(){
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        u--; v--;
        eg[u].push_back(v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<int> a;
    for(int i = 0; i < n; i++){
        if(mark[i] == 0){cyc(i);a.push_back(i);}
        for(auto u : comp)mark[u] = 2;
        comp.clear();
    }

    string ans(n, 'E');
    for(auto u : a)ans[u] = 'A';
    cout << a.size() << '\n' << ans << '\n';
}

void slv(){
}

signed main(){
    fio;

    int t = 1;
    //cin >> t;
    while(t--){inp();slv();}
}


#include <bits/stdc++.h>

using namespace std;

#define fio ios::sync_with_stdio(false); cin.tie(); cout.tie();
#define fls cout.flush();
#define all(v) v.begin(), v.end()
#define uni(v) sort(all(v)); v.resize(unique(all(v))-v.begin());
#define scan(a, n) for(int i = 0; i < n; i++)cin >> a[i];
#define print(a, n) for(int i = 0; i < n; i++)cout << a[i] << ' '; cout << '\n';
#define fr first
#define sc second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int mod = int(1e9+7);
const int MN = int(2e5+7);

ll po(ll b, ll p){
    ll r =1;
    while(p){
        if(p&1)r = r*b%mod;
        p >>= 1;
        b = b*b%mod;
    }
}

int n, m, mark[MN], isa[MN], dp0[MN], dp1[MN];
vector<int> g[MN], comp, eg[MN], cc;

void dfs(int nw){
    mark[nw] = 1;
    dp0[nw] = 0;
    dp1[nw] = 1;
    for(auto u : g[nw]){
        if(!mark[u])dfs(u);
        dp1[nw] += dp0[u];
        dp0[nw] += dp1[u];
    }
    cc.push_back(nw);
}

void recit(int nw, int q){
    mark[nw] = 1;
    if(q < 0){
        q = 1;
        if(dp0[nw] > dp1[nw])q = 0;
    }
    isa[nw] = q;
    for(auto u : g[nw]){
        if(!mark[u]){
            if(q == 1)recit(u, 0);
            else recit(u, -1);
        }
    }
}

void cyc(int nw){
    mark[nw] = 1;
    for(auto u : eg[nw]){
        if(mark[u] == 1){
            cout << "-1\n";
            exit(0);
        }
        if(!mark[u])cyc(u);
    }
    comp.push_back(nw);
}

void inp(){
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        u--; v--;
        eg[u].push_back(v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<int> a;
    for(int i = 0; i < n; i++){
        if(mark[i] == 0){cyc(i);}
        for(auto u : comp)mark[u] = 2;
        comp.clear();
    }

    for(int i = 0; i < n; i++)mark[i] = 0;

    for(int i = 0; i < n; i++){
        if(!mark[i]){
            dfs(i);
            for(auto u : cc)mark[u] = 0;
            cc.clear();
            recit(i, -1);
        }
    }

    string ans(n, 'E');
    for(int i = 0; i < n; i++)if(isa[i])ans[i] = 'A', a.push_back(i);
    cout << a.size() << '\n' << ans << '\n';
}

void slv(){
}

signed main(){
    fio;

    int t = 1;
    //cin >> t;
    while(t--){inp();slv();}
}


#include <bits/stdc++.h>

using namespace std;

#define fio ios::sync_with_stdio(false); cin.tie(); cout.tie();
#define fls cout.flush();
#define all(v) v.begin(), v.end()
#define uni(v) sort(all(v)); v.resize(unique(all(v))-v.begin());
#define scan(a, n) for(int i = 0; i < n; i++)cin >> a[i];
#define print(a, n) for(int i = 0; i < n; i++)cout << a[i] << ' '; cout << '\n';
#define fr first
#define sc second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int mod = int(1e9+7);
const int MN = int(2e5+7);

ll po(ll b, ll p){
    ll r =1;
    while(p){
        if(p&1)r = r*b%mod;
        p >>= 1;
        b = b*b%mod;
    }
}

int n, m, mark[MN], isa[MN], dp0[MN], dp1[MN];
vector<int> g[MN], comp, eg[MN], cc;
    vector<int> a;

void dfs(int nw){
    mark[nw] = 1;
    dp0[nw] = 0;
    dp1[nw] = 1;

    for(auto u : g[nw]){
        if(!mark[u])dfs(u);
        dp1[nw] += dp0[u];
        dp0[nw] += max(dp0[u], dp1[u]);
    }
    cc.push_back(nw);
}

void recit(int nw, int q){
    mark[nw] = 1;
    if(q < 0){
        q = 1;
        if(dp0[nw] > dp1[nw])q = 0;
    }

    if(q == 1)a.push_back(nw);
    for(auto u : g[nw]){
        if(!mark[u]){
            if(q == 1)recit(u, 0);
            else recit(u, -1);
        }
    }
}

void cyc(int nw){
    mark[nw] = 1;
    for(auto u : eg[nw]){
        if(mark[u] == 1){
            cout << "-1\n";
            exit(0);
        }
        if(mark[u] == 0)cyc(u);
    }
    comp.push_back(nw);
}

void inp(){
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        u--; v--;
        eg[u].push_back(v);
        g[u].push_back(v);
        g[v].push_back(u);
    }

    for(int i = 0; i < n; i++){
        if(mark[i] == 0){cyc(i);}
        for(auto u : comp)mark[u] = 2;
        comp.clear();
    }

    for(int i = 0; i < n; i++)mark[i] = 0;

    for(int i = 0; i < n; i++){
        if(!mark[i]){
            dfs(i);
            for(auto u : cc)mark[u] = 0;
            cc.clear();
            recit(i, -1);
        }
    }

    string ans(n, 'E');
    for(auto u : a)ans[u] = 'A';
    cout << a.size() << '\n' << ans << '\n';
}

void slv(){
}

signed main(){
    fio;

    int t = 1;
    //cin >> t;
    while(t--){inp();slv();}
}


#include<bits/stdc++.h>
using namespace std;

long long n,m,ans,u,v,start;
string opz;
int vis[2][200005];
vector<int> grafo[2][200005];

void dfs(int nodo,int mode){
	vis[mode][nodo]=1;

	for(auto i:grafo[mode][nodo]){

		if(vis[mode][i]==1){
			cout<<"-1\n";
			exit(0);
		}

		if(vis[mode][i]==0){
			dfs(i,mode);
		}
	}

	vis[mode][nodo]=2;
}

int main(){

	ios::sync_with_stdio(false);
	cin.tie(0);

	cin>>n>>m;

	opz.resize(n);

	for(int i=0;i<m;i++){
		cin>>u>>v;
		grafo[0][u].push_back(v);
		grafo[1][v].push_back(u);
	}

	for(int i=1;i<=n;i++){
		if(vis[0][i]==0 && vis[1][i]==0){
			opz[i-1]='A';
			ans++;
		}
		else{
			opz[i-1]='E';
		}

		if(vis[0][i]==false)
		dfs(i,0);

		if(vis[1][i]==false)
		dfs(i,1);
	}

	cout<<ans<<"\n"<<opz<<"\n";

return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fio ios::sync_with_stdio(false); cin.tie(); cout.tie();
#define fls cout.flush();
#define all(v) v.begin(), v.end()
#define uni(v) sort(all(v)); v.resize(unique(all(v))-v.begin());
#define scan(a, n) for(int i = 0; i < n; i++)cin >> a[i];
#define print(a, n) for(int i = 0; i < n; i++)cout << a[i] << ' '; cout << '\n';
#define fr first
#define sc second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int mod = int(1e9+7);
const int MN = int(2e5+7);

ll po(ll b, ll p){
    ll r =1;
    while(p){
        if(p&1)r = r*b%mod;
        p >>= 1;
        b = b*b%mod;
    }
}

int n, m, mark[MN], isa[MN], dp0[MN], dp1[MN];
vector<int> g[MN], comp, eg[MN], cc;

void dfs(int nw){
    mark[nw] = 1;
    dp0[nw] = 0;
    dp1[nw] = 1;
    for(auto u : g[nw]){
        if(!mark[u])dfs(u);
        dp1[nw] += dp0[u];
        dp0[nw] += max(dp0[u], dp1[u]);
    }
    cc.push_back(nw);
}

void recit(int nw, int q){
    mark[nw] = 1;
    if(q < 0){
        q = 1;
        if(dp0[nw] > dp1[nw])q = 0;
    }
    isa[nw] = q;
    for(auto u : g[nw]){
        if(!mark[u]){
            if(q == 1)recit(u, 0);
            else recit(u, -1);
        }
    }
}

void cyc(int nw){
    mark[nw] = 1;
    for(auto u : eg[nw]){
        if(mark[u] == 1){
            cout << "-1\n";
            exit(0);
        }
        if(!mark[u])cyc(u);
    }
    comp.push_back(nw);
}

void inp(){
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        u--; v--;
        eg[u].push_back(v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<int> a;
    for(int i = 0; i < n; i++){
        if(mark[i] == 0){cyc(i);}
        for(auto u : comp)mark[u] = 2;
        comp.clear();
    }

    for(int i = 0; i < n; i++)mark[i] = 0;

    for(int i = 0; i < n; i++){
        if(!mark[i]){
            dfs(i);
            for(auto u : cc)mark[u] = 0;
            cc.clear();
            recit(i, -1);
        }
    }

    string ans(n, 'E');
    for(int i = 0; i < n; i++)if(isa[i])ans[i] = 'A', a.push_back(i);
    cout << a.size() << '\n' << ans << '\n';
}

void slv(){
}

signed main(){
    fio;

    int t = 1;
    //cin >> t;
    while(t--){inp();slv();}
}


/**

  @@@@@@@  @@@@  @@@@  @@@@  @@@@  @
  @  @  @  @  @  @  @  @  @  @  @  @
  @  @  @  @  @  @  @  @  @  @  @  @
  @  @  @  @  @  @  @  @  @  @  @  @
  @  @  @  @@@@  @@@@  @@@@  @  @  @

**/
#include <bits/stdc++.h>

using namespace std;

#define ll int
#define ull unsigned long long
#define db double
#define ld long double
#define str string
#define pi pair
#define tup tuple
#define vec vector
#define temp template
#define tn typename

#define ff first
#define ss second
#define SZ(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rsz resize
#define ins insert
#define fr front
#define bc back
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mk make_pair

#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ROF(i, a, b) for (ll i = (a); i >= (b); i--)
#define trav(a, x) for (auto &a : x)
#define popcount __builtin_popcount
#define ctz __builtin_ctz
#define clz __builtin_clz
#define gcd __gcd

vec<ll> find_topsort(vec<vec<pi<ll, ll>>> &g) {
  ll n = SZ(g);
  vec<vec<ll>> g_in(n), g_out(n);
  FOR(i, 0, n - 1) {
    trav(edge, g[i]) {
      ll u = edge.ss;
      g_out[i].pb(u);
      g_in[u].pb(i);
    }
  }
  vec<ll> deg(n);
  FOR(i, 0, n - 1) {
    deg[i] = SZ(g_in[i]);
  }
  vec<ll> x;
  FOR(i, 0, n - 1) {
    if (deg[i] == 0) {
      x.pb(i);
    }
  }
  FOR(p, 0, SZ(x) - 1) {
    trav(v, g_out[x[p]]) {
      --deg[v];
      if (deg[v] == 0) {
        x.pb(v);
      }
    }
  }
  if (SZ(x) != n) {
    return vec<ll>();
  }
  return x;
}

vec<ll> find_topsort(vec<vec<ll>> &g) {
	ll n = SZ(g);
	vec<vec<pi<ll, ll>>> h;
	h.rsz(n);
	FOR(i, 0, n - 1) {
		trav(v, g[i]) {
			h[i].eb(1, v);
		}
	}
	return find_topsort(h);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vec<vec<ll>> g(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g[x].pb(y);
  }
  vector<int> order = find_topsort(g);
  if (order.empty()) {
    cout << -1 << '\n';
    return 0;
  }
  string res(n, 'A');
  vector<int> mn(n);
  iota(mn.begin(), mn.end(), 0);
  for (int i : order) {
    for (int to : g[i]) {
      int j = to;
      mn[j] = min(mn[j], mn[i]);
    }
  }
  for (int i = 0; i < n; i++) {
    if (mn[i] < i) {
      res[i] = 'E';
    }
  }
  iota(mn.begin(), mn.end(), 0);
  for (int i : vector<int>(order.rbegin(), order.rend())) {
    for (int to : g[i]) {
      int j = to;
      mn[i] = min(mn[i], mn[j]);
    }
  }
  for (int i = 0; i < n; i++) {
    if (mn[i] < i) {
      res[i] = 'E';
    }
  }
  int ans = 0;
  for (char c : res) {
    ans += (c == 'A');
  }
  cout << ans << '\n';
  cout << res << '\n';
  return 0;
}


/**
 * THIS IS MOOONI'S CODE !
 * HACK IT IF YOU CAN !
**/
#include <bits/stdc++.h>

using namespace std;

/// debug

void dbg(long int x){cerr<<x;}void dbg(int x){cerr<<x;}void dbg(long long x){cerr<<x;}
void dbg(unsigned long long x){cerr<<x;}void dbg(double x){cerr<<x;}void dbg(float x){cerr<<x;}
void dbg(char x){cerr<<"'"<<x<<"'";}void dbg(bool x){cerr<<(x?"true":"false");}void dbg(string x){cerr<<'"'+x+'"';}
template<typename A,typename B>void dbg(pair<A,B>p){cerr<<'(';dbg(p.first);cerr<<", ";dbg(p.second);cerr<<')';}
template<typename A,typename B,typename C>void dbg(tuple<A,B,C>p){cerr<<'(';dbg(get<0>(p));cerr<<", ";dbg(get<1>(p));cerr<<", ";dbg(get<2>(p));cerr<<')';}
template<typename A,typename B,typename C,typename D>
void dbg(tuple<A,B,C,D>p){cerr<<'(';dbg(get<0>(p));cerr<<", ";dbg(get<1>(p));cerr<<", ";dbg(get<2>(p));cerr<<", ";dbg(get<3>(p));cerr<<')';}
template<size_t N>void dbg(bitset<N>v){string res="";for(size_t i=0;i<N;i++){res+=static_cast<char>('0'+v[i]);}cerr<<res;}
template<typename A>void dbg(vector<A>v){cerr<<'{';for(int i=0;i<(int)v.size();i++){if(i)cerr<<", ";dbg(v[i]);}cerr<<'}';}
template<typename T>void Dbg(T x){dbg(x);cerr<<endl;}
template<typename Head,typename...Tail>void Dbg(Head H,Tail...T){Dbg(H);Dbg(T...);}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:"<<endl,Dbg(__VA_ARGS__)

/// debug

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g_in(n), g_out(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g_out[x].push_back(y);
    g_in[y].push_back(x);
  }
  bool is_dag = true;
  vector<int> was(n, -1);
  function<void(int, int)> Dfs = [&](int v, int now) {
    was[v] = now;
    for (int u : g_out[v]) {
      if (was[u] != -1) {
        if (was[u] == now) {
          is_dag = false;
        }
        continue;
      }
      Dfs(u, now);
    }
  };
  int cur = 0;
  for (int i = 0; i < n; i++) {
    if (was[i] == -1) {
      Dfs(i, cur);
      if (is_dag == false) {
        cout << -1 << '\n';
        return 0;
      }
      ++cur;
    }
  }
  string res = "";
  vector<bool> mark(n, false);
  function<void(int)> Dfs_in = [&](int v) {
    mark[v] = true;
    for (int u : g_in[v]) {
      if (mark[u]) {
        continue;
      }
      Dfs_in(u);
    }
  };
  function<void(int)> Dfs_out = [&](int v) {
    mark[v] = true;
    for (int u : g_out[v]) {
      if (mark[u]) {
        continue;
      }
      Dfs_out(u);
    }
  };
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (mark[i]) {
      res += 'E';
    } else {
      ++ans;
      res += 'A';
      Dfs_in(i);
      Dfs_out(i);
    }
  }
  cout << ans << '\n';
  cout << res << '\n';
  return 0;
}


/**
 *  author: MOOONI
 *  hackers are welcome!
**/
#include <bits/stdc++.h>

#define int long long

using namespace std;

template<typename T>
void debug_out(T x) {
  cerr << x;
}

template<typename A>
void debug_out(vector<A> v) {
  cerr << '{';
  for (int i = 0; i < (int) v.size(); i++) {
    if (i) {
      cerr << ", ";
    }
    debug_out(v[i]);
  }
  cerr << '}';
}

template <typename A, typename B>
void debug_out(pair<A, B> p) {
  cerr << '(';
  debug_out(p.first);
  cerr << ", ";
  debug_out(p.second);
  cerr << ')';
}

template <typename A, typename B, typename C>
void debug_out(tuple<A, B, C> p) {
  cerr << '(';
  debug_out(get<0>(p));
  cerr << ", ";
  debug_out(get<1>(p));
  cerr << ", ";
  debug_out(get<2>(p));
  cerr << ')';
}

template <typename A, typename B, typename C, typename D>
void debug_out(tuple<A, B, C, D> p) {
  cerr << '(';
  debug_out(get<0>(p));
  cerr << ", ";
  debug_out(get<1>(p));
  cerr << ", ";
  debug_out(get<2>(p));
  cerr << ", ";
  debug_out(get<3>(p));
  cerr << ')';
}

template <size_t N>
void debug_out(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  cerr << res;
}

template <typename T>
void debug_with_endl(T v) {
  debug_out(v);
  cerr << endl;
}

template <typename Head, typename... Tail>
void debug_with_endl(Head H, Tail... T) {
  debug_with_endl(H);
  debug_with_endl(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_with_endl(__VA_ARGS__)
#else
#define debug(...) 2003
#endif

vector<int> topsort(vector<vector<int>> &g_in, vector<vector<int>> &g_out) {
  int n = (int) g_in.size();
  vector<int> deg(n);
  for (int i = 0; i < n; i++) {
    deg[i] = (int) g_in[i].size();
  }
  vector<int> x;
  for (int i = 0; i < n; i++) {
    if (deg[i] == 0) {
      x.push_back(i);
    }
  }
  for (int p = 0; p < (int) x.size(); p++) {
    for (int v : g_out[p]) {
      --deg[v];
      if (!deg[v]) {
        x.push_back(v);
      }
    }
  }
  if ((int) x.size() != n) {
    return vector<int>();
  }
  return x;
}

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g_in(n), g_out(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g_out[x].push_back(y);
    g_in[y].push_back(x);
  }
  auto x = topsort(g_in, g_out);
  if (x.empty()) {
    cout << -1 << '\n';
    return 0;
  }
  string res = "";
  vector<bool> mark_in(n, false);
  function<void(int)> Dfs_in = [&](int v) {
    mark_in[v] = true;
    for (int u : g_in[v]) {
      if (mark_in[u]) {
        continue;
      }
      Dfs_in(u);
    }
  };
  vector<bool> mark_out(n, false);
  function<void(int)> Dfs_out = [&](int v) {
    mark_out[v] = true;
    for (int u : g_out[v]) {
      if (mark_out[u]) {
        continue;
      }
      Dfs_out(u);
    }
  };
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (mark_in[i] || mark_out[i]) {
      res += 'E';
      if (!mark_in[i]) {
        Dfs_in(i);
      }
      if (!mark_out[i]) {
        Dfs_out(i);
      }
    } else {
      ++ans;
      res += 'A';
      Dfs_in(i);
      Dfs_out(i);
    }
  }
  cout << ans << '\n';
  cout << res << '\n';
  return 0;
}


/**
 *  author: MOOONI
 *  hackers are welcome!
**/
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define str string
#define pi pair
#define tup tuple
#define vec vector
#define temp template
#define tn typename
#define fc function

#define ff first
#define ss second
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rsz resize
#define ins insert
#define fr front
#define bc back
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound

#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define ROF(i, a, b) for (int i = b; i >= a; i--)
#define trav(a, x) for (auto &a : x)
#define popcount __builtin_popcount
#define ctz __builtin_ctz
#define clz __builtin_clz
#define gcd __gcd

// DEBUG
temp <tn T> void DBG(T v) { cerr << v; }
temp <tn T> void DBG(vec<T> v) {
  cerr << '{';
  bool f = true;
  FOR(i,0, sz(v) - 1) {
    if (!f) cerr << ", ";
    DBG(v[i]);
    f = false;
  }
  cerr << '}';
}
temp <tn T> void DBG(set<T> s) {
  vec<T> v;
  trav(x, s) { v.pb(x); }
  DBG(v);
}
temp <tn T> void DBG(multiset<T> s) {
  vec<T> v;
  trav(x, s) { v.pb(x); }
  DBG(v);
}
temp <size_t N> void DBG(bitset<N> b) {
  FOR(i, 0, N - 1) { cerr << b[i]; }
}
temp <tn A, tn B> void DBG(pi<A, B> p) { cerr << '(' << p.ff << ", " << p.ss << ')'; }
temp <tn A, tn B, tn C> void DBG(tup<A, B, C> t) {
  cerr << '(' << get<0>(t) << ", " << get<1>(t) << ", " << get<2>(t) << ')';
}
temp <tn T> void _dbg(T v) { DBG(v); cerr << endl; }
temp <tn H, tn... T>
void _dbg(H h, T... t) { _dbg(h); _dbg(t...); }
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl; _dbg(__VA_ARGS__)

vec<ll> topsort(vec<vec<ll>> &g_in, vec<vec<ll>> &g_out) {
  ll n = sz(g_in);
  vec<ll> deg(n);
  FOR (i, 0, n - 1) {
    deg[i] = sz(g_in[i]);
  }
  vec<ll> x;
  FOR (i, 0, n - 1) {
    if (deg[i] == 0) {
      x.pb(i);
    }
  }
  FOR (p, 0, sz(x) - 1) {
    trav(v, g_out[x[p]]) {
      --deg[v];
      if (deg[v] == 0) {
        x.pb(v);
      }
    }
  }
  if (sz(x) != n) {
    return vec<ll>();
  }
  return x;
}

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  #define int ll
  #define debug(...) 42
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g_in(n), g_out(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g_out[x].push_back(y);
    g_in[y].push_back(x);
  }
  auto x = topsort(g_in, g_out);
  if (x.empty()) {
    cout << -1 << '\n';
    return 0;
  }
  debug(x);
  string res = "";
  vector<bool> mark_in(n, false);
  function<void(int)> Dfs_in = [&](int v) {
    mark_in[v] = true;
    for (int u : g_in[v]) {
      if (mark_in[u]) {
        continue;
      }
      Dfs_in(u);
    }
  };
  vector<bool> mark_out(n, false);
  function<void(int)> Dfs_out = [&](int v) {
    mark_out[v] = true;
    for (int u : g_out[v]) {
      if (mark_out[u]) {
        continue;
      }
      Dfs_out(u);
    }
  };
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (mark_in[i] || mark_out[i]) {
      res += 'E';
      if (!mark_in[i]) {
        Dfs_in(i);
      }
      if (!mark_out[i]) {
        Dfs_out(i);
      }
    } else {
      ++ans;
      res += 'A';
      Dfs_in(i);
      Dfs_out(i);
    }
  }
  cout << ans << '\n';
  cout << res << '\n';
  return 0;
}


/**
 * THIS IS MOOONI'S CODE !
 * HACK IT IF YOU CAN !
**/
#include <bits/stdc++.h>

using namespace std;

/// debug

void dbg(long int x){cerr<<x;}void dbg(int x){cerr<<x;}void dbg(long long x){cerr<<x;}
void dbg(unsigned long long x){cerr<<x;}void dbg(double x){cerr<<x;}void dbg(float x){cerr<<x;}
void dbg(char x){cerr<<"'"<<x<<"'";}void dbg(bool x){cerr<<(x?"true":"false");}void dbg(string x){cerr<<'"'+x+'"';}
template<typename A,typename B>void dbg(pair<A,B>p){cerr<<'(';dbg(p.first);cerr<<", ";dbg(p.second);cerr<<')';}
template<typename A,typename B,typename C>void dbg(tuple<A,B,C>p){cerr<<'(';dbg(get<0>(p));cerr<<", ";dbg(get<1>(p));cerr<<", ";dbg(get<2>(p));cerr<<')';}
template<typename A,typename B,typename C,typename D>
void dbg(tuple<A,B,C,D>p){cerr<<'(';dbg(get<0>(p));cerr<<", ";dbg(get<1>(p));cerr<<", ";dbg(get<2>(p));cerr<<", ";dbg(get<3>(p));cerr<<')';}
template<size_t N>void dbg(bitset<N>v){string res="";for(size_t i=0;i<N;i++){res+=static_cast<char>('0'+v[i]);}cerr<<res;}
template<typename A>void dbg(vector<A>v){cerr<<'{';for(int i=0;i<(int)v.size();i++){if(i)cerr<<", ";dbg(v[i]);}cerr<<'}';}
template<typename T>void Dbg(T x){dbg(x);cerr<<endl;}
template<typename Head,typename...Tail>void Dbg(Head H,Tail...T){Dbg(H);Dbg(T...);}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:"<<endl,Dbg(__VA_ARGS__)

/// debug

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g_in(n), g_out(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g_out[x].push_back(y);
    g_in[y].push_back(x);
  }
  bool is_dag = true;
  vector<int> was(n, -1);
  function<void(int, int)> Dfs = [&](int v, int now) {
    was[v] = now;
    for (int u : g_out[v]) {
      if (was[u] != -1) {
        if (was[u] == now) {
          is_dag = false;
        }
        continue;
      }
      Dfs(u, now);
    }
  };
  int cur = 0;
  for (int i = 0; i < n; i++) {
    if (was[i] == -1) {
      Dfs(i, cur);
      if (is_dag == false) {
        cout << -1 << '\n';
        return 0;
      }
      ++cur;
    }
  }
  string res = "";
  vector<bool> mark_in(n, false);
  function<void(int)> Dfs_in = [&](int v) {
    mark_in[v] = true;
    for (int u : g_in[v]) {
      if (mark_in[u]) {
        continue;
      }
      Dfs_in(u);
    }
  };
  vector<bool> mark_out(n, false);
  function<void(int)> Dfs_out = [&](int v) {
    mark_out[v] = true;
    for (int u : g_out[v]) {
      if (mark_out[u]) {
        continue;
      }
      Dfs_out(u);
    }
  };
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (mark_in[i] || mark_out[i]) {
      res += 'E';
      if (!mark_in[i]) {
        Dfs_in(i);
      }
      if (!mark_out[i]) {
        Dfs_out(i);
      }
    } else {
      ++ans;
      res += 'A';
      Dfs_in(i);
      Dfs_out(i);
    }
  }
  cout << ans << '\n';
  cout << res << '\n';
  return 0;
}


/**
 *  author: MOOONI
 *  hackers are welcome!
**/
#include <bits/stdc++.h>

#define int long long

using namespace std;

template<typename T>
void debug_out(T x) {
  cerr << x;
}

template<typename A>
void debug_out(vector<A> v) {
  cerr << '{';
  for (int i = 0; i < (int) v.size(); i++) {
    if (i) {
      cerr << ", ";
    }
    debug_out(v[i]);
  }
  cerr << '}';
}

template <typename A, typename B>
void debug_out(pair<A, B> p) {
  cerr << '(';
  debug_out(p.first);
  cerr << ", ";
  debug_out(p.second);
  cerr << ')';
}

template <typename A, typename B, typename C>
void debug_out(tuple<A, B, C> p) {
  cerr << '(';
  debug_out(get<0>(p));
  cerr << ", ";
  debug_out(get<1>(p));
  cerr << ", ";
  debug_out(get<2>(p));
  cerr << ')';
}

template <typename A, typename B, typename C, typename D>
void debug_out(tuple<A, B, C, D> p) {
  cerr << '(';
  debug_out(get<0>(p));
  cerr << ", ";
  debug_out(get<1>(p));
  cerr << ", ";
  debug_out(get<2>(p));
  cerr << ", ";
  debug_out(get<3>(p));
  cerr << ')';
}

template <size_t N>
void debug_out(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  cerr << res;
}

template <typename T>
void debug_with_endl(T v) {
  debug_out(v);
  cerr << endl;
}

template <typename Head, typename... Tail>
void debug_with_endl(Head H, Tail... T) {
  debug_with_endl(H);
  debug_with_endl(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_with_endl(__VA_ARGS__)
#else
#define debug(...) 2003
#endif

vector<int> topsort(vector<vector<int>> &g_in, vector<vector<int>> &g_out) {
  int n = (int) g_in.size();
  vector<int> deg(n);
  for (int i = 0; i < n; i++) {
    deg[i] = (int) g_in[i].size();
  }
  vector<int> x;
  for (int i = 0; i < n; i++) {
    if (deg[i] == 0) {
      x.push_back(i);
    }
  }
  for (int p = 0; p < (int) x.size(); p++) {
    for (int v : g_out[x[p]]) {
      --deg[v];
      if (deg[v] == 0) {
        x.push_back(v);
      }
    }
  }
  if ((int) x.size() != n) {
    return vector<int>();
  }
  return x;
}

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g_in(n), g_out(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g_out[x].push_back(y);
    g_in[y].push_back(x);
  }
  auto x = topsort(g_in, g_out);
  if (x.empty()) {
    cout << -1 << '\n';
    return 0;
  }
  debug(x);
  string res = "";
  vector<bool> mark_in(n, false);
  function<void(int)> Dfs_in = [&](int v) {
    mark_in[v] = true;
    for (int u : g_in[v]) {
      if (mark_in[u]) {
        continue;
      }
      Dfs_in(u);
    }
  };
  vector<bool> mark_out(n, false);
  function<void(int)> Dfs_out = [&](int v) {
    mark_out[v] = true;
    for (int u : g_out[v]) {
      if (mark_out[u]) {
        continue;
      }
      Dfs_out(u);
    }
  };
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (mark_in[i] || mark_out[i]) {
      res += 'E';
      if (!mark_in[i]) {
        Dfs_in(i);
      }
      if (!mark_out[i]) {
        Dfs_out(i);
      }
    } else {
      ++ans;
      res += 'A';
      Dfs_in(i);
      Dfs_out(i);
    }
  }
  cout << ans << '\n';
  cout << res << '\n';
  return 0;
}


/**
 * THIS IS MOOONI'S CODE !
 * HACK IT IF YOU CAN !
**/
#include <bits/stdc++.h>

using namespace std;

/// debug

void dbg(long int x){cerr<<x;}void dbg(int x){cerr<<x;}void dbg(long long x){cerr<<x;}
void dbg(unsigned long long x){cerr<<x;}void dbg(double x){cerr<<x;}void dbg(float x){cerr<<x;}
void dbg(char x){cerr<<"'"<<x<<"'";}void dbg(bool x){cerr<<(x?"true":"false");}void dbg(string x){cerr<<'"'+x+'"';}
template<typename A,typename B>void dbg(pair<A,B>p){cerr<<'(';dbg(p.first);cerr<<", ";dbg(p.second);cerr<<')';}
template<typename A,typename B,typename C>void dbg(tuple<A,B,C>p){cerr<<'(';dbg(get<0>(p));cerr<<", ";dbg(get<1>(p));cerr<<", ";dbg(get<2>(p));cerr<<')';}
template<typename A,typename B,typename C,typename D>
void dbg(tuple<A,B,C,D>p){cerr<<'(';dbg(get<0>(p));cerr<<", ";dbg(get<1>(p));cerr<<", ";dbg(get<2>(p));cerr<<", ";dbg(get<3>(p));cerr<<')';}
template<size_t N>void dbg(bitset<N>v){string res="";for(size_t i=0;i<N;i++){res+=static_cast<char>('0'+v[i]);}cerr<<res;}
template<typename A>void dbg(vector<A>v){cerr<<'{';for(int i=0;i<(int)v.size();i++){if(i)cerr<<", ";dbg(v[i]);}cerr<<'}';}
template<typename T>void Dbg(T x){dbg(x);cerr<<endl;}
template<typename Head,typename...Tail>void Dbg(Head H,Tail...T){Dbg(H);Dbg(T...);}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:"<<endl,Dbg(__VA_ARGS__)

/// debug

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g_in(n), g_out(n);
  vector<int> deg(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g_out[x].push_back(y);
    g_in[y].push_back(x);
    ++deg[y];
  }
  vector<int> x;
  for (int i = 0; i < n; i++) {
    if (deg[i] == 0) {
      x.push_back(i);
    }
  }
  for (int ptr = 0; ptr < (int) x.size(); ptr++) {
    int v = x[ptr];
    for (int u : g_out[v]) {
      --deg[u];
      if (deg[u] == 0) {
        x.push_back(u);
      }
    }
  }
  if ((int) x.size() != n) {
    cout << -1 << '\n';
    return 0;
  }
  string res = "";
  vector<bool> mark_in(n, false);
  function<void(int)> Dfs_in = [&](int v) {
    mark_in[v] = true;
    for (int u : g_in[v]) {
      if (mark_in[u]) {
        continue;
      }
      Dfs_in(u);
    }
  };
  vector<bool> mark_out(n, false);
  function<void(int)> Dfs_out = [&](int v) {
    mark_out[v] = true;
    for (int u : g_out[v]) {
      if (mark_out[u]) {
        continue;
      }
      Dfs_out(u);
    }
  };
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (mark_in[i] || mark_out[i]) {
      res += 'E';
      if (!mark_in[i]) {
        Dfs_in(i);
      }
      if (!mark_out[i]) {
        Dfs_out(i);
      }
    } else {
      ++ans;
      res += 'A';
      Dfs_in(i);
      Dfs_out(i);
    }
  }
  cout << ans << '\n';
  cout << res << '\n';
  return 0;
}


#include <bits/stdc++.h>

#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first

using namespace std;

typedef pair < long long, long long > pll;
typedef pair < int, int > pii;
typedef unsigned long long ull;
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;
typedef long long ll;
typedef double db;

const int inf = 1e9, maxn = 1e7 + 48, mod = 1e9 + 7, N = 1e5 + 104;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;

int n, v, u, res[N], timer, ans, m;
bool was[2][N];
vi g[2][N];

void dfs (int v, int j) {
	was[j][v] = timer;
	for (auto to : g[j][v]) {
		if (was[j][to] == timer) {
		    cout << -1;
		    exit(0);
		}

		if (!was[j][to])
			dfs(to, j);
	}

}

main () {
	cin >> n >> m;
	while (m--) {
		cin >> v >> u;
		g[0][v].pb(u);
		g[1][u].pb(v);
	}

	for (int i = 1; i <= n; ++i) {
	    if (!was[0][i] && !was[1][i]) {
			res[i] = 1;
			++ans;
		}

		++timer;
		if (!was[0][i])
			dfs(i, 0);
		if (!was[1][i])
			dfs(i, 1);
	}

	cout << ans << endl;
	for (int i = 1; i <= n; ++i)
		cout << (res[i] ? 'A' : 'E');

}