// Arup Guha
// 10/9/2015
// Solution to 2001 UCF HS Contest Problem: Combination Lock

import java.util.*;

public class combo {

	final public static int SKIP = 3;
	final public static int SPOTS = 10;

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		int loop = 1;

		// Process each case.
		while (n != 0) {

			// Read in starting, ending combos.
			int[] start = new int[n];
			int[] end = new int[n];
			for (int i=0; i<n; i++) start[i] = stdin.nextInt();
			for (int i=0; i<n; i++) end[i] = stdin.nextInt();

			// Case header
			System.out.println("Lock #"+loop);
			print(start,"\n");

			int steps = 0;

			// Loop through setting each number.
			for (int i=0; i<n; i++) {

				// Loop until this digit is set.
				while (start[i] != end[i]) {
					steps++;
					start[i] = (start[i]+SKIP)%SPOTS;
					print(start,"");
					if (start[i]==end[i]) 	System.out.println("- click");
					else					System.out.println();
				}
			}

			// Output result.
			System.out.println("Locker opened in "+steps+" steps");
			System.out.println();

			// Get next case.
			n = stdin.nextInt();
			loop++;
		}
	}

	public static void print(int[] arr, String end) {
		for (int i=0; i<arr.length; i++)
			System.out.print(arr[i]+" ");
		System.out.print(end);
	}
}