#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#include <random>
typedef long double ld;

ll n;
vector<ll> x, y, r;

const ll LIM = 10000 - 1;
const int INF = 1000000000;

struct STATE {
	vector<P> loc;
	vector<P> area;
	ll score;
};

ll calc_score(STATE &state){
	ld score = 0;
	rep(i,n){
		ll R = state.area[i].first * state.area[i].second;
		ld tmp = (ld)(min(r[i], R)) / (ld)(max(r[i], R));
		score += (ld)1 - ((ld)1 - tmp) * ((ld)1 - tmp);
	}
	score *= (ld)(1000000000);
	score = floor(score);
	ll ret = score;
	ret /= n;
	return ret;
}

void isOverlapped(STATE &state, ll j, ll X, ll Y){
	vector<P> now(4);
	now[0] = P(y[j], x[j]);
	now[1] = P(y[j], x[j] + X);
	now[2] = P(y[j] + Y, x[j] + X);
	now[3] = P(y[j] + Y, x[j]);
	rep(i,n){
		if(i == j) continue;
		ll L = x[i];
		ll R = x[i] + state.area[i].second;
		ll U = y[i];
		ll D = y[i] + state.area[i].first;
		bool ok = true;
		rep(k,4){
			if(now[k].first < U) continue;
			if(D < now[k].first) continue;
			if(now[k].second < L) continue;
			if(R < now[k].second) continue;
			ok = false;
			break;
		}
		if(x[j] <= L && R <= x[j] + X && !(D <= y[j]) && !(y[j] + Y <= U)) ok = false;
		if(y[j] <= U && D <= y[j] + Y && !(R <= x[j]) && !(x[j] + X <= L)) ok = false;
		if(!ok){
			state.loc[i] = P(LIM, i);
			state.area[i] = P(1, 1);
		}
	}
	return;
}

void modify(STATE &state){
	std::random_device rnd;
	std:: mt19937 mt(rnd());
	std::uniform_int_distribution<> randN(0,n-1);
	int j = randN(mt);
	std::uniform_int_distribution<> randH(1,r[j]);
	ll h = randH(mt);
	if(y[j] + h > LIM) return;
	ll w = r[j] / h;
	if(x[j] + w > LIM) return;
	isOverlapped(state, j, w, h);
	state.loc[j] = P(y[j], x[j]);
	state.area[j] = P(h, w);
	state.score = calc_score(state);
}

void init(STATE &state){
	state.loc.resize(n);
	state.area.resize(n);
	rep(i,n){
		state.loc[i] = P(LIM, i);
		state.area[i] = P(1, 1);
	}
	state.score = calc_score(state);
}

void solve(){
	std::random_device rnd;
	std:: mt19937 mt(rnd());
	std::uniform_int_distribution<> randINF(1,INF);
	STATE state;
	init(state);
	const ld TL = 4.8;
	const ld start_temp = 1000000000;
	const ld end_temp = 10;
	//int cnt = 0;
	while(true){
		//++cnt;
		ld terminal = (ld)clock() / (ld)CLOCKS_PER_SEC;
		if(terminal >= TL) break;
		STATE new_state = state;
		ll pre_score = state.score;
		modify(new_state);
		ll new_score = new_state.score;
		ld temp = start_temp + (end_temp - start_temp) * terminal / TL;
		ld prob = exp((new_score - pre_score) / temp);
		if(prob > (randINF(mt) % INF)/(double)INF){
			state = new_state;
		}
	}
	rep(i,n){
		ll y = state.loc[i].first;
		ll x = state.loc[i].second;
		ll dy = state.area[i].first;
		ll dx = state.area[i].second;
		cout << x << " " << y << " " << x+dx << " " << y+dy << endl;
	}
	//cout << cnt << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	rep(i,n){
		ll X, Y, R;
		cin >> X >> Y >> R;
		x.push_back(X);
		y.push_back(Y);
		r.push_back(R);
	}
	solve();
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

constexpr i32 mod   = 1e9 + 7;
// constexpr i32 mod   = 998244353;

constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

constexpr i32 dx[] = {0, -1, 1, 0, -1, 1, -1, 1}; 
constexpr i32 dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

struct IoSetup { IoSetup(i32 x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != (int)v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solve() {
  int n = input();

  vector< string > ans;
  ans.emplace_back("AB");
  range(i, 1, n) {
    vector< string > na;
    for (auto &a : ans) {
      auto b = a;
      na.emplace_back(a + b);
      for (auto &c : b) {
        if (c == 'A') c = 'B';
        else c = 'A';
      }
      na.emplace_back(a + b);
    }

    na.emplace_back(string(ans[0].size(), 'A') + string(ans[0].size(), 'B'));
    ans = na;
  }
  
  cout << ans.size() << endl;
  for (auto &a : ans) cout << a << endl;
}

signed main() {
  solve();
}

