using System;
using System.Linq;

namespace takkvalifikacije
{
    class Program
    {
        static void Main()
        {
            int N, K; int[] input;

            input = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
            N = input[0];
            K = input[1];

            // k + 1: -2 ako nije vidjen, -1 ako nije pogodna, 0-N kolona pocetka
            // k + 2: 0-N kolona kraja
            // k + 3: poslednje vidjen u redu
            short[,] sortePos = new short[K + 1, 3];
            int pogodneSorte = 0;
            for (int i = 0; i < K + 1; i++)
                sortePos[i, 0] = -2;

            for (short i = 0, j; i < N; i++)
            {
                input = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
                int sorta = -1; short sortaStart = 0;
                for (j = 0; j < N; j++)
                    if (sorta != input[j])
                    {
                        azurirajPos(sortePos, i, sorta, sortaStart, j, ref pogodneSorte);
                        sorta = input[j];
                        sortaStart = j;
                    }
                if (sorta != -1) azurirajPos(sortePos, i, sorta, sortaStart, j, ref pogodneSorte);
            }
            for (int i = 0; i < K; i++)
                Console.WriteLine("{0}: kolone {1}-{2} red {3}", 1 + i, sortePos[i, 0], sortePos[i, 1], sortePos[i, 2]);
            Console.WriteLine(pogodneSorte);
            Console.ReadKey();
        }

        private static void azurirajPos(short[,] sortePos, short i, int sorta, short sortaStart, short sortaEnd, ref int pogodneSorte)
        {
            if (sorta != -1 && sortePos[sorta, 0] != -1)
            {
                if (sortePos[sorta, 0] == -2)
                {
                    pogodneSorte++;
                    sortePos[sorta, 0] = sortaStart;
                    sortePos[sorta, 1] = sortaEnd;
                    sortePos[sorta, 2] = i;
                }
                else if (sortePos[sorta, 2] == i - 1 && sortePos[sorta, 0] == sortaStart && sortePos[sorta, 1] == sortaEnd)
                {
                    sortePos[sorta, 0] = sortaStart;
                    sortePos[sorta, 1] = sortaEnd;
                    sortePos[sorta, 2] = i;
                }
                else
                {
                    pogodneSorte--;
                    sortePos[sorta, 0] = -1;
                }
            }
        }
    }
}