/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{

	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	int t=Integer.parseInt(bf.readLine());
	while(t-->0)
	{
	    sum=0;
	    int n=Integer.parseInt(bf.readLine());
	    String s=bf.readLine();
	    check(97,s);
	    System.out.println(solve(s,0));
	 //   System.out.println("testcase khtm");

	}

	}
static int sum=0;
public static void check(int z,String s)
{

    int n=s.length();
    if(n==0)
    return;
    if(n==1)
    {
        if(s.charAt(0)==(char)z)
        {
            return;
        }
        else{
        sum=sum+1;
        return;
        }
    }
    if(n==2)
    {
        if(s.charAt(0)==(char)z || s.charAt(1)==(char)z)
        {
            if(s.charAt(0)==(char)z+1 || s.charAt(1)==(char)z+1)
            {
                return;

            }
            else
            {
                sum=sum+1;
                return;
            }

        }
        else
        {
            if(s.charAt(0)==(char)z+1 || s.charAt(1)==(char)z+1)
            {
                sum=sum+1;
                return;

            }
            else
            {
                sum=sum+2;
                return;
            }

        }
    }
 //   char c=(char)z;
    int a[]=new int[26];
    int b[]=new int[26];
    int req[]=new int[26];
    int len=n;
    int zz=z-97;
    while(len>0)
    {
        req[zz]=len/2;
        zz++;
        len=len/2;
    }
    int index=0;
    for(index=z-97;index<26;index++)
    {
        if(req[index]==0)
        {
            break;
        }
    }
    for(int i=0;i<n/2;i++)
    {
        int p=s.charAt(i)-97;
        a[p]++;
        if(a[p]>req[p])
        {
            a[p]=req[p];
        }

    }
    for(int i=n/2;i<n;i++)
    {
        int p=s.charAt(i)-97;
        b[p]++;
        if(b[p]>req[p])
        {
            b[p]=req[p];
        }

    }
//    System.out.println("a  "+Arrays.toString(a));
//     System.out.println("b  "+Arrays.toString(b));
    int sum1=0;
    int sum2=0;
    for(int i=(z-97)+1;i<index;i++)
    {
        sum1+=a[i];
        sum2+=b[i];
    }
    if(sum1>sum2)
    {
        sum+=n/2-b[z-97];

        String m=s.substring(0,n/2);
        check(z+1,m);

    }
    else if(sum2>sum1)
    {
        sum+=a[z-97];
        String m=s.substring(n/2,n);
        check(z+1,m);
    }

    // for(int i=z-97;i<26;i++)
    // {
    //     if(i==z-97 )
    //     {
    //     if(a[i]!=b[i])
    //     {
    //         if(a[i]>b[i])
    //         {
    //             sum=sum+(n/2-a[i]);
    //         //    System.out.println("sum1 "+sum);
    //          //   z++;
    //       //  System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
    //       String m=s.substring(n/2,n);
    //             check(z+1,m);
    //             break;
    //         }
    //         else
    //         {
    //             sum=sum+(n/2-b[i]);
    //          //   System.out.println("sum2 "+sum);
    //         //     System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
    //           //  z++;
    //           String m=s.substring(0,n/2);
    //             check(z+1,m);
    //             break;
    //         }
    //     }
    //     }
    //     else
    //     {
    //         if(a[i]!=b[i])
    //       {
    //         if(a[i]<b[i])
    //         {
    //             sum=sum+(n/2-a[z-97]);
    //          //   z++;
    //       //  System.out.println("sum3 "+sum);
    //       //   System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
    //       String m=s.substring(n/2,n);
    //             check(z+1,m);
    //             break;
    //         }
    //         else
    //         {
    //             sum=sum+(n/2-b[z-97]);
    //           //  z++;
    //       //   System.out.println("sum4 "+sum);
    //       //    System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
    //               String m=s.substring(0,n/2);
    //             check(z+1,m);

    //             break;
    //         }
    //     }
    //     else
    //     {
    //         if(i==25)
    //         {
    //             sum=sum+(n/2);
    //             String m=s.substring(0,n/2);
    //             check(z+1,m);
    //         }
    //     }

    //     }
    // }

}
public static int solve(String str,int ii){

char ch=(char)(ii+'a');

    int n=str.length();

    if(str.length()==1){
    if(str.charAt(0)==ch)
    {
        return 0;

    }
    else{

        return 1;
    }
}
int ans1=0;
for(int i=0;i<n/2;i++){
if(str.charAt(i)!=ch)
{
    ans1++;

}
}
ans1 = ans1 + solve(str.substring(n/2,n),ii+1);
    int ans2 = 0;
    for(int i=0;i<n/2;i++){
    if(str.charAt(i+n/2)!=ch)
    {
        ans2++;
    }
}
ans2 += solve(str.substring(0,n/2),ii+1);
return Math.min(ans1,ans2);

}
}


/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{

	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	int t=Integer.parseInt(bf.readLine());
	while(t-->0)
	{
	    sum=0;
	    int n=Integer.parseInt(bf.readLine());
	    String s=bf.readLine();
	    check(97,s);
	    System.out.println(sum);
	 //   System.out.println("testcase khtm");

	}

	}
static int sum=0;
public static void check(int z,String s)
{
    int start=0;
    int end=s.length()-1;
    int n=s.length();
    if(n==0)
    return;
    if(n==1)
    {
        if(s.charAt(start)==(char)z)
        {
            return;
        }
        else{
        sum=sum+1;
        return;
        }
    }
    if(n==2)
    {
        if(s.charAt(start)==(char)z || s.charAt(end)==(char)z)
        {
            if(s.charAt(start)==(char)z+1 || s.charAt(end)==(char)z+1)
            {
                return;

            }
            else
            {
                sum=sum+1;
                return;
            }

        }
        else
        {
            if(s.charAt(start)==(char)z+1 || s.charAt(end)==(char)z+1)
            {
                sum=sum+1;
                return;

            }
            else
            {
                sum=sum+2;
                return;
            }

        }
    }
 //   char c=(char)z;
    int a[]=new int[26];
    int b[]=new int[26];
    for(int i=0;i<n/2;i++)
    {
        int p=s.charAt(i)-97;
        a[p]++;

    }
    for(int i=n/2;i<n;i++)
    {
        int p=s.charAt(i)-97;
        b[p]++;

    }
//    System.out.println("a  "+Arrays.toString(a));
//     System.out.println("b  "+Arrays.toString(b));
    for(int i=z-97;i<26;i++)
    {
        if(i==z-97 )
        {
        if(a[i]!=b[i])
        {
            if(a[i]>b[i])
            {
                sum=sum+(n/2-a[i]);
            //    System.out.println("sum1 "+sum);
             //   z++;
           //  System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
           String m=s.substring(n/2,n);
                check(z+1,m);
                break;
            }
            else
            {
                sum=sum+(n/2-b[i]);
             //   System.out.println("sum2 "+sum);
            //     System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
              //  z++;
              String m=s.substring(0,n/2);
                check(z+1,m);
                break;
            }
        }
        }
        else
        {
            if(a[i]!=b[i])
          {
            if(a[i]<b[i])
            {
                sum=sum+(n/2-a[z-97]);
             //   z++;
           //  System.out.println("sum3 "+sum);
           //   System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
           String m=s.substring(n/2,n);
                check(z+1,m);
                break;
            }
            else
            {
                sum=sum+(n/2-b[z-97]);
              //  z++;
           //   System.out.println("sum4 "+sum);
           //    System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
                  String m=s.substring(0,n/2);
                check(z+1,m);

                break;
            }
        }

        }
    }

}
}


/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{

	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	int t=Integer.parseInt(bf.readLine());
	while(t-->0)
	{
	    sum=0;
	    int n=Integer.parseInt(bf.readLine());
	    String s=bf.readLine();
	    check(0,s.length()-1,n,97,s);
	    System.out.println(sum);
	 //   System.out.println("testcase khtm");

	}

	}
static int sum=0;
public static void check(int start,int end,int n,int z,String s)
{
    if(n==0)
    return;
    if(n==1)
    {
        if(s.charAt(start)==(char)z)
        {
            return;
        }
        else{
        sum=sum+1;
        return;}
    }
    if(n==2)
    {
        if(s.charAt(start)==(char)z || s.charAt(end)==(char)z)
        {
            if(s.charAt(start)==(char)z+1 || s.charAt(end)==(char)z+1)
            {
                return;

            }
            else
            {
                sum=sum+1;
                return;
            }

        }
        else
        {
            if(s.charAt(start)==(char)z+1 || s.charAt(end)==(char)z+1)
            {
                sum=sum+1;
                return;

            }
            else
            {
                sum=sum+2;
                return;
            }

        }
    }
 //   char c=(char)z;
    int a[]=new int[26];
    int b[]=new int[26];
    for(int i=start;i<=start+((end-start+1)/2)-1;i++)
    {
        int p=s.charAt(i)-97;
        a[p]++;

    }
    for(int i=(end-start+1)/2;i<=end;i++)
    {
        int p=s.charAt(i)-97;
        b[p]++;

    }
//    System.out.println("a  "+Arrays.toString(a));
//     System.out.println("b  "+Arrays.toString(b));
    for(int i=z-97;i<26;i++)
    {
        if(i==z-97 )
        {
        if(a[i]!=b[i])
        {
            if(a[i]>b[i])
            {
                sum=sum+(n/2-a[i]);
            //    System.out.println("sum1 "+sum);
             //   z++;
           //  System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
                check((start+(end-start+1)/2),end,n/2,(z+1),s);
                break;
            }
            else
            {
                sum=sum+(n/2-b[i]);
             //   System.out.println("sum2 "+sum);
            //     System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
              //  z++;
                check(start,(start+(end-start+1)/2)-1,n/2,(z+1),s);
                break;
            }
        }
        }
        else
        {
            if(a[i]!=b[i])
          {
            if(a[i]<b[i])
            {
                sum=sum+(n/2-a[z-97]);
             //   z++;
           //  System.out.println("sum3 "+sum);
           //   System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
                check(start+(end-start+1)/2,end,n/2,(z+1),s);
                break;
            }
            else
            {
                sum=sum+(n/2-b[z-97]);
              //  z++;
           //   System.out.println("sum4 "+sum);
           //    System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
                check(start,(start+(end-start+1)/2)-1,n/2,(z+1),s);

                break;
            }
        }

        }
    }

}
}


/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{

	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	int t=Integer.parseInt(bf.readLine());
	while(t-->0)
	{
	    sum=0;
	    int n=Integer.parseInt(bf.readLine());
	    String s=bf.readLine();
	    check(97,s);
	    System.out.println(sum);
	 //   System.out.println("testcase khtm");

	}

	}
static int sum=0;
public static void check(int z,String s)
{

    int n=s.length();
    if(n==0)
    return;
    if(n==1)
    {
        if(s.charAt(0)==(char)z)
        {
            return;
        }
        else{
        sum=sum+1;
        return;
        }
    }
    if(n==2)
    {
        if(s.charAt(0)==(char)z || s.charAt(1)==(char)z)
        {
            if(s.charAt(0)==(char)z+1 || s.charAt(1)==(char)z+1)
            {
                return;

            }
            else
            {
                sum=sum+1;
                return;
            }

        }
        else
        {
            if(s.charAt(0)==(char)z+1 || s.charAt(1)==(char)z+1)
            {
                sum=sum+1;
                return;

            }
            else
            {
                sum=sum+2;
                return;
            }

        }
    }
 //   char c=(char)z;
    int a[]=new int[26];
    int b[]=new int[26];
    for(int i=0;i<n/2;i++)
    {
        int p=s.charAt(i)-97;
        a[p]++;

    }
    for(int i=n/2;i<n;i++)
    {
        int p=s.charAt(i)-97;
        b[p]++;

    }
//    System.out.println("a  "+Arrays.toString(a));
//     System.out.println("b  "+Arrays.toString(b));
    for(int i=z-97;i<26;i++)
    {
        if(i==z-97 )
        {
        if(a[i]!=b[i])
        {
            if(a[i]>b[i])
            {
                sum=sum+(n/2-a[i]);
            //    System.out.println("sum1 "+sum);
             //   z++;
           //  System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
           String m=s.substring(n/2,n);
                check(z+1,m);
                break;
            }
            else
            {
                sum=sum+(n/2-b[i]);
             //   System.out.println("sum2 "+sum);
            //     System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
              //  z++;
              String m=s.substring(0,n/2);
                check(z+1,m);
                break;
            }
        }
        }
        else
        {
            if(a[i]!=b[i])
          {
            if(a[i]<b[i])
            {
                sum=sum+(n/2-a[z-97]);
             //   z++;
           //  System.out.println("sum3 "+sum);
           //   System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
           String m=s.substring(n/2,n);
                check(z+1,m);
                break;
            }
            else
            {
                sum=sum+(n/2-b[z-97]);
              //  z++;
           //   System.out.println("sum4 "+sum);
           //    System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
                  String m=s.substring(0,n/2);
                check(z+1,m);

                break;
            }
        }

        }
    }

}
}


