#include <stdio.h>
#include <stdlib.h>
#include <string.h> 

typedef struct{
    int x;
    char str[51];
}Word;
int compare(const void *a,const void *b){
    Word *w1=(Word *)a;
    Word *w2=(Word *)b;
    if (w1->x!=w2->x){
        return w1->x-w2->x;
    }
    return strcmp(w1->str, w2->str);
}
int main(){
    int n; scanf("%d",&n);
    getchar();
    Word w[n];
    for (int i=0;i<n;i++){
        gets(w[i].str);
        w[i].x=strlen(w[i].str);
    }
    qsort(w,n,sizeof(Word),compare);
    for (int i=0;i<n;i++){
        char tmp[51]="";
        if (strcmp(tmp,w[i].str)==0) continue;
        printf("%s\n",w[i].str);
        strcpy(tmp,w[i].str);
    }

    
}