#include <cstdlib>
#include <iostream>
#include <stdio.h>

struct rec
{
    char* str;
    int length;
};

rec reci[5000],x[5000];

bool cmp(rec rec1, rec rec2)
{
     int pos=0;
     while(pos<rec1.length && pos<rec2.length)
       {
           if(rec1.str[pos]<rec2.str[pos]) return true;
           if(rec1.str[pos]>rec2.str[pos]) return false;
           pos++;
       }
     if(rec1.length<rec2.length) return true;
     return false;
}

void msort(int a,int b)
{
    if(b-a>0)
      {
          int m=(a+b)/2;
          msort(a,m);
          msort(m+1,b);
          
          for(int i=a; i<=b; i++) x[i]=reci[i];
          
          int j=a,k=m+1,l=a;
          while(l<=b)
          {
              if(j==m+1)
                {
                    reci[l]=x[k];
                    k++;
                    l++;
                }
              else if(k==b+1)
                {
                    reci[l]=x[j];
                    j++;
                    l++;
                }
              else if(cmp(x[j],x[k]))
                {
                    reci[l]=x[j];
                    j++;
                    l++;
                }
              else
                {
                    reci[l]=x[k];
                    k++;
                    l++;
                }
          }
      }
}

int main(int argc, char *argv[])
{
    /*rec *first=NULL;
    rec *cur=NULL;
    int n;
    scanf("%d",&n);
    char chr;
    scanf("%c",&chr);
    for(int i=0; i<n; i++)
      {
          char c;
          char *str=(char*)malloc(50*sizeof(char));
          scanf("%c",&c);
          int len=0;
          while(c!='\n')
          {
              str[len]=c;
              len++;
              scanf("%c",&c);
          }
          str[len]='\0';
          rec *novo=new rec;
          novo->str=str;
          novo->length=len;
          novo->next=NULL;
          if(cur!=NULL) cur->next=novo;
          else first=novo;
          cur=novo;
          //scanf("%c",&c);
      }*/
    FILE *in,*out;
    in=fopen("igra.in","r");
    out=fopen("igra.out","w");
    int n;
    fscanf(in,"%d",&n);
    char chr;
    fscanf(in,"%c",&chr);
    for(int i=0; i<n; i++)
      {
          char c;
          char *str=(char*)malloc(50*sizeof(char));
          fscanf(in,"%c",&c);
          int len=0;
          while(c!='\n' && !feof(in))
          {
              str[len]=c;
              len++;
              fscanf(in,"%c",&c);
          }
          str[len]='\0';
          rec *novo=new rec;
          novo->str=str;
          novo->length=len;
          reci[i]=*novo;
      }
    msort(0,n-1);

    int pl=0,rnd=0;
    int start=0,end=n-1;
    while(end-start>0)
      {
          int min=99,max=-1,indMin=-1,indMax=-1;
          char minChr='z'+1,maxChr='z'+1;
          for(int i=start; i<end; i++)
            {
                int len=reci[i].length;
                if(len%2==pl && (len<min || (len==min && reci[i].str[rnd]<minChr)))
                  {
                      indMin=i;
                      min=len;
                      minChr=reci[i].str[rnd];
                  }
                if(len%2==(pl+1)%2 && (len>max || (len==min && reci[i].str[rnd]<maxChr)))
                  {
                      indMax=i;
                      max=len;
                      maxChr=reci[i].str[rnd];
                  }
            }
          int choose=-1;
          if(indMin>-1) choose=indMin;
          else choose=indMax;
                
          int pos=0;
          while(!(reci[pos].length>=rnd && reci[pos].str[rnd]==reci[choose].str[rnd])) pos++;
          start=pos;
          while(reci[pos].length>=rnd && reci[pos].str[rnd]==reci[choose].str[rnd]) pos++;
          end=pos-1;
          pl=(pl+1)%2;
          rnd++;
      }
    pl=(pl+reci[start].length-rnd)%2;
    fprintf(out,"%d\n",pl+1);
    fprintf(out,"%s\n",reci[start].str);
    fclose(in);
    fclose(out);
    return 0;
}

/*
8
avioni
banana
berza
selo
seobe
kosa
kola
kuca
*/