/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{

	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	int t=Integer.parseInt(bf.readLine());
	while(t-->0)
	{
	    sum=0;
	    int n=Integer.parseInt(bf.readLine());
	    String s=bf.readLine();
	    check(97,s);
	    System.out.println(sum);
	 //   System.out.println("testcase khtm");

	}

	}
static int sum=0;
public static void check(int z,String s)
{

    int n=s.length();
    if(n==0)
    return;
    if(n==1)
    {
        if(s.charAt(0)==(char)z)
        {
            return;
        }
        else{
        sum=sum+1;
        return;
        }
    }
    if(n==2)
    {
        if(s.charAt(0)==(char)z || s.charAt(1)==(char)z)
        {
            if(s.charAt(0)==(char)z+1 || s.charAt(1)==(char)z+1)
            {
                return;

            }
            else
            {
                sum=sum+1;
                return;
            }

        }
        else
        {
            if(s.charAt(0)==(char)z+1 || s.charAt(1)==(char)z+1)
            {
                sum=sum+1;
                return;

            }
            else
            {
                sum=sum+2;
                return;
            }

        }
    }
 //   char c=(char)z;
    int a[]=new int[26];
    int b[]=new int[26];
    for(int i=0;i<n/2;i++)
    {
        int p=s.charAt(i)-97;
        a[p]++;

    }
    for(int i=n/2;i<n;i++)
    {
        int p=s.charAt(i)-97;
        b[p]++;

    }
//    System.out.println("a  "+Arrays.toString(a));
//     System.out.println("b  "+Arrays.toString(b));
    for(int i=z-97;i<26;i++)
    {
        if(i==z-97 )
        {
        if(a[i]!=b[i])
        {
            if(a[i]>b[i])
            {
                sum=sum+(n/2-a[i]);
            //    System.out.println("sum1 "+sum);
             //   z++;
           //  System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
           String m=s.substring(n/2,n);
                check(z+1,m);
                break;
            }
            else
            {
                sum=sum+(n/2-b[i]);
             //   System.out.println("sum2 "+sum);
            //     System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
              //  z++;
              String m=s.substring(0,n/2);
                check(z+1,m);
                break;
            }
        }
        }
        else
        {
            if(a[i]!=b[i])
          {
            if(a[i]<b[i])
            {
                sum=sum+(n/2-a[z-97]);
             //   z++;
           //  System.out.println("sum3 "+sum);
           //   System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
           String m=s.substring(n/2,n);
                check(z+1,m);
                break;
            }
            else
            {
                sum=sum+(n/2-b[z-97]);
              //  z++;
           //   System.out.println("sum4 "+sum);
           //    System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
                  String m=s.substring(0,n/2);
                check(z+1,m);

                break;
            }
        }
        else
        {
            if(i==25)
            {
                sum=sum+(n/2);
                String m=s.substring(0,n/2);
                check(z+1,m);
            }
        }

        }
    }

}
}


/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{

	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	int t=Integer.parseInt(bf.readLine());
	while(t-->0)
	{
	    sum=0;
	    int n=Integer.parseInt(bf.readLine());
	    String s=bf.readLine();
	    check(0,s.length()-1,n,97,s);
	    System.out.println(sum);
	 //   System.out.println("testcase khtm");

	}

	}
static int sum=0;
public static void check(int start,int end,int n,int z,String s)
{
    if(n==0)
    return;
    if(n==1)
    {
        if(s.charAt(start)==(char)z)
        {
            return;
        }
        else
        sum=sum+1;
        return;
    }
    if(n==2)
    {
        if(s.charAt(start)==(char)z || s.charAt(end)==(char)z)
        {
            if(s.charAt(start)==(char)z+1 || s.charAt(end)==(char)z+1)
            {
                return;

            }
            else
            {
                sum=sum+1;
                return;
            }

        }
        else
        {
            if(s.charAt(start)==(char)z+1 || s.charAt(end)==(char)z+1)
            {
                sum=sum+1;
                return;

            }
            else
            {
                sum=sum+2;
                return;
            }

        }
    }
 //   char c=(char)z;
    int a[]=new int[26];
    int b[]=new int[26];
    for(int i=start;i<=start+((end-start+1)/2)-1;i++)
    {
        int p=s.charAt(i)-97;
        a[p]++;

    }
    for(int i=(end-start+1)/2;i<=end;i++)
    {
        int p=s.charAt(i)-97;
        b[p]++;

    }
//    System.out.println("a  "+Arrays.toString(a));
//     System.out.println("b  "+Arrays.toString(b));
    for(int i=z-97;i<26;i++)
    {
        if(i==z-97 )
        {
        if(a[i]!=b[i])
        {
            if(a[i]>b[i])
            {
                sum=sum+(n/2-a[i]);
            //    System.out.println("sum1 "+sum);
             //   z++;
           //  System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
                check((start+(end-start+1)/2),end,n/2,(z+1),s);
                break;
            }
            else
            {
                sum=sum+(n/2-b[i]);
             //   System.out.println("sum2 "+sum);
            //     System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
              //  z++;
                check(start,(start+(end-start+1)/2)-1,n/2,(z+1),s);
                break;
            }
        }
        }
        else
        {
            if(a[i]!=b[i])
          {
            if(a[i]<b[i])
            {
                sum=sum+(n/2-a[z-97]);
             //   z++;
           //  System.out.println("sum3 "+sum);
           //   System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
                check(start+(end-start+1)/2,end,n/2,(z+1),s);
                break;
            }
            else
            {
                sum=sum+(n/2-b[z-97]);
              //  z++;
           //   System.out.println("sum4 "+sum);
           //    System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
                check(start,(start+(end-start+1)/2)-1,n/2,(z+1),s);

                break;
            }
        }

        }
    }

}
}


/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{

	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	int t=Integer.parseInt(bf.readLine());
	while(t-->0)
	{
	    sum=0;
	    int n=Integer.parseInt(bf.readLine());
	    String s=bf.readLine();
	    check(0,s.length()-1,n,97,s);
	    System.out.println(sum);
	 //   System.out.println("testcase khtm");

	}

	}
static int sum=0;
public static void check(int start,int end,int n,int z,String s)
{
    if(n==0)
    return;
    if(n==1)
    {
        if(s.charAt(start)==(char)z)
        {
            return;
        }
        else
        sum=sum+1;
        return;
    }
    if(n==2)
    {
        if(s.charAt(start)==(char)z || s.charAt(end)==(char)z)
        {
            if(s.charAt(start)==(char)z+1 || s.charAt(end)==(char)z+1)
            {
                return;

            }
            else
            {
                sum=sum+1;
                return;
            }

        }
        else
        {
            if(s.charAt(start)==(char)z+1 || s.charAt(end)==(char)z+1)
            {
                sum=sum+1;
                return;

            }
            else
            {
                sum=sum+2;
                return;
            }

        }
    }
 //   char c=(char)z;
    int a[]=new int[26];
    int b[]=new int[26];
    for(int i=start;i<=start+((end-start+1)/2)-1;i++)
    {
        int p=s.charAt(i)-97;
        a[p]++;

    }
    for(int i=(end-start+1)/2;i<=end;i++)
    {
        int p=s.charAt(i)-97;
        b[p]++;

    }
//    System.out.println("a  "+Arrays.toString(a));
//     System.out.println("b  "+Arrays.toString(b));
int minu=z-97;
    for(int i=z-97;i<26;i++)
    {
        if(i==z-97 )
        {
        if(a[i]!=b[i])
        {
            if(a[i]>b[i])
            {
                sum=sum+(n/2-a[minu]);
            //    System.out.println("sum1 "+sum);
             //   z++;
           //  System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
                check((start+(end-start+1)/2),end,n/2,(z+1),s);
                break;
            }
            else
            {
                sum=sum+(n/2-b[minu]);
             //   System.out.println("sum2 "+sum);
            //     System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
              //  z++;
                check(start,(start+(end-start+1)/2)-1,n/2,(z+1),s);
                break;
            }
        }
        }
        else
        {
            if(a[i]!=b[i])
          {
            if(a[i]<b[i])
            {
                sum=sum+(n/2-a[minu]);
             //   z++;
           //  System.out.println("sum3 "+sum);
           //   System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
                check(start+(end-start+1)/2,end,n/2,(z+1),s);
                break;
            }
            else
            {
                sum=sum+(n/2-b[minu]);
              //  z++;
           //   System.out.println("sum4 "+sum);
           //    System.out.println(((end-start+1)/2)+" "+end+" "+n/2+" "+(z+1)+" "+s);
                check(start,(start+(end-start+1)/2)-1,n/2,(z+1),s);

                break;
            }
        }

        }
    }

}
}


import java.util.*;
public class cfgs{

    static int goods(String s,int strs,int stre,int ctf)
    {
        if(strs==stre)
        {
            char c=(char)(97+ctf);

            if(s.charAt(strs)!=c)
            return 1;
            else
            return 0;
        }

        int lc=0;
        int rc=0;

        char c=(char)(97+ctf);

        int i=0;
        int k=(stre-strs+1)/2;
        while(k>0)
        {

            char cl=s.charAt(strs+i);
            char cr=s.charAt(stre-i);
            if(cl==c)
            lc++;
            if(cr==c)
            rc++;

            i++;
            k--;
        }

        int count=0;

        if(lc>rc)
        {
            count=(stre-strs+1)/2-lc;
            int con=goods(s,((stre+strs)/2)+1,stre,ctf+1);
            count=count+con;
        }

        else if(lc<rc)
        {
            count=(stre-strs+1)/2-rc;
            int con=goods(s,strs,((stre+strs)/2),ctf+1);
            count=count+con;

        }
        else
{
    count=(stre-strs+1)/2-lc;
            int conl=goods(s,((stre+strs)/2)+1,stre,ctf+1);
            int conr=goods(s,strs,((stre+strs)/2),ctf+1);
            count=count+Math.min(conl,conr);

}

        return count;
    }

    public static void main(String[]args)
    {

        Scanner scn=new Scanner(System.in);
        int tc=scn.nextInt();
        for(int i=0;i<tc;i++)
        {

            int n=scn.nextInt();
            String s=scn.next();

            int res=goods(s,0,s.length()-1,0);
            System.out.println(res);
        }

    }

}


import java.util.*;
public class cfgs{

