#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair <int, int> pin;

const int N = 2e5 + 5;
const ll P = 998244353LL;

int n, tot, head[N], ans[N], dis[N], fa[N], diaSon[N];
bool vis[N], inDia[N];
vector <int> son[N];

struct Edge {
    int to, nxt;
} e[N << 1];

inline void add(int from, int to) {
    e[++tot].to = to;
    e[tot].nxt = head[from];
    head[from] = tot;
}

template <typename T>
inline void read(T &X) {
    char ch = 0; T op = 1; 
    for (X = 0; ch > '9' || ch < '0'; ch = getchar())
        if (ch == '-') op = -1;
    for (; ch >= '0' && ch <= '9'; ch = getchar())
        X = (X * 10) + ch - '0';
    X *= op;
}

void dfs(int x, int fat) {
    for (int i = head[x]; i; i = e[i].nxt) {
        int y = e[i].to;
        if (y == fat) continue;
        fa[y] = x;
        dis[y] = dis[x] + 1;
        dfs(y, x);
    }
}

void makeFlag(int x, int fat, int b) {
    if (x == b) inDia[x] = 1;
    for (int i = head[x]; i; i = e[i].nxt) {
        int y = e[i].to;
        if (y == fat) continue;
        makeFlag(y, x, b);
        if (inDia[y]) inDia[x] = 1;
    }
}

// void getAns(int x, int now, int b) {
//     vis[x] = 1;
//     if (ans[x] == 0) ans[x] = now;
//     if (x == b) return;
//     bool flag = 0;
//     int son = 0, sonInDia = 0;
//     for (int i = head[x]; i; i = e[i].nxt) {
//         int y = e[i].to;
//         if (y == fa[x]) continue;
//         if (inDia[y]) {
//             sonInDia = y;
//             continue;
//         }
//         if (vis[y]) continue;
//         flag = 1;
//         son = y;
//         break;
//     }
//     if (flag) getAns(son, now + 1, b);
//     else {
//         if (sonInDia == 0) getAns(fa[x], now + 1, b);
//         else getAns(sonInDia, now + 1, b);
//     } 
// }

void getAns(int x, int now, int b) {
    vis[x] = 1;
    if (ans[x] == 0) ans[x] = now;
    if (x == b) return;
    if (!son[x].empty()) {
        int nowSon = son[x][son[x].size() - 1];
        son[x].pop_back();
        getAns(nowSon, now + 1, b);
    } else {
        if (diaSon[x] == 0) getAns(fa[x], now + 1, b);
        else getAns(diaSon[x], now + 1, b);
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("sample.in", "r", stdin);
    clock_t st_clock = clock();
#endif

    read(n);
    for (int x, y, i = 1; i < n; i++) {
        read(x), read(y);
        add(x, y), add(y, x);
    }
    dis[1] = 0;
    dfs(1, 0);
    int a = 1;
    for (int i = 2; i <= n; i++)
        if (dis[i] > dis[a]) a = i;
    dis[a] = 0;
    dfs(a, 0);
    int b = 1;
    for (int i = 2; i <= n; i++)
        if (dis[i] > dis[b]) b = i;
    makeFlag(a, 0, b);
    for (int x = 1; x <= n; x++) {
        for (int i = head[x]; i; i = e[i].nxt) {
            int y = e[i].to;
            if (y == fa[x]) continue;
            if (inDia[x] && inDia[y]) diaSon[x] = y;
            else son[x].push_back(y);
        }
    }
    getAns(a, 1, b);
    for (int i = 1; i <= n; i++)
        printf("%d%c", ans[i], " \n"[i == n]);

#ifndef ONLINE_JUDGE
    clock_t ed_clock = clock();
    printf("time = %f ms\n", (double)(ed_clock - st_clock) / CLOCKS_PER_SEC * 1000);
#endif
    return 0;
}
#include <bits/stdc++.h>
using namespace std;

string sdouble(string s) {
  int n = s.size();
  string s2(n*2,'a');
  for (int i = 0; i < n; i++) {
    s2[i*2] = s[i];
    s2[i*2+1] = s[i];
  }
  return s2;
}

string ssign(string s) {
  int n = s.size();
  string s2(n*2,'a');
  for (int i = 0; i < n; i++) {
    if (s[i] == 'A') {
      s2[i*2] = 'A';
      s2[i*2+1] = 'B';
    }
    else {
      s2[i*2] = 'B';
      s2[i*2+1] = 'A';
    }
  }
  return s2;
}

int main() {

  int N;
  cin >> N;
  
  int m = 1;
  for (int i = 0; i < N; i++) {
    m *= 2;
  }
  
  cout << m-1 << endl;
  
  vector<string> group(m);
  
  group[0] = "A";
  
  int m2 = 1;
  for (int i = 0; i < N; i++) {
    for (int i = 0; i < m2; i++) {
      group[i+m2] = ssign(group[i]);
      group[i] = sdouble(group[i]);
    }
    m2 *= 2;
  }
  
  for (int i = 1; i < m; i++) {
    cout << group[i] << endl;
  }
  
return 0;
}