// Arup Guha
// 6/2/2017
// Solution to 2012 WF Problem E: Infiltration
// Rewritten to pass on Kattis (wrote from scratch using old solution idea adding BitSet and cleaning it up)

import java.util.*;

public class e {

	public static int n;
	public static BitSet[] bits;

	public static void main(String[] args) throws Exception {

		Scanner stdin = new Scanner(System.in);
		int loop = 1;

		// Process each case.
		while (stdin.hasNext()) {

			n = stdin.nextInt();
			bits = new BitSet[n];
			for (int i=0; i<n; i++)
				bits[i] = convert(i,stdin.next());

			solveWrapper(loop);
			loop++;
		}
	}

	public static void solveWrapper(int caseNum) throws Exception {

		// First do brute force.
		for (int i=1; i<=4; i++) {
			int res = solve(0, 0, i, -1, new BitSet());
			if (res != -1) {
				ArrayList<Integer> list = new ArrayList<Integer>();
				for (int j=0; j<i; j++) {
					list.add(res%100 + 1);
					res /= 100;
				}
				System.out.print("Case "+caseNum+": "+i);
				for (int j=0; j<i; j++)
					System.out.print(" "+list.get(j));
				System.out.println();
				return;
			}
		}

		// If we get here, we are doing the greedy.
		BitSet used = new BitSet(n);
		BitSet inSet = new BitSet(n);
		for (int i=0; i<5; i++) {
			int addItem = getBest(used,inSet);
			inSet.flip(addItem);
			used.or(bits[addItem]);

			// update bits.
			for (int j=0; j<n; j++) {
				if (used.get(j)) {
					bits[j].clear();
					for (int k=0; k<n; k++)
						bits[k].set(j, false);
				}
			}
		}

		System.out.print("Case "+caseNum+": 5");
		for (int i=0; i<n; i++)
			if (inSet.get(i))
				System.out.print(" "+(i+1));
		System.out.println();

	}

	public static int getBest(BitSet used, BitSet inSet) {

		int maxS = used.cardinality();
		int res = -1;

		for (int i=0; i<n; i++) {
			if (inSet.get(i)) continue;
			BitSet newbits = used.get(0, n);
			newbits.or(bits[i]);
			if (newbits.cardinality() > maxS) {
				res = i;
				maxS = newbits.cardinality();
			}
		}
		return res;
	}

	public static int solve(int curSet, int k, int max, int last, BitSet allBits) {

		// Filled in all max items.
		if (k == max) {
			if (allBits.cardinality() == n) return curSet;
			return -1;
		}

		for (int i=last+1; i<n; i++) {
			BitSet newbits = allBits.get(0, n);
			newbits.or(bits[i]);
			int tmp = solve(curSet*100+i, k+1, max, i, newbits);
			if (tmp != -1) return tmp;
		}

		return -1;
	}

	// Convert s to a bit set for row loc.
	public static BitSet convert(int loc, String s) {
		BitSet res = new BitSet(s.length());
		res.flip(loc);
		for (int i=0; i<s.length(); i++)
			if (s.charAt(i)=='1')
				res.flip(i);
		return res;
	}
}