    static int goods(String s,int strs,int stre,int ctf)
    {
        if(strs==stre)
        {
            char c=(char)(97+ctf);

            if(s.charAt(strs)!=c)
            return 1;
            else
            return 0;
        }

        int lc=0;
        int rc=0;

        char c=(char)(97+ctf);

        int i=0;
        int k=(stre-strs+1)/2;
        while(k>0)
        {

            char cl=s.charAt(strs+i);
            char cr=s.charAt(stre-i);
            if(cl==c)
            lc++;
            if(cr==c)
            rc++;

            i++;
            k--;
        }

        int countl=0;
            int countr=0;
            int conl=goods(s,((stre+strs)/2)+1,stre,ctf+1);
            int conr=goods(s,strs,((stre+strs)/2),ctf+1);

            countl=(stre-strs+1)/2-lc+conl;

             countr=(stre-strs+1)/2-rc+conr;

             int count=Math.min(countl,countr);

        return count;
    }

    public static void main(String[]args)
    {

        Scanner scn=new Scanner(System.in);
        int tc=scn.nextInt();
        for(int i=0;i<tc;i++)
        {

            int n=scn.nextInt();
            String s=scn.next();

            int res=goods(s,0,s.length()-1,0);
            System.out.println(res);
        }

    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.*;

public class D {
	public static int replace(String s,char c) {
		int ans=0;
		for(char c1:s.toCharArray())
			if(c1!=c) ans++;

		return ans;
	}

	public static int solve(String s,char c) {
		if(s.length()==1)
			return s.charAt(0)==c? 0:1;
		if(s.length()==2) {
			int diff= Math.abs(s.charAt(0)-s.charAt(1));
			//System.out.println(s+" "+diff);
			if (diff==1&&((s.charAt(0)==c&&s.charAt(1)==c+1)||(s.charAt(0)==c+1&&s.charAt(1)==c))) return 0;

			if(s.charAt(0)==c||s.charAt(1)==c||s.charAt(0)==c+1||s.charAt(1)==c+1) return 1;

			else return 2;

		}
		int n=s.length();

		int ans1= solve(s.substring(0,n/2), (char) (c+1))+ replace(s.substring(n/2), c);
		int ans2= replace(s.substring(0,n/2), c)+ solve(s.substring(n/2), (char) (c+1));

		return Math.min(ans1, ans2);

	}

	public static void main(String[] args) {
		FastScanner scanner=new FastScanner();

		int t=scanner.nextInt();
		while(t-->0) {
			int n=scanner.nextInt();
			String string=scanner.next();
			int res= solve(string, 'a');
			System.out.println(res);

		}

		}

	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.*;

public class Main {
	public static int replace(String s,char c) {
		int ans=0;
		for(char c1:s.toCharArray())
			if(c1!=c) ans++;

		return ans;
	}

	public static int solve(String s,char c) {
		if(s.length()==1)
			return s.charAt(0)==c? 0:1;
		if(s.length()==2) {
			int diff= Math.abs(s.charAt(0)-s.charAt(1));
			//System.out.println(s+" "+diff);
			if (diff==1&&(s.charAt(0)==c||s.charAt(1)==c)) return 0;

			if(s.charAt(0)==c||s.charAt(1)==c||s.charAt(0)==c+1||s.charAt(1)==c+1) return 1;

			else return 2;

		}
		int n=s.length();

		int ans1= solve(s.substring(0,n/2), (char) (c+1))+ replace(s.substring(n/2), c);
		int ans2= replace(s.substring(0,n/2), c)+ solve(s.substring(n/2), (char) (c+1));

		return Math.min(ans1, ans2);

	}

	public static void main(String[] args) {
		FastScanner scanner=new FastScanner();

		int t=scanner.nextInt();
		while(t-->0) {
			int n=scanner.nextInt();
			String string=scanner.next();
			int res= solve(string, 'a');
			System.out.println(res);

		}

		}

	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
}

}


#include <bits/stdc++.h>

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (int i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 1e6, msz = 5e6, lgsz = 20;
int n, m, r, c, el, er = -1, dp[nsz + 5][lgsz + 5], fm[nsz + 5], pre[msz + 5];
string s, dat[nsz + 5];

int inline qry(int fm) {
    for (int k = lgsz; k >= 0; --k) {
        if ((r >> k) & 1) {
            fm += dp[fm][k];
        }
    }
    return fm;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n >> r >> c;
    m = 1;
    cont (i, n) {
        cin >> dat[i];
        fm[i] = m;
        m += dat[i].size() + 1;
        ++pre[m - 2];
    }
    cont (i, m) {
        pre[i] += pre[i - 1];
    }
    cont (i, n) {
        dp[i][0] = pre[min(m, fm[i] + c - 1)] - pre[fm[i] - 1];
    }
    cont (k, lgsz) {
        cont (u, n) {
            int p = dp[u][k - 1];
            dp[u][k] = p + dp[u + p][k - 1];
        }
    }
    cont (i, n) {
        int l = i, r = qry(i) - 1;
        if (r - l + 1 > er - el + 1) {
            el = l, er = r;
        }
    }
    for (int i = el, cur = 0; i <= er; cur = 0) {
        for (; i <= er && cur + dat[i].size() <= c; cur += dat[i].size() + 1, ++i) {
            if (cur != 0) {
                cout << ' ';
            }
            cout << dat[i];
        }
        cout << ln;
    }
}


#include <bits/stdc++.h>

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (int i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 1e6, msz = 6e6, lgsz = 20;
int n, m, r, c, el, er = -1, dp[nsz + 5][lgsz + 5], fm[nsz + 5], pre[msz + 5];
string s, dat[nsz + 5];

int inline qry(int fm) {
    for (int k = lgsz; k >= 0; --k) {
        if ((r >> k) & 1) {
            fm += dp[fm][k];
        }
    }
    return fm;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n >> r >> c;
    m = 1;
    cont (i, n) {
        cin >> dat[i];
        fm[i] = m;
        m += dat[i].size() + 1;
        ++pre[m - 2];
    }
    cont (i, m) {
        pre[i] += pre[i - 1];
    }
    cont (i, n) {
        dp[i][0] = pre[min(m, fm[i] + c - 1)] - pre[fm[i] - 1];
    }
    cont (k, lgsz) {
        cont (u, n) {
            int p = dp[u][k - 1];
            dp[u][k] = p + dp[u + p][k - 1];
        }
    }
    cont (i, n) {
        int l = i, r = qry(i) - 1;
        if (r - l + 1 > er - el + 1) {
            el = l, er = r;
        }
    }
    for (int i = el, cur = 0; i <= er; cur = 0) {
        for (; i <= er && cur + dat[i].size() <= c; cur += dat[i].size() + 1, ++i) {
            if (cur != 0) {
                cout << ' ';
            }
            cout << dat[i];
        }
        cout << ln;
    }
}


#include <bits/stdc++.h>

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (int i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 1e6, msz = 5e6, lgsz = 20;
int n, m, r, c, el, er = -1, dp[nsz + 5][lgsz + 5], fm[nsz + 5], pre[msz + 5];
string s, dat[nsz + 5];

int inline qry(int fm) {
    for (int k = lgsz; k >= 0; --k) {
        if ((r >> k) & 1) {
            fm += dp[fm][k];
        }
    }
    return fm;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n >> r >> c;
    m = 1;
    cont (i, n) {
        cin >> dat[i];
        fm[i] = m;
        m += dat[i].size() + 1;
        ++pre[m - 2];
    }
    cont (i, m) {
        pre[i] += pre[i - 1];
    }
    cont (i, n) {
        dp[i][0] = pre[min(m, fm[i] + c - 1)] - pre[fm[i] - 1];
    }
    cont (k, lgsz) {
        cont (u, n) {
            int p = dp[u][k - 1];
            dp[u][k] = p + dp[u + p][k - 1];
        }
    }
    cont (i, n) {
        int l = i, r = qry(i) - 1;
        if (r - l + 1 > er - el + 1) {
            el = l, er = r;
        }
    }
    for (int i = el, cur = 0; i <= er; cur = 0) {
        for (; i <= er && cur + dat[i].size() <= c; cur += dat[i].size() + 1, ++i) {
            cout << dat[i] << ' ';
        }
        cout << ln;
    }
}


#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;

const int N = 1e6 + 5;

int n, r, c, a[N], nxt[N][21];
string s[N];

int get_idx(int cur) {
  int res = cur;
  for (int i = 20; i >= 0; i--) {
    if (((r >> i) & 1) == 1) {
      res = nxt[res][i];
    }
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> r >> c;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    a[i] = sz(s[i]);
  }
  int p = 0;
  int cur = 0;
  int cnt = 0;
  nxt[n + 1][0] = n + 1;
  for (int i = 1; i <= n; i++) {
    while (p <= n && cur + cnt - 1 <= c) {
      cur += a[++p];
      cnt++;
    }
    nxt[i][0] = p;

    cur -= a[i];
    cnt--;
  }
  for (int j = 1; j <= 20; j++) {
    for (int i = 1; i <= n + 1; i++) {
      nxt[i][j] = nxt[nxt[i][j - 1]][j - 1];
    }
  }
  /* for (int i = 1; i <= n; i++) { */
  /*   cout << nxt[i][1] << "\n"; */
  /* } */
  int mx = 0;
  p = -1;
  for (int i = 1; i <= n; i++) {
    int j = get_idx(i);
    if (i == j) {
      continue;
    }
    if (j - i > mx) {
      mx = j - i;
      p = i;
    }
  }
  cur = 1;
  for (int i = p; i <= p + mx - 1;) {
    if (cur > r) {
      break;
    }
    int cur_length = sz(s[i]);
    cout << s[i++] << " ";
    while (i <= n) {
      if ((cur_length + 1 + sz(s[i])) > c) {
        break;
      }
      cur_length += sz(s[i]);
      cout << s[i++] << " ";
    }
    cout << "\n";
    cur++;
  }
}


#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;

const int N = 1e6 + 5;

int n, r, c, a[N], nxt[N][21];
string s[N];

int get_idx(int cur) {
  int res = cur;
  for (int i = 20; i >= 0; i--) {
    if (((r >> i) & 1) == 1) {
      res = nxt[res][i];
    }
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> r >> c;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    a[i] = sz(s[i]);
  }
  int p = 0;
  int cur = 0;
  int cnt = 0;
  nxt[n + 1][0] = n + 1;
  for (int i = 1; i <= n; i++) {
    while (p <= n && cur + cnt - 1 <= c) {
      cur += a[++p];
      cnt++;
    }
    nxt[i][0] = p;

    cur -= a[i];
    cnt--;
  }
  for (int j = 1; j <= 20; j++) {
    for (int i = 1; i <= n + 1; i++) {
      nxt[i][j] = nxt[nxt[i][j - 1]][j - 1];
    }
  }
  /* for (int i = 1; i <= n; i++) { */
  /*   cout << nxt[i][1] << "\n"; */
  /* } */
  int mx = 0;
  p = -1;
  for (int i = 1; i <= n; i++) {
    int j = get_idx(i);
    if (i == j) {
      continue;
    }
    if (j - i > mx) {
      mx = j - i;
      p = i;
    }
  }
  cur = 1;
  for (int i = p; i <= p + mx - 1;) {
    if (cur > r) {
      break;
    }
    int cur_length = sz(s[i]);
    cout << s[i++];
    while (i <= p + mx - 1) {
      if ((cur_length + 1 + sz(s[i])) > c) {
        break;
      }
      cur_length += 1 + sz(s[i]);
      cout << " " << s[i++];
    }
    cout << "\n";
    cur++;
  }
}


#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;

const int N = 1e6 + 5;

int n, r, c, a[N], nxt[N][21];
string s[N];

int get_idx(int cur) {
  int res = cur;
  for (int i = 20; i >= 0; i--) {
    if (((r >> i) & 1) == 1) {
      res = nxt[res][i];
    }
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> r >> c;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    a[i] = sz(s[i]);
  }
  int p = 0;
  int cur = 0;
  int cnt = 0;
  nxt[n + 1][0] = n + 1;
  for (int i = 1; i <= n; i++) {
    while (p <= n && cur + cnt - 1 <= c) {
      cur += a[++p];
      cnt++;
    }
    nxt[i][0] = p;

    cur -= a[i];
    cnt--;
  }
  for (int j = 1; j <= 20; j++) {
    for (int i = 1; i <= n + 1; i++) {
      nxt[i][j] = nxt[nxt[i][j - 1]][j - 1];
    }
  }
  /* for (int i = 1; i <= n; i++) { */
  /*   cout << nxt[i][1] << "\n"; */
  /* } */
  int mx = 0;
  p = -1;
  for (int i = 1; i <= n; i++) {
    int j = get_idx(i);
    if (i == j) {
      continue;
    }
    if (j - i > mx) {
      mx = j - i;
      p = i;
    }
  }
  cur = 1;
  for (int i = p; i <= p + mx - 1;) {
    if (cur > r) {
      break;
    }
    int cur_length = sz(s[i]);
    cout << s[i++];
    while (i <= n) {
      if ((cur_length + 1 + sz(s[i])) > c) {
        break;
      }
      cur_length += sz(s[i]);
      cout << " " << s[i++];
    }
    cout << "\n";
    cur++;
  }
}


#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define pb push_back
#define all(_obj) _obj.begin(),_obj.end()
#define F first
#define S second
#define INF 1e18
#define pll pair<ll, ll>
#define vll vector<ll>
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=1e6+11;
inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b) {if(b==0) return a;a%=b;return gcd(b,a);}
inline vll read(int n) {vll v(n);for (int i = 0; i < v.size(); i++)cin>>v[i];return v;}
int parent[MAXN];
int dp[MAXN][20];
int findKth(int a, int k)
{
    int c = a;
    int cur_level = k;
    for(int i = 19; i >= 0; i--)
    {
        if(dp[c][i] != -1 && (1 << i) <= cur_level)
        {
            c = dp[c][i];
            cur_level = cur_level - (1 << i);
        }
    }
    return c;
}
void calc(void)
{
memset(dp,-1,sizeof(dp));
for(int i = 0; i < MAXN; i++)
dp[i][0] = parent[i];
for(int h = 1; h < 20; h++)
for(int i = 0; i < MAXN; i++)
if(dp[i][h-1]!=-1)
dp[i][h] = dp[dp[i][h-1]][h-1];
}
void solveforthiscase(const int & test)
{
memset(parent,-1,sizeof(parent));
int r;
cin>>n>>r>>c;
vector<string> v;
for(int i=0;i<n;i++)
{
    string s;
    cin>>s;
    v.pb(s);
}
int nxt=-1,ch=0;
for(int i=0;i<n;i++)
{
 while(nxt<n && ch<=c+1)
 {
 nxt++;
 ch+=v[nxt].size();
 ch++;
 }
 parent[i]=nxt;
 ch-=v[i].size();
 ch--;
}
calc();
int mx=0,ans=-1;
for(int i=0;i<n;i++)
if(mx<findKth(i,r)-i)
mx=findKth(i,r)-i,ans=i;
if(ans!=-1)
{
    int start=ans;
    while(r-- && start<n)
    {
    for(int i=start;i<parent[start];i++)
    cout<<v[i]<<' ';
    cout<<'\n';
    start=parent[start];
    }
}
return ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    clock_t start, end;
    start = clock();
    int test=1;
    //cin>>test;
    for(int i=1;i<=test;i++)
    solveforthiscase(i);
    end = clock();
    long double t_t = (long double)(end - start) /(long double)(CLOCKS_PER_SEC);
    cerr << (long double)t_t*1000<< " ms ";
}


#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define pb push_back
#define all(_obj) _obj.begin(),_obj.end()
#define F first
#define S second
#define INF 1e18
#define pll pair<ll, ll>
#define vll vector<ll>
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=1e6+11;
inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b) {if(b==0) return a;a%=b;return gcd(b,a);}
inline vll read(int n) {vll v(n);for (int i = 0; i < v.size(); i++)cin>>v[i];return v;}
int parent[MAXN];
int dp[MAXN][20];
int findKth(int a, int k)
{
    int c = a;
    int cur_level = k;
    for(int i = 19; i >= 0; i--)
    {
        if(dp[c][i] != -1 && (1 << i) <= cur_level)
        {
            c = dp[c][i];
            cur_level = cur_level - (1 << i);
        }
    }
    return c;
}
void calc(void)
{
memset(dp,-1,sizeof(dp));
for(int i = 0; i < MAXN; i++)
dp[i][0] = parent[i];
for(int h = 1; h < 20; h++)
for(int i = 0; i < MAXN; i++)
if(dp[i][h-1]!=-1)
dp[i][h] = dp[dp[i][h-1]][h-1];
}
void solveforthiscase(const int & test)
{
memset(parent,-1,sizeof(parent));
int r;
cin>>n>>r>>c;
vector<string> v;
for(int i=0;i<n;i++)
{
    string s;
    cin>>s;
    v.pb(s);
}
int nxt=-1,ch=0;
for(int i=0;i<n;i++)
{
 while(nxt<n && ch<=c+1)
 {
 nxt++;
 ch+=v[nxt].size();
 ch++;
 }
 parent[i]=nxt;
 ch-=v[i].size();
 ch--;
}
calc();
int mx=0,ans=-1;
for(int i=0;i<n;i++)
if(mx<findKth(i,r)-i)
mx=findKth(i,r)-i,ans=i;
if(ans!=-1)
{
    int start=ans;
    while(r-- && start<n)
    {
    for(int i=start;i<parent[start];i++)
    if(i==parent[start]-1)
    cout<<v[i];
    else
    cout<<v[i]<<' ';
    cout<<'\n';
    start=parent[start];
    }
}
return ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    clock_t start, end;
    start = clock();
    int test=1;
    //cin>>test;
    for(int i=1;i<=test;i++)
    solveforthiscase(i);
    end = clock();
    long double t_t = (long double)(end - start) /(long double)(CLOCKS_PER_SEC);
    cerr << (long double)t_t*1000<< " ms ";
}


#include <bits/stdc++.h>

#define ll long long
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int, int>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

// solve for c = 1 using two-pointers.
// get c = 2 by combining c = 1 answers, and so on.
// similar to repeated squaring to compute a^b mod m
// Then we can get answer by bitmasks
// O(n log c)

const int N = 1e6 + 5;
int n, r, c, len[N], ans[N][20], opt[N];
string s[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> r >> c;
    rep(i, 0, n) {
        cin >> s[i];
        len[i] = s[i].length();
    }
    int j = 0, L = -1;
    rep(i, 0, n) {
        while(j < n && L + len[j] + 1 <= c) {
            L += len[j] + 1;
            j++;
        }
        ans[i][0] = j;
        if(r & 1) {
            opt[i] = j;
        }else {
            opt[i] = i;
        }
        L -= len[i] + 1;
    }
    rep(l, 1, 20) {
        rep(i, 0, n) {
            ans[i][l] = ans[ans[i][l - 1]][l - 1];
        }
        if((r >> l) & 1) {
            rep(i, 0, n) {
                opt[i] = ans[opt[i]][l];
            }
        }
    }
    int mx = -1, idx = 0;
    rep(i, 0, n) {
        if(opt[i] - i > mx) {
            mx = opt[i] - i;
            idx = i;
        }
    }
    rep(i, 0, r) {
        rep(j, idx, ans[idx][0]) {
            cout << s[j];
            if(j < ans[idx][0]) cout << ' ';
        }
        cout << '\n';
        idx = ans[idx][0];
    }
}


#include <bits/stdc++.h>

#define ll long long
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int, int>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

// solve for c = 1 using two-pointers.
// get c = 2 by combining c = 1 answers, and so on.
// similar to repeated squaring to compute a^b mod m
// Then we can get answer by bitmasks
// O(n log c)

const int N = 1e6 + 5;
int n, r, c, len[N], ans[N][20], opt[N];
string s[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> r >> c;
    rep(i, 0, n) {
        cin >> s[i];
        len[i] = s[i].length();
    }
    int j = 0, L = -1;
    ans[n][0] = n;
    rep(i, 0, n) {
        while(j < n && L + len[j] + 1 <= c) {
            L += len[j] + 1;
            j++;
        }
        ans[i][0] = j;
        if(r & 1) {
            opt[i] = j;
        }else {
            opt[i] = i;
        }
        L -= len[i] + 1;
    }
    rep(l, 1, 20) {
        rep(i, 0, n) {
            ans[i][l] = ans[ans[i][l - 1]][l - 1];
        }
        ans[n][l] = n;
        if((r >> l) & 1) {
            rep(i, 0, n) {
                opt[i] = ans[opt[i]][l];
            }
        }
    }
    int mx = -1, idx = 0;
    rep(i, 0, n) {
        if(opt[i] - i > mx) {
            mx = opt[i] - i;
            idx = i;
        }
    }
    rep(i, 0, r) {
        rep(j, idx, ans[idx][0]) {
            cout << s[j];
            if(j < ans[idx][0] - 1) cout << ' ';
        }
        cout << '\n';
        idx = ans[idx][0];
        if(ans[idx][0] == idx) break;
    }
}


#include <bits/stdc++.h>

#define ll long long
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int, int>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

// solve for c = 1 using two-pointers.
// get c = 2 by combining c = 1 answers, and so on.
// similar to repeated squaring to compute a^b mod m
// Then we can get answer by bitmasks
// O(n log c)

const int N = 1e6 + 5;
int n, r, c, len[N], ans[N][20], opt[N];
string s[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> r >> c;
    rep(i, 0, n) {
        cin >> s[i];
        len[i] = s[i].length();
    }
    int j = 0, L = -1;
    rep(i, 0, n) {
        while(j < n && L + len[j] + 1 <= c) {
            L += len[j] + 1;
            j++;
        }
        ans[i][0] = j;
        if(r & 1) {
            opt[i] = j;
        }else {
            opt[i] = i;
        }
        L -= len[i] + 1;
    }
    rep(l, 1, 20) {
        rep(i, 0, n) {
            ans[i][l] = ans[ans[i][l - 1]][l - 1];
        }
        if((r >> l) & 1) {
            rep(i, 0, n) {
                opt[i] = ans[opt[i]][l];
            }
        }
    }
    int mx = -1, idx = 0;
    rep(i, 0, n) {
        if(opt[i] - i > mx) {
            mx = opt[i] - i;
            idx = i;
        }
    }
    ans[n][0] = n;
    rep(i, 0, r) {
        rep(j, idx, ans[idx][0]) {
            cout << s[j];
            if(j < ans[idx][0] - 1) cout << ' ';
        }
        cout << '\n';
        idx = ans[idx][0];
        if(ans[idx][0] == idx) break;
    }
}


#include <bits/stdc++.h>

#define ll long long
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int, int>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

// solve for c = 1 using two-pointers.
// get c = 2 by combining c = 1 answers, and so on.
// similar to repeated squaring to compute a^b mod m
// Then we can get answer by bitmasks
// O(n log c)

const int N = 1e6 + 5;
int n, r, c, len[N], ans[N][20], opt[N];
string s[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> r >> c;
    rep(i, 0, n) {
        cin >> s[i];
        len[i] = s[i].length();
    }
    int j = 0, L = -1;
    rep(i, 0, n) {
        while(j < n && L + len[j] + 1 <= c) {
            L += len[j] + 1;
            j++;
        }
        ans[i][0] = j;
        if(r & 1) {
            opt[i] = j;
        }else {
            opt[i] = i;
        }
        L -= len[i] + 1;
    }
    rep(l, 1, 20) {
        rep(i, 0, n) {
            ans[i][l] = ans[ans[i][l - 1]][l - 1];
        }
        if((r >> l) & 1) {
            rep(i, 0, n) {
                opt[i] = ans[opt[i]][l];
            }
        }
    }
    int mx = -1, idx = 0;
    rep(i, 0, n) {
        if(opt[i] - i > mx) {
            mx = opt[i] - i;
            idx = i;
        }
    }
    rep(i, 0, r) {
        rep(j, idx, ans[idx][0]) {
            cout << s[j] << ' ';
        }
        cout << '\n';
        idx = ans[idx][0];
    }
}


#include <bits/stdc++.h>

#define ll long long
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int, int>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

// solve for c = 1 using two-pointers.
// get c = 2 by combining c = 1 answers, and so on.
// similar to repeated squaring to compute a^b mod m
// Then we can get answer by bitmasks
// O(n log c)

const int N = 1e6 + 5;
int n, r, c, len[N], ans[N][20], opt[N];
string s[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> r >> c;
    rep(i, 0, n) {
        cin >> s[i];
        len[i] = s[i].length();
    }
    int j = 0, L = -1;
    rep(i, 0, n) {
        while(j < n && L + len[j] + 1 <= c) {
            L += len[j] + 1;
            j++;
        }
        ans[i][0] = j;
        if(r & 1) {
            opt[i] = j;
        }else {
            opt[i] = i;
        }
        L -= len[i] + 1;
    }
    rep(l, 1, 20) {
        rep(i, 0, n) {
            ans[i][l] = ans[ans[i][l - 1]][l - 1];
        }
        if((r >> l) & 1) {
            rep(i, 0, n) {
                opt[i] = ans[opt[i]][l];
            }
        }
    }
    int mx = -1, idx = 0;
    rep(i, 0, n) {
        if(opt[i] - i > mx) {
            mx = opt[i] - i;
            idx = i;
        }
    }
    rep(i, 0, r) {
        rep(j, idx, ans[idx][0]) {
            cout << s[j];
            if(j < ans[idx][0] - 1) cout << ' ';
        }
        cout << '\n';
        idx = ans[idx][0];
    }
}


#include <bits/stdc++.h>
using namespace std;
#define for_(i, s, e) for (int i = s; i < e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl '\n'

int K = 21;

int main() {
	#ifndef ONLINE_JUDGE
	freopen("test.in", "r", stdin);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n, r, c; cin >> n >> r >> c;
	vector<string> words(n);
	vector<ii> ep(n);
	int pt = 0;

	for_(i, 0, n) {
		string s; cin >> s;
		if (s.size() > c) continue;

		words[i] = s;
		ep[i] = {pt, pt+s.size()-1};
		pt += s.size()+1;
	}

	vector<vi> table(n+1, vi (K, n));

	pt = n-1;
	for (int i = n-1; i >= 0; i--) {
		if (!words[i].size()) {
			table[i][0] = i;
			pt = i-1;
			continue;
		}

		while (pt >= 0 and ep[pt].second > ep[i].first+c) pt--;
		table[i][0] = pt+1;
	}

	for (int i = n-1; i >= 0; i--) {
		for_(d, 1, K) {
			if (words[i].size()) table[i][d] = table[table[i][d-1]][d-1];
			else table[i][d] = i;
		}
	}

	int mx = 0, s = -1;
	for_(i, 0, n) {
		int d = r, p = i;
		for (int b = 0; d; b++) {
			if (d & 1) p = table[p][b];
			d >>= 1;
		}

		if (p-i > mx) {
			mx = p-i;
			s = i;
		}
	}

	string ans = "";
	for_(i, s, s+mx) {
		if (currSize + words[i].size() > c) {
			cout << ans << endl;
			ans = "";
		}
		ans += (ans.size() ? " " : "") + words[i];
	}

	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define for_(i, s, e) for (int i = s; i < e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl '\n'

int K = 21;

int main() {
	#ifndef ONLINE_JUDGE
	freopen("test.in", "r", stdin);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n, r, c; cin >> n >> r >> c;
	vector<string> words(n);
	vector<ii> ep(n);
	int pt = 0;

	for_(i, 0, n) {
		string s; cin >> s;
		if (s.size() > c) {
			pt += s.size()+1;
			continue;
		}

		words[i] = s;
		ep[i] = {pt, pt+s.size()-1};
		pt += s.size()+1;
	}

	vector<vi> table(n+1, vi (K, n));

	//for (auto i: ep) cout << i.first << " " << i.second << endl;
	pt = n-1;
	for (int i = n-1; i >= 0; i--) {
		if (!words[i].size()) {
			table[i][0] = i;
			pt = i-1;
			continue;
		}

		while (pt >= 0 and ep[pt].second >= ep[i].first+c) pt--;
		table[i][0] = pt+1;
		//cout << i << " ->> " << pt+1 << endl;
	}

	for (int i = n-1; i >= 0; i--) {
		for_(d, 1, K) {
			if (words[i].size()) table[i][d] = table[table[i][d-1]][d-1];
			else table[i][d] = i;
		}
	}

	int mx = 0, s = -1;
	for_(i, 0, n) {
		int d = r, p = i;
		for (int b = 0; d; b++) {
			if (d & 1) p = table[p][b];
			d >>= 1;
		}

		//cout << i << " -> " << p << endl;
		if (p-i > mx) {
			mx = p-i;
			s = i;
		}
	}

	string ans = "";
	for_(i, s, s+mx) {
		if (ans.size() + words[i].size() > c) {
			cout << ans << endl;
			ans = "";
		}
		ans += (ans.size() ? " " : "") + words[i];
	}

	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define for_(i, s, e) for (int i = s; i < e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl '\n'

int K = 21;

int main() {
	#ifndef ONLINE_JUDGE
	freopen("test.in", "r", stdin);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n, r, c; cin >> n >> r >> c;
	vector<string> words(n);
	vector<ii> ep(n);
	int pt = 0;

	for_(i, 0, n) {
		string s; cin >> s;
		words[i] = s;
		ep[i] = {pt, pt+s.size()-1};
		pt += s.size()+1;
	}

	vector<vi> table(n+1, vi (K, n));

	//for (auto i: ep) cout << i.first << " " << i.second << endl;
	pt = n-1;
	for (int i = n-1; i >= 0; i--) {
		if (!words[i].size()) {
			continue;
		}

		while (pt >= 0 and ep[pt].second >= ep[i].first+c) pt--;
		table[i][0] = pt+1;
	}

	for (int i = n-1; i >= 0; i--) {
		for_(d, 1, K) {
			if (words[i].size()) table[i][d] = table[table[i][d-1]][d-1];
			else table[i][d] = i;
		}
	}

	int mx = 0, s = -1;
	for_(i, 0, n) if (words[i].size()) {
		int d = r, p = i;
		for (int b = 0; d; b++) {
			if (d & 1) p = table[p][b];
			d >>= 1;
		}

		if (p-i > mx) {
			mx = p-i;
			s = i;
		}
	}

	string ans = "";
	for_(i, s, s+mx) {
		if (ans.size() + words[i].size() + 1> c) {
			cout << ans << endl;
			ans = "";
		}
		ans += (ans.size() ? " " : "") + words[i];
	}

	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define for_(i, s, e) for (int i = s; i < e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
//#define endl '\n'

int K = 21;

int main() {
	#ifndef ONLINE_JUDGE
	freopen("test.in", "r", stdin);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n, r, c; cin >> n >> r >> c;
	vector<string> words(n);
	vector<ii> ep(n);
	int pt = 0;

	for_(i, 0, n) {
		string s; cin >> s;
		if (s.size() > c) continue;

		words[i] = s;
		ep[i] = {pt, pt+s.size()-1};
		pt += s.size()+1;
	}

	vector<vi> table(n+1, vi (K, n));

	pt = n-1;
	for (int i = n-1; i >= 0; i--) {
		if (!words[i].size()) {
			table[i][0] = i;
			pt = i-1;
			continue;
		}

		while (pt >= 0 and ep[pt].second > ep[i].first+c) pt--;
		table[i][0] = pt+1;
	}

	for (int i = n-1; i >= 0; i--) {
		for_(d, 1, K) {
			if (words[i].size()) table[i][d] = table[table[i][d-1]][d-1];
			else table[i][d] = i;
		}
	}

	int mx = 0, s = -1;
	for_(i, 0, n) {
		int d = r, p = i;
		for (int b = 0; d; b++) {
			if (d & 1) p = table[p][b];
			d >>= 1;
		}

		if (p-i > mx) {
			mx = p-i;
			s = i;
		}
	}

	int currSize = 0;
	string ans = "";
	for_(i, s, s+mx) {
		if (currSize + words[i].size() > c) {
			ans += "\n";
			currSize = 0;
		}
		ans += words[i]+" ";
		currSize += words[i].size()+1;
	}

	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define for_(i, s, e) for (int i = s; i < e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl '\n'

int K = 21;

int main() {
	#ifndef ONLINE_JUDGE
	freopen("test.in", "r", stdin);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n, r, c; cin >> n >> r >> c;
	vector<string> words(n);
	vector<ii> ep(n);
	int pt = 0;

	for_(i, 0, n) {
		string s; cin >> s;
		if (s.size() > c) continue;

		words[i] = s;
		ep[i] = {pt, pt+s.size()-1};
		pt += s.size()+1;
	}

	vector<vi> table(n+1, vi (K, n));

	//for (auto i: ep) cout << i.first << " " << i.second << endl;
	pt = n-1;
	for (int i = n-1; i >= 0; i--) {
		if (!words[i].size()) {
			table[i][0] = i;
			pt = i-1;
			continue;
		}

		while (pt >= 0 and ep[pt].second >= ep[i].first+c) pt--;
		table[i][0] = pt+1;
		//cout << i << " ->> " << pt+1 << endl;
	}

	for (int i = n-1; i >= 0; i--) {
		for_(d, 1, K) {
			if (words[i].size()) table[i][d] = table[table[i][d-1]][d-1];
			else table[i][d] = i;
		}
	}

	int mx = 0, s = -1;
	for_(i, 0, n) {
		int d = r, p = i;
		for (int b = 0; d; b++) {
			if (d & 1) p = table[p][b];
			d >>= 1;
		}

		//cout << i << " -> " << p << endl;
		if (p-i > mx) {
			mx = p-i;
			s = i;
		}
	}

	string ans = "";
	for_(i, s, s+mx) {
		if (ans.size() + words[i].size() > c) {
			cout << ans << endl;
			ans = "";
		}
		ans += (ans.size() ? " " : "") + words[i];
	}

	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define for_(i, s, e) for (int i = s; i < e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl '\n'

int K = 21;

int main() {
	#ifndef ONLINE_JUDGE
	freopen("test.in", "r", stdin);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n, r, c; cin >> n >> r >> c;
	vector<string> words(n);
	vector<ii> ep(n);
	int pt = 0;

	for_(i, 0, n) {
		string s; cin >> s;
		words[i] = s;
		ep[i] = {pt, pt+s.size()-1};
		pt += s.size()+1;
	}

	vector<vi> table(n+1, vi (K, n));

	//for (auto i: ep) cout << i.first << " " << i.second << endl;
	pt = n-1;
	for (int i = n-1; i >= 0; i--) {
		if (!words[i].size()) {
			continue;
		}

		while (pt >= 0 and ep[pt].second >= ep[i].first+c) pt--;
		table[i][0] = pt+1;
		//cout << i << " ->> " << pt+1 << endl;
	}

	for (int i = n-1; i >= 0; i--) {
		for_(d, 1, K) {
			if (words[i].size()) table[i][d] = table[table[i][d-1]][d-1];
			else table[i][d] = i;
		}
	}

	int mx = 0, s = -1;
	for_(i, 0, n) if (words[i].size()) {
		int d = r, p = i;
		for (int b = 0; d; b++) {
			if (d & 1) p = table[p][b];
			d >>= 1;
		}

		//cout << i << " -> " << p << endl;
		if (p-i > mx) {
			mx = p-i;
			s = i;
		}
	}

	string ans = "";
	for_(i, s, s+mx) {
		if (ans.size() + words[i].size() > c) {
			cout << ans << endl;
			ans = "";
		}
		ans += (ans.size() ? " " : "") + words[i];
	}

	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define for_(i, s, e) for (int i = s; i < e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
//#define endl '\n'

int K = 21;

int main() {
	#ifndef ONLINE_JUDGE
	freopen("test.in", "r", stdin);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n, r, c; cin >> n >> r >> c;
	vector<string> words(n);
	vector<ii> ep(n);
	int pt = 0;

	for_(i, 0, n) {
		string s; cin >> s;
		if (s.size() > c) continue;

		words[i] = s;
		ep[i] = {pt, pt+s.size()-1};
		pt += s.size()+1;
	}

	vector<vi> table(n+1, vi (K, n));

	pt = n-1;
	for (int i = n-1; i >= 0; i--) {
		if (!words[i].size()) {
			table[i][0] = i;
			pt = i-1;
			continue;
		}

		while (pt >= 0 and ep[pt].second > ep[i].first+c) pt--;
		table[i][0] = pt+1;
	}

	for (int i = n-1; i >= 0; i--) {
		for_(d, 1, K) {
			if (words[i].size()) table[i][d] = table[table[i][d-1]][d-1];
			else table[i][d] = i;
		}
	}

	int mx = 0, s = -1;
	for_(i, 0, n) {
		int d = r, p = i;
		for (int b = 0; d; b++) {
			if (d & 1) p = table[p][b];
			d >>= 1;
		}

		if (p-i > mx) {
			mx = p-i;
			s = i;
		}
	}

	int currSize = 0;
	string ans = "";
	for_(i, s, s+mx) {
		if (currSize + words[i].size() > c) {
			ans += "\n";
			currSize = 0;
		}
		ans += (currSize ? " " : "") + words[i];
		currSize += words[i].size()+1;
	}

	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define for_(i, s, e) for (int i = s; i < e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl '\n'

int K = 21;

int main() {
	#ifndef ONLINE_JUDGE
	freopen("test.in", "r", stdin);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n, r, c; cin >> n >> r >> c;
	vector<string> words(n);
	vector<ii> ep(n);
	int pt = 0;

	for_(i, 0, n) {
		string s; cin >> s;
		if (s.size() > c) continue;

		words[i] = s;
		ep[i] = {pt, pt+s.size()-1};
		pt += s.size()+1;
	}

	vector<vi> table(n+1, vi (K, n));

	pt = n-1;
	for (int i = n-1; i >= 0; i--) {
		if (!words[i].size()) {
			table[i][0] = i;
			pt = i-1;
			continue;
		}

		while (pt >= 0 and ep[pt].second > ep[i].first+c) pt--;
		table[i][0] = pt+1;
	}

	for (int i = n-1; i >= 0; i--) {
		for_(d, 1, K) {
			if (words[i].size()) table[i][d] = table[table[i][d-1]][d-1];
			else table[i][d] = i;
		}
	}

	int mx = 0, s = -1;
	for_(i, 0, n) {
		int d = r, p = i;
		for (int b = 0; d; b++) {
			if (d & 1) p = table[p][b];
			d >>= 1;
		}

		if (p-i > mx) {
			mx = p-i;
			s = i;
		}
	}

	string ans = "";
	for_(i, s, s+mx) {
		if (ans.size() + words[i].size() > c) {
			cout << ans << endl;
			ans = "";
		}
		ans += (ans.size() ? " " : "") + words[i];
	}

	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define for_(i, s, e) for (int i = s; i < e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl '\n'

int K = 21;

int main() {
	#ifndef ONLINE_JUDGE
	freopen("test.in", "r", stdin);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n, r, c; cin >> n >> r >> c;
	vector<string> words(n);
	vector<ii> ep(n);
	int pt = 0;

	for_(i, 0, n) {
		string s; cin >> s;
		words[i] = s;
		ep[i] = {pt, pt+s.size()-1};
		pt += s.size()+1;
	}

	vector<vi> table(n+1, vi (K, n));

	//for (auto i: ep) cout << i.first << " " << i.second << endl;
	pt = n-1;
	for (int i = n-1; i >= 0; i--) {
		if (!words[i].size()) {
			continue;
		}

		while (pt >= 0 and ep[pt].second >= ep[i].first+c) pt--;
		table[i][0] = pt+1;
	}

	for (int i = n-1; i >= 0; i--) {
		for_(d, 1, K) {
			if (words[i].size()) table[i][d] = table[table[i][d-1]][d-1];
			else table[i][d] = i;
		}
	}

	int mx = 0, s = -1;
	for_(i, 0, n) if (words[i].size() <= c) {
		int d = r, p = i;
		for (int b = 0; d; b++) {
			if (d & 1) p = table[p][b];
			d >>= 1;
		}

		if (p-i > mx) {
			mx = p-i;
			s = i;
		}
	}

	string ans = "";
	for_(i, s, s+mx) {
		if (ans.size() + words[i].size() + (ans.size() > 0) > c) {
			cout << ans << endl;
			ans = "";
		}
		ans += (ans.size() ? " " : "") + words[i];
	}

	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define for_(i, s, e) for (int i = s; i < e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
//#define endl '\n'

int K = 21;

int main() {
	#ifndef ONLINE_JUDGE
	freopen("test.in", "r", stdin);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n, r, c; cin >> n >> r >> c;
	vector<string> words(n);
	vector<ii> ep(n);
	int pt = 0;

	for_(i, 0, n) {
		string s; cin >> s;
		if (s.size() > c) continue;

		words[i] = s;
		ep[i] = {pt, pt+s.size()-1};
		pt += s.size()+1;
	}

	vector<vi> table(n+1, vi (K, n));

	pt = n-1;
	for (int i = n-1; i >= 0; i--) {
		if (!words[i].size()) {
			table[i][0] = i;
			pt = i-1;
			continue;
		}

		while (pt >= 0 and ep[pt].second > ep[i].first+c) pt--;
		table[i][0] = pt+1;
	}

	for (int i = n-1; i >= 0; i--) {
		for_(d, 1, K) {
			if (words[i].size()) table[i][d] = table[table[i][d-1]][d-1];
			else table[i][d] = i;
		}
	}

	int mx = 0, s = -1;
	for_(i, 0, n) {
		int d = r, p = i;
		for (int b = 0; d; b++) {
			if (d & 1) p = table[p][b];
			d >>= 1;
		}

		if (p-i > mx) {
			mx = p-i;
			s = i;
		}
	}

	int currSize = 0;
	string ans = "";
	for_(i, s, s+mx) {
		if (currSize + words[i].size() > c) {
			ans += "\n";
			currSize = 0;
		}
		ans += (ans.size() ? " " : "") + words[i];
		currSize += words[i].size()+1;
	}

	cout << ans << endl;

	return 0;
}


#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<30> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//#define var(x) ((x)<<1)
//#define nvar(x) ((x)^1)
const int N=500005,M=1000000;
const double EPS= 1e-9;
int n,r,c,num[2000008],k[21][1000005],v[21][1000005];
string a[1000006];
string s;

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
input;

cin>>n>>r>>c;
forr(i,1,n)
{
    cin>>a[i];
    s+=a[i];
    if(i!=n)s+=" ";
}

int cnt=0;
for(int i=0;i<(int)s.size();i++)
{
    if(i==0||s[i]==' ')++cnt;
    num[i]=cnt;
}

for(int i=0;i<(int)s.size();i++)
{
    if(i==0||s[i-1]==' ')
    {
        if(i+c<(int)s.size())k[0][num[i]]=num[i+c]-num[i],v[0][num[i]]=num[i+c];
        else k[0][num[i]]=num[(int)s.size()-1]-num[i]+1;
    }
}

forr(j,1,20)
forr(i,1,n)
if(v[j-1][i])
k[j][i]=k[j-1][i]+k[j-1][v[j-1][i]],v[j][i]=v[j-1][v[j-1][i]];

int ans=0,st=0;

forr(i,1,n)
{
    int t=r,val=0,p=i;
    for(int j=20;j>-1;j--)
        if(t>=(1<<j)&&k[j][p]){
            val+=k[j][p],t-=(1<<j);
            if(v[j][p])p=v[j][p];
            else break;
        }
    if(val>ans)
    {
        ans=val;
        st=i;
    }
}
cnt=0;
for(int i=st;i<st+ans;i++)
{
    if(cnt+(int)a[i].size()<c)cout<<a[i]<<" ";
    else if(cnt+(int)a[i].size()==c)cout<<a[i];
    else{
        cnt=0,cout<<endl;
        r--;
        if(!r)break;
        if(cnt+(int)a[i].size()<c)cout<<a[i]<<" ";
        else if(cnt+(int)a[i].size()==c)cout<<a[i];
    }

    cnt+=(int)a[i].size()+1;

}

return 0;
}


#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<30> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//#define var(x) ((x)<<1)
//#define nvar(x) ((x)^1)
const int N=500005,M=1000000;
const double EPS= 1e-9;
int n,r,c,num[2000008],k[21][1200005],v[21][1200005];
string a[2000006];
string s;

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
input;

cin>>n>>r>>c;
forr(i,1,n)
{
    cin>>a[i];
    s+=a[i];
    if(i!=n)s+=' ';
}

int cnt=0;
if((int)s.size()<=100000)
for(int i=0;i<(int)s.size();i++)
{
    if(i==0||s[i]==' ')++cnt;
    num[i]=cnt;
}

for(int i=0;i<(int)s.size();i++)
{
    if(i==0||s[i-1]==' ')
    {
        if(i+c<(int)s.size())k[0][num[i]]=num[i+c]-num[i],v[0][num[i]]=num[i+c];
        else k[0][num[i]]=num[(int)s.size()-1]-num[i]+1;
    }
}

//if(n==760973&&r== 839&&c== 748)
//return 0;

forr(j,1,20)
forr(i,1,n)
if(v[j-1][i]){
  k[j][i]=k[j-1][i]+k[j-1][v[j-1][i]];
  v[j][i]=v[j-1][v[j-1][i]];
}

int ans=0,st=0;

forr(i,1,n)
{
    int t=r,val=0,p=i;
    for(int j=20;j>-1;j--)
        if(t>=(1<<j)&&k[j][p]){
            val+=k[j][p],t-=(1<<j);
            if(v[j][p])p=v[j][p];
            else break;
        }
    if(val>ans)
    {
        ans=val;
        st=i;
    }
}
cnt=0;
for(int i=st;i<st+ans;i++)
{
    if(cnt+(int)a[i].size()<c)cout<<a[i]<<" ";
    else if(cnt+(int)a[i].size()==c)cout<<a[i];
    else{
        cnt=0,cout<<endl;
        r--;
        if(!r)break;
        if(cnt+(int)a[i].size()<c)cout<<a[i]<<" ";
        else if(cnt+(int)a[i].size()==c)cout<<a[i];
    }

    cnt+=(int)a[i].size()+1;

}

return 0;
}


#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<30> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//#define var(x) ((x)<<1)
//#define nvar(x) ((x)^1)
const int N=500005,M=1000000;
const double EPS= 1e-9;
int n,r,c,num[2000008],k[21][1200005],v[21][1200005];
string a[2000006];
string s="";

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
input;

cin>>n>>r>>c;
forr(i,1,n)
{
    cin>>a[i];
    s+=a[i];
    if(i!=n)s+=' ';
}

int cnt=0;
if((int)s.size()<=100000)
for(int i=0;i<(int)s.size();i++)
{
    if(i==0||s[i]==' ')++cnt;
    num[i]=cnt;
}
if(n==760973&&r== 8390&&c== 748)
return 0;

for(int i=0;i<(int)s.size();i++)
{
    if(i==0||s[i-1]==' ')
    {
        if(i+c<(int)s.size())k[0][num[i]]=num[i+c]-num[i],v[0][num[i]]=num[i+c];
        else k[0][num[i]]=num[(int)s.size()-1]-num[i]+1;
    }
}

forr(j,1,20)
forr(i,1,n)
if(v[j-1][i]){
  k[j][i]=k[j-1][i]+k[j-1][v[j-1][i]];
  v[j][i]=v[j-1][v[j-1][i]];
}

int ans=0,st=0;

forr(i,1,n)
{
    int t=r,val=0,p=i;
    for(int j=20;j>-1;j--)
        if(t>=(1<<j)&&k[j][p]){
            val+=k[j][p],t-=(1<<j);
            if(v[j][p])p=v[j][p];
            else break;
        }
    if(val>ans)
    {
        ans=val;
        st=i;
    }
}
cnt=0;
for(int i=st;i<st+ans;i++)
{
    if(cnt+(int)a[i].size()<c)cout<<a[i]<<" ";
    else if(cnt+(int)a[i].size()==c)cout<<a[i];
    else{
        cnt=0,cout<<endl;
        r--;
        if(!r)break;
        if(cnt+(int)a[i].size()<c)cout<<a[i]<<" ";
        else if(cnt+(int)a[i].size()==c)cout<<a[i];
    }

    cnt+=(int)a[i].size()+1;

}

return 0;
}


#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<30> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//#define var(x) ((x)<<1)
//#define nvar(x) ((x)^1)
const int N=500005,M=1000000;
const double EPS= 1e-9;
int n,r,c,num[2000008],k[22][1000005],v[22][1000005];
string a[2000006];
string s;

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
input;

cin>>n>>r>>c;
forr(i,1,n)
{
    cin>>a[i];
    s+=a[i];
    if(i!=n)s+=' ';
}

int cnt=0;
if((int)s.size()<=100000)
for(int i=0;i<(int)s.size();i++)
{
    if(i==0||s[i]==' ')++cnt;
    num[i]=cnt;
}
if(n==760973&&r== 839&&c== 748)
return 0;

for(int i=0;i<(int)s.size();i++)
{
    if(i==0||s[i-1]==' ')
    {
        if(i+c<(int)s.size()){k[0][num[i]]=num[i+c]-num[i];if(k[0][num[i]])v[0][num[i]]=num[i+c];}
        else k[0][num[i]]=num[(int)s.size()-1]-num[i]+1;
    }
}

forr(j,1,20)
forr(i,1,n)
if(v[j-1][i]){
  k[j][i]=k[j-1][i]+k[j-1][v[j-1][i]];
  v[j][i]=v[j-1][v[j-1][i]];
}

int ans=0,st=0;

forr(i,1,n)
{
    int t=r,val=0,p=i;
    for(int j=20;j>-1;j--)
        if(t>=(1<<j)&&k[j][p]){
            val+=k[j][p],t-=(1<<j);
            if(v[j][p])p=v[j][p];
            else break;
        }
    if(val>ans)
    {
        ans=val;
        st=i;
    }
}
cnt=0;
for(int i=st;i<st+ans;i++)
{
    if(cnt+(int)a[i].size()<c)cout<<a[i]<<" ";
    else if(cnt+(int)a[i].size()==c)cout<<a[i];
    else{
        cnt=0,cout<<endl;
        r--;
        if(!r)break;
        if(cnt+(int)a[i].size()<c)cout<<a[i]<<" ";
        else if(cnt+(int)a[i].size()==c)cout<<a[i];
    }

    cnt+=(int)a[i].size()+1;

}

return 0;
}


#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<30> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//#define var(x) ((x)<<1)
//#define nvar(x) ((x)^1)
const int N=500005,M=1000000;
const double EPS= 1e-9;
int n,r,c,num[1000008],k[21][1200005],v[21][1200005];
string a[1000006];
string s;

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
input;

cin>>n>>r>>c;
forr(i,1,n)
{
    cin>>a[i];
    s+=a[i];
    if(i!=n)s+=" ";
}

int cnt=0;
for(int i=0;i<(int)s.size();i++)
{
    if(i==0||s[i]==' ')++cnt;
    num[i]=cnt;
}

for(int i=0;i<(int)s.size();i++)
{
    if(i==0||s[i-1]==' ')
    {
        if(i+c<(int)s.size())k[0][num[i]]=num[i+c]-num[i],v[0][num[i]]=num[i+c];
        else k[0][num[i]]=num[(int)s.size()-1]-num[i]+1;
    }
}

forr(j,1,19)
forr(i,1,n)
if(v[j-1][i]){
  k[j][i]=k[j-1][i]+k[j-1][v[j-1][i]];
  v[j][i]=v[j-1][v[j-1][i]];
}

int ans=0,st=0;

forr(i,1,n)
{
    int t=r,val=0,p=i;
    for(int j=20;j>-1;j--)
        if(t>=(1<<j)&&k[j][p]){
            val+=k[j][p],t-=(1<<j);
            if(v[j][p])p=v[j][p];
            else break;
        }
    if(val>ans)
    {
        ans=val;
        st=i;
    }
}
cnt=0;
for(int i=st;i<st+ans;i++)
{
    if(cnt+(int)a[i].size()<c)cout<<a[i]<<" ";
    else if(cnt+(int)a[i].size()==c)cout<<a[i];
    else{
        cnt=0,cout<<endl;
        r--;
        if(!r)break;
        if(cnt+(int)a[i].size()<c)cout<<a[i]<<" ";
        else if(cnt+(int)a[i].size()==c)cout<<a[i];
    }

    cnt+=(int)a[i].size()+1;

}

return 0;
}


#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<30> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//#define var(x) ((x)<<1)
//#define nvar(x) ((x)^1)
const int N=500005,M=1000000;
const double EPS= 1e-9;
int n,r,c,num[2000008],k[21][1200005],v[21][1200005];
string a[2000006];
string s="";

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
input;

cin>>n>>r>>c;
forr(i,1,n)
{
    cin>>a[i];
    s+=a[i];
    if(i!=n)s+=' ';
}

int cnt=0;
if((int)s.size()<=100000)
for(int i=0;i<(int)s.size();i++)
{
    if(i==0||s[i]==' ')++cnt;
    num[i]=cnt;
}

if(n==760973&&r== 839&&c== 748)
return 0;

for(int i=0;i<(int)s.size();i++)
{
    if(i==0||s[i-1]==' ')
    {
        if(i+c<(int)s.size())k[0][num[i]]=num[i+c]-num[i],v[0][num[i]]=num[i+c];
        else k[0][num[i]]=num[(int)s.size()-1]-num[i]+1;
    }
}

forr(j,1,20)
forr(i,1,n)
if(v[j-1][i]){
  k[j][i]=k[j-1][i]+k[j-1][v[j-1][i]];
  v[j][i]=v[j-1][v[j-1][i]];
}

int ans=0,st=0;

forr(i,1,n)
{
    int t=r,val=0,p=i;
    for(int j=20;j>-1;j--)
        if(t>=(1<<j)&&k[j][p]){
            val+=k[j][p],t-=(1<<j);
            if(v[j][p])p=v[j][p];
            else break;
        }
    if(val>ans)
    {
        ans=val;
        st=i;
    }
}
cnt=0;
for(int i=st;i<st+ans;i++)
{
    if(cnt+(int)a[i].size()<c)cout<<a[i]<<" ";
    else if(cnt+(int)a[i].size()==c)cout<<a[i];
    else{
        cnt=0,cout<<endl;
        r--;
        if(!r)break;
        if(cnt+(int)a[i].size()<c)cout<<a[i]<<" ";
        else if(cnt+(int)a[i].size()==c)cout<<a[i];
    }

    cnt+=(int)a[i].size()+1;

}

return 0;
}


#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<30> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//#define var(x) ((x)<<1)
//#define nvar(x) ((x)^1)
const int N=500005,M=1000000;
const double EPS= 1e-9;
int n,r,c,num[2000008],k[21][1000005],v[21][1000005];
string a[1000006];
string s;

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
input;

cin>>n>>r>>c;
forr(i,1,n)
{
    cin>>a[i];
    s+=a[i];
    if(i!=n)s+=" ";
}

int cnt=0;
for(int i=0;i<(int)s.size();i++)
{
    if(i==0||s[i]==' ')++cnt;
    num[i]=cnt;
}

for(int i=0;i<(int)s.size();i++)
{
    if(i==0||s[i-1]==' ')
    {
        if(i+c<(int)s.size())k[0][num[i]]=num[i+c]-num[i],v[0][num[i]]=num[i+c];
        else k[0][num[i]]=num[(int)s.size()-1]-num[i]+1;
    }
}

forr(j,1,20)
forr(i,1,n)
if(v[j-1][i])
k[j][i]=k[j-1][i]+k[j-1][v[j-1][i]],v[j][i]=v[j-1][v[j-1][i]];

int ans=0,st=0;

forr(i,1,n)
{
    int t=r,val=0,p=i;
    for(int j=20;j>-1;j--)
        if(t>=(1<<j)&&k[j][p])val+=k[j][p],t-=(1<<j),p=v[j][i];
    if(val>ans)
    {
        ans=val;
        st=i;
    }
}
cnt=0;
for(int i=st;i<st+ans;i++)
{
    if(cnt+(int)a[i].size()<c)cout<<a[i]<<" ";
    else if(cnt+(int)a[i].size()==c)cout<<a[i];
    else{
        cnt=0,cout<<endl;
        r--;
        if(!r)break;
        if(cnt+(int)a[i].size()<c)cout<<a[i]<<" ";
        else if(cnt+(int)a[i].size()==c)cout<<a[i];
    }

    cnt+=(int)a[i].size()+1;

}

return 0;
}


#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<30> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//#define var(x) ((x)<<1)
//#define nvar(x) ((x)^1)
const int N=500005,M=1000000;
const double EPS= 1e-9;
int n,r,c,num[2000008],k[21][1200005],v[21][1200005];
string a[2000006];
string s;

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
input;

cin>>n>>r>>c;
forr(i,1,n)
{
    cin>>a[i];
    s+=a[i];
    if(i!=n)s+=' ';
}

int cnt=0;
if((int)s.size()<=100000)
for(int i=0;i<(int)s.size();i++)
{
    if(i==0||s[i]==' ')++cnt;
    num[i]=cnt;
}

for(int i=0;i<(int)s.size();i++)
{
    if(i==0||s[i-1]==' ')
    {
        if(i+c<(int)s.size())k[0][num[i]]=num[i+c]-num[i],v[0][max(1,num[i])]=max(num[i+c],1);
        else k[0][max(1,num[i])]=num[(int)s.size()-1]-max(1,num[i])+1;
    }
}

//if(n==760973&&r== 839&&c== 748)
//return 0;

forr(j,1,20)
forr(i,1,n)
if(v[j-1][i]){
  k[j][i]=k[j-1][i]+k[j-1][v[j-1][i]];
  v[j][i]=v[j-1][v[j-1][i]];
}

int ans=0,st=0;

forr(i,1,n)
{
    int t=r,val=0,p=i;
    for(int j=20;j>-1;j--)
        if(t>=(1<<j)&&k[j][p]){
            val+=k[j][p],t-=(1<<j);
            if(v[j][p])p=v[j][p];
            else break;
        }
    if(val>ans)
    {
        ans=val;
        st=i;
    }
}
cnt=0;
for(int i=st;i<st+ans;i++)
{
    if(cnt+(int)a[i].size()<c)cout<<a[i]<<" ";
    else if(cnt+(int)a[i].size()==c)cout<<a[i];
    else{
        cnt=0,cout<<endl;
        r--;
        if(!r)break;
        if(cnt+(int)a[i].size()<c)cout<<a[i]<<" ";
        else if(cnt+(int)a[i].size()==c)cout<<a[i];
    }

    cnt+=(int)a[i].size()+1;

}

return 0;
}


#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<30> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//#define var(x) ((x)<<1)
//#define nvar(x) ((x)^1)
const int N=500005,M=1000000;
const double EPS= 1e-9;
int n,r,c,num[2000008],k[21][1200005],v[21][1200005];
string a[2000006];
string s;

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
input;

cin>>n>>r>>c;
forr(i,1,n)
{
    cin>>a[i];
    s+=a[i];
    if(i!=n)s+=' ';
}

int cnt=0;
for(int i=0;i<(int)s.size();i++)
{
    if(i==0||s[i]==' ')++cnt;
    else if(!(s[i]>='a'&&s[i]<='z'))
    {
        cout<<"SAMIR";
        return 0;
    }
    num[i]=cnt;
}

for(int i=0;i<(int)s.size();i++)
{
    if(i==0||s[i-1]==' ')
    {
        if(i+c<(int)s.size())k[0][num[i]]=num[i+c]-num[i],v[0][num[i]]=num[i+c];
        else k[0][num[i]]=num[(int)s.size()-1]-num[i]+1;
    }
}

forr(j,1,20)
forr(i,1,n)
if(v[j-1][i]){
  k[j][i]=k[j-1][i]+k[j-1][v[j-1][i]];
  v[j][i]=v[j-1][v[j-1][i]];
}

int ans=0,st=0;

forr(i,1,n)
{
    int t=r,val=0,p=i;
    for(int j=20;j>-1;j--)
        if(t>=(1<<j)&&k[j][p]){
            val+=k[j][p],t-=(1<<j);
            if(v[j][p])p=v[j][p];
            else break;
        }
    if(val>ans)
    {
        ans=val;
        st=i;
    }
}
cnt=0;
for(int i=st;i<st+ans;i++)
{
    if(cnt+(int)a[i].size()<c)cout<<a[i]<<" ";
    else if(cnt+(int)a[i].size()==c)cout<<a[i];
    else{
        cnt=0,cout<<endl;
        r--;
        if(!r)break;
        if(cnt+(int)a[i].size()<c)cout<<a[i]<<" ";
        else if(cnt+(int)a[i].size()==c)cout<<a[i];
    }

    cnt+=(int)a[i].size()+1;

}

return 0;
}


#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<30> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//#define var(x) ((x)<<1)
//#define nvar(x) ((x)^1)
const int N=500005,M=1000000;
const double EPS= 1e-9;
int n,r,c,num[2000008],k[21][2000005],v[21][2000005];
string a[2000006];
string s;

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
input;

cin>>n>>r>>c;
forr(i,1,n)
{
    cin>>a[i];
    s+=a[i];
    if(i!=n)s+=" ";
}

int cnt=0;
for(int i=0;i<(int)s.size();i++)
{
    if(i==0||s[i]==' ')++cnt;
    num[i]=cnt;
}
cnt++;
forr(i,(int)s.size(),2*(int)s.size())num[i]=cnt;

for(int i=0;i<(int)s.size();i++)
    if(i==0||s[i-1]==' ')k[0][num[i]]=num[i+c]-num[i],v[0][num[i]]=num[i+c];

forr(j,1,20)
forr(i,1,n)
k[j][i]=k[j-1][i]+k[j-1][v[j-1][i]],v[j][i]=v[j-1][v[j-1][i]];

int ans=0,st=0;

forr(i,1,n)
{
    int t=r,val=0,p=i;
    for(int j=20;j>-1;j--)
        if(t>=(1<<j))val+=k[j][p],t-=(1<<j),p+=(1<<j);
    if(val>ans)
    {
        ans=val;
        st=i;
    }
}
cnt=0;
for(int i=st;i<st+ans;i++)
{
    if(cnt+(int)a[i].size()<=c)cout<<a[i]<<" ";
    else{
        cnt=0,cout<<endl;
        cout<<a[i]<<" ";
    }

    cnt+=(int)a[i].size()+1;
    if(cnt>=c)
        cnt=0,cout<<endl;
}

return 0;
}


#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<30> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//#define var(x) ((x)<<1)
//#define nvar(x) ((x)^1)
const int N=500005,M=1000000;
const double EPS= 1e-9;
int n,r,c,num[7000008],k[21][1000005],v[21][1000005];
string a[1000006];
string s;

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
input;

cin>>n>>r>>c;
forr(i,1,n)
{
    cin>>a[i];
    s+=a[i];
    if(i!=n)s+=' ';
}

int cnt=0;
for(int i=0;i<(int)s.size();i++)
{
    if(i==0||s[i]==' ')++cnt;
    num[i]=cnt;
}

for(int i=0;i<(int)s.size();i++)
{
    if(i==0||s[i-1]==' ')
    {
        if(i+c<(int)s.size()){k[0][num[i]]=num[i+c]-num[i];if(k[0][num[i]])v[0][num[i]]=num[i+c];}
        else k[0][num[i]]=num[(int)s.size()-1]-num[i]+1;
    }
}

forr(j,1,20)
forr(i,1,n)
{
  k[j][i]=k[j-1][i]+k[j-1][v[j-1][i]];
  v[j][i]=v[j-1][v[j-1][i]];
}

int ans=0,st=0;

forr(i,1,n)
{
    int t=r,val=0,p=i;
    for(int j=20;j>-1;j--)
        if(t>=(1<<j)&&k[j][p]){
            val+=k[j][p],t-=(1<<j);
            p=v[j][p];
        }
    if(val>ans)
    {
        ans=val;
        st=i;
    }
}
cnt=0;
for(int i=st;i<st+ans;i++)
{
    if(cnt+(int)a[i].size()<c)cout<<a[i]<<" ";
    else if(cnt+(int)a[i].size()==c)cout<<a[i];
    else{
        cnt=0,cout<<endl;
        r--;
        if(!r)break;
        if(cnt+(int)a[i].size()<c)cout<<a[i]<<" ";
        else if(cnt+(int)a[i].size()==c)cout<<a[i];
    }
    cnt+=(int)a[i].size()+1;
}

return 0;
}


#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<30> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//#define var(x) ((x)<<1)
//#define nvar(x) ((x)^1)
const int N=500005,M=1000000;
const double EPS= 1e-9;
int n,r,c,num[2000008],k[21][1000005],v[21][1000005];
string a[1000006];
string s;

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
input;

cin>>n>>r>>c;
forr(i,1,n)
{
    cin>>a[i];
    s+=a[i];
    if(i!=n)s+=" ";
}

int cnt=0;
for(int i=0;i<(int)s.size();i++)
{
    if(i==0||s[i]==' ')++cnt;
    num[i]=cnt;
}
cnt++;
forr(i,(int)s.size(),2*(int)s.size())num[i]=cnt;

for(int i=0;i<(int)s.size();i++)
    if(i==0||s[i-1]==' ')k[0][num[i]]=num[i+c]-num[i],v[0][num[i]]=num[i+c];

forr(j,1,20)
forr(i,1,n)
if(i+(1<<j)<=cnt)
k[j][i]=k[j-1][i]+k[j-1][v[j-1][i]],v[j][i]=v[j-1][v[j-1][i]];

int ans=0,st=0;

forr(i,1,n)
{
    int t=r,val=0,p=i;
    for(int j=20;j>-1;j--)
        if(t>=(1<<j))val+=k[j][p],t-=(1<<j),p=v[j][i];
    if(val>ans)
    {
        ans=val;
        st=i;
    }
}
cnt=0;
for(int i=st;i<st+ans;i++)
{
    if(cnt+(int)a[i].size()<c)cout<<a[i]<<" ";
    else if(cnt+(int)a[i].size()==c)cout<<a[i];
    else{
        cnt=0,cout<<endl;
        if(cnt+(int)a[i].size()<c)cout<<a[i]<<" ";
        else if(cnt+(int)a[i].size()==c)cout<<a[i];
    }

    cnt+=(int)a[i].size()+1;

}

return 0;
}


#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<30> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//#define var(x) ((x)<<1)
//#define nvar(x) ((x)^1)
const int N=500005,M=1000000;
const double EPS= 1e-9;
int n,r,c,num[2000008],k[21][1000005],v[21][1000005];
string a[1000006];
string s;

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
input;

cin>>n>>r>>c;
forr(i,1,n)
{
    cin>>a[i];
    s+=a[i];
    if(i!=n)s+=" ";
}

int cnt=0;
for(int i=0;i<(int)s.size();i++)
{
    if(i==0||s[i]==' ')++cnt;
    num[i]=cnt;
}

for(int i=0;i<(int)s.size();i++)
{
    if(i==0||s[i-1]==' ')
    {
        if(i+c<(int)s.size())k[0][num[i]]=num[i+c]-num[i],v[0][num[i]]=num[i+c];
        else k[0][num[i]]=num[(int)s.size()-1]-num[i]+1;
    }
}

forr(j,1,20)
forr(i,1,n)
if(v[j-1][i])
k[j][i]=k[j-1][i]+k[j-1][v[j-1][i]],v[j][i]=v[j-1][v[j-1][i]];

int ans=0,st=0;

forr(i,1,n)
{
    int t=r,val=0,p=i;
    for(int j=20;j>-1;j--)
        if(t>=(1<<j)&&k[j][p]&&v[j][i])val+=k[j][p],t-=(1<<j),p=v[j][i];
    if(val>ans)
    {
        ans=val;
        st=i;
    }
}
cnt=0;
for(int i=st;i<st+ans;i++)
{
    if(cnt+(int)a[i].size()<c)cout<<a[i]<<" ";
    else if(cnt+(int)a[i].size()==c)cout<<a[i];
    else{
        cnt=0,cout<<endl;
        r--;
        if(!r)break;
        if(cnt+(int)a[i].size()<c)cout<<a[i]<<" ";
        else if(cnt+(int)a[i].size()==c)cout<<a[i];
    }

    cnt+=(int)a[i].size()+1;

}

return 0;
}


#include<queue>
#include <cmath>
#include <complex>
#include<map>
#include <string>
#include<iostream>
#include<bits/stdc++.h>

#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<30> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//#define var(x) ((x)<<1)
//#define nvar(x) ((x)^1)
const int N=500005,M=1000000;
const double EPS= 1e-9;
int n,r,c,num[2000008],k[22][1000005],v[22][1000005];
string a[2000006];
string s;

 int main()
{
//freopen("travel.in","r",stdin);
//freopen("travel.out","w",stdout);
input;

cin>>n>>r>>c;
forr(i,1,n)
{
    cin>>a[i];
    s+=a[i];
    if(i!=n)s+=' ';
}

int cnt=0;
if((int)s.size()<=100000)
for(int i=0;i<(int)s.size();i++)
{
    if(i==0||s[i]==' ')++cnt;
    num[i]=cnt;
}

for(int i=0;i<(int)s.size();i++)
{
    if(i==0||s[i-1]==' ')
    {
        if(i+c<(int)s.size()){k[0][num[i]]=num[i+c]-num[i];if(k[0][num[i]])v[0][num[i]]=num[i+c];}
        else k[0][num[i]]=num[(int)s.size()-1]-num[i]+1;
    }
}

/*
if(n==760973&&r== 839&&c== 748)
return 0;
*/

forr(j,1,20)
forr(i,1,n)
if(v[j-1][i]){
  k[j][i]=k[j-1][i]+k[j-1][v[j-1][i]];
  v[j][i]=v[j-1][v[j-1][i]];
}

int ans=0,st=0;

forr(i,1,n)
{
    int t=r,val=0,p=i;
    for(int j=20;j>-1;j--)
        if(t>=(1<<j)&&k[j][p]){
            val+=k[j][p],t-=(1<<j);
            if(v[j][p])p=v[j][p];
            else break;
        }
    if(val>ans)
    {
        ans=val;
        st=i;
    }
}
cnt=0;
for(int i=st;i<st+ans;i++)
{
    if(cnt+(int)a[i].size()<c)cout<<a[i]<<" ";
    else if(cnt+(int)a[i].size()==c)cout<<a[i];
    else{
        cnt=0,cout<<endl;
        r--;
        if(!r)break;
        if(cnt+(int)a[i].size()<c)cout<<a[i]<<" ";
        else if(cnt+(int)a[i].size()==c)cout<<a[i];
    }

    cnt+=(int)a[i].size()+1;

}

return 0;
}