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

int main(){
	unsigned n, k, i, j;
	char rec[100];
	FILE *ulaz, *izlaz;

	scanf("%u %u", &n, &k);
	ulaz = fopen("ulaz.txt","r");
	izlaz = fopen("izlaz.txt", "w");
	
	if(ulaz==NULL || izlaz==NULL){
		printf("-1\n");
		return 0;
	}

	i=1;
	while(!feof(ulaz)){
		fscanf(ulaz, "%s", rec);
		if(i%n==0){
			for(j=1; j<=strlen(rec); j++){
				if(j%k!=0)
					fprintf(izlaz, "%c", rec[j-1]);
			}
			fprintf(izlaz, " ");
		}
		i++;	
	}

	fclose(ulaz);
	fclose(izlaz);

	return 0;
}
