// Generator created by Nikolay Budin

#ifdef DEBUG
#  define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include "testlib.h"
#define ff first
#define ss second
#define szof(x) ((int)x.size())
#ifndef LOCAL
#  define cerr __get_ce
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef unsigned long long ull;

using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename K, typename V> using ordered_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;

int const INF = (int)1e9 + 1e3;
ll const INFL = (ll)1e18 + 1e6;


int main(int argc, char* argv[]) {
	registerGen(argc, argv, 1);

	int t = opt<int>("t");
	int minn = 1, maxn = 1000000;
	if (has_opt("maxn")) {
		maxn = opt<int>("maxn");
	}
	if (has_opt("n")) {
		minn = maxn = opt<int>("n");
	}
	ll maxx = opt<ll>("maxx");

	cout << t << "\n";
	for (int tn = 1; tn <= t; ++tn) {
		setTestCase(tn);
		int n = rnd.next(minn, maxn);
		cout << n << "\n";
		ll x = rnd.next(1ll, maxx);
		for (int i = 0; i < n; ++i, ++x) {
			vector<int> digs;
			ll tmp = x;
			while (tmp) {
				digs.push_back(tmp % 10);
				tmp /= 10;
			}
			int d;
			if (has_opt("wdistr")) {
				d = digs[rnd.wnext(szof(digs), opt<int>("wdistr"))];
			} else if (has_opt("suff_len")) {
				d = digs[rnd.next(0, min(szof(digs), opt<int>("suff_len")) - 1)];
			} else {
				d = digs[rnd.next(0, szof(digs) - 1)];
			}
			cout << d;
		}
		cout << "\n";
	}

	return 0;
}