import java.io.*;
import java.util.*;

public class TestGen {

	String c(int a) {
		if (a < 10)
			return "0" + a;
		else
			return "" + a;
	}

	String timeToString(int t) {
		return c(t / 3600) + ":" + c(t % 3600 / 60) + ":" + c(t % 60);
	}

	class Flight {
		int sTime, fTime;
		int cost;
		String name;

		public Flight(String name, int sTime, int fTime, int cost) {
			super();
			this.sTime = sTime;
			this.fTime = fTime;
			this.cost = cost;
			this.name = name;
		}

		public String toString() {
			return name + " " + timeToString(sTime) + " " + timeToString(fTime)
					+ " " + cost;
		}
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	Random rnd;
	int tNumber;
	TreeSet<String> was;

	String getName() {
		String s = "";
		while (was.contains(s)) {
			s = "";
			int n = rnd.nextInt(5) + 1;
			for (int i = 0; i < n; i++) {
				if (rnd.nextBoolean())
					s = s + (char) ('A' + rnd.nextInt(26));
				else
					s = s + (char) ('0' + rnd.nextInt(10));
			}
		}
		was.add(s);
		return s;
	}

	class test {
		ArrayList<Flight> a, b;

		void clear() {
			a.clear();
			b.clear();
		}

		test() {
			a = new ArrayList<Flight>();
			b = new ArrayList<Flight>();
		}

		void printTest() throws FileNotFoundException {
			if (tNumber < 10)
				out = new PrintWriter("0" + tNumber);
			else
				out = new PrintWriter("" + tNumber);
			tNumber++;

			Collections.shuffle(a, rnd);
			Collections.shuffle(b, rnd);

			out.println(a.size());
			for (int i = 0; i < a.size(); i++) {
				out.println(a.get(i).toString());
			}

			out.println(b.size());
			for (int i = 0; i < b.size(); i++) {
				out.println(b.get(i).toString());
			}

			out.close();
		}

		void addPair(int cost) {
			int a = rnd.nextInt(3600 * 24 - 1100);
			int b = a + rnd.nextInt(3600 * 24 - 1000 - a) + 1;
			int c = b + 900 + rnd.nextInt(10) - 5;
			int d = rnd.nextInt(3600 * 24 - c - 1) + 1 + c;

			int x = rnd.nextInt(cost - 1) + 1;
			this.a.add(new Flight(getName(), a, b, x));
			this.b.add(new Flight(getName(), c, d, cost - x));
		}

		void addPair(int cost, int diff) {
			int a = rnd.nextInt(3600 * 24 - 1100);
			int b = a + rnd.nextInt(3600 * 24 - 1000 - a) + 1;
			int c = b + 900 + diff;
			int d = rnd.nextInt(3600 * 24 - c - 1) + 1 + c;

			int x = rnd.nextInt(cost - 1) + 1;
			this.a.add(new Flight(getName(), a, b, x));
			this.b.add(new Flight(getName(), c, d, cost - x));
		}

		void addRandomTo(boolean fl, int cost) {
			int a = rnd.nextInt(3600 * 24 - 5);
			int b = a + rnd.nextInt(3600 * 24 - a - 1) + 1;
			if (fl) {
				this.a.add(new Flight(getName(), a, b, cost));
			} else {
				this.b.add(new Flight(getName(), a, b, cost));
			}
		}

		void addFlight(boolean fl, Flight a) {
			if (fl) {
				this.a.add(a);
			} else {
				this.b.add(a);
			}
		}
	}

	public String nextToken() throws IOException {
		while ((st == null) || (!st.hasMoreTokens()))
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public void solve() throws IOException {
		tNumber = 2;
		rnd = new Random(31);
		was = new TreeSet<String>();
		was.add("");

		test t = new test();
		for (int i = 0; i < 5; i++) {
			t.addPair(rnd.nextInt(1000000), rnd.nextInt(3) + 1);
			int z = rnd.nextInt(5) + 2;
			for (int j = 0; j < z; j++) {
				t.addPair(rnd.nextInt(1000000), i - 2);
			}
			t.printTest();
			t.clear();
		}
		
		/*for (int i = 0; i < 10; i++) {
			int cost = rnd.nextInt(100000);
			t.addPair(cost, rnd.nextInt(3) + 1);
			int z = rnd.nextInt(3);
			for (int j = 0; j < z; j++) {
				t.addPair(cost, i);
			}
			t.printTest();
			t.clear();
		}*/
		for (int i = 0; i < 5; i++) {
			int a = rnd.nextInt(10000);
			int b = a + rnd.nextInt(5000);
			int c = b + 900;
			int d = c + rnd.nextInt(1000);
			int c1 = rnd.nextInt(1000000);
			int c2 = rnd.nextInt(1000000);
			int n = 10 + rnd.nextInt(6);
			for (int j = 0; j < n; j++) {
				if (rnd.nextBoolean()) {
					t.addFlight(true, new Flight(getName(), a + rnd.nextInt(3)
							- 6, b + rnd.nextInt(3) - 6, c1));
				} else {
					t.addFlight(false, new Flight(getName(), c + rnd.nextInt(3)
							- 6, d + rnd.nextInt(3) - 6, c2));
				}
			}
			t.printTest();
			t.clear();
		}

		for (int i = 0; i < 4; i++) {
			int n = rnd.nextInt(10000) + 90000;
			if (i == 3)
				n = 200000;
			for (int j = 0; j < n; j++) {
				t.addRandomTo(j % 2 == 0, rnd.nextInt(1000000) + 1);
			}
			t.printTest();
			t.clear();
		}
		
		for (int i = 0; i < 5; i++) {
			t.addPair(rnd.nextInt(1000000), rnd.nextInt(3) + 1);
			int z = rnd.nextInt(50000) + 50000;
			for (int j = 0; j < z; j++) {
				t.addPair(rnd.nextInt(1000000) + 2, rnd.nextInt(40) - 20);
			}
			t.printTest();
			t.clear();
		}

		for (int i = 0; i < 5; i++) {
			int a = rnd.nextInt(10000);
			int b = a + rnd.nextInt(5000) + 1001;
			int c = b + 900;
			int d = c + rnd.nextInt(1000) + 1001;
			int c1 = rnd.nextInt(1000000) + 1001;
			int c2 = rnd.nextInt(1000000) + 1001;
			int n = 150000 + rnd.nextInt(50000);
			for (int j = 0; j < n; j++) {
				if (rnd.nextBoolean()) {
					t.addFlight(true, new Flight(getName(), a + rnd.nextInt(70)
							- 35, b + rnd.nextInt(60) - 30, c1 + rnd.nextInt(40) - 20));
				} else {
					t.addFlight(false, new Flight(getName(), c + rnd.nextInt(70)
							- 35, d + rnd.nextInt(60) - 30, c2 + rnd.nextInt(40) - 20));
				}
			}
			t.printTest();
			t.clear();
		}
		
		
	}

	public void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		new TestGen().run();
	}
}