# include <stdio.h>
main (argc,argv)

	int  	argc;
	char	*argv[];
{

	static char	head[40][55];
	static int	ph[40][4],key[20];
	int	m,k,i,j,nh,nr,nc,df,rgh;
	FILE	*fh,*fopen();
	FILE	*fi,*fopen();
	FILE	*fp,*fopen();

	long	lh;

	if ((fp=fopen(argv[1],"r")) == NULL) exit(0);
	fscanf(fp,"%d%d%d%d",&nh,&nr,&nc,&df);
	lh=1+nr*6L;
	for (i=0;i<nh;i++)
		for (j=0;j<4;j++)
		{
			fscanf(fp,"%d",&m);
			ph[i][j]=m;
			if (j==2) lh +=m;
			if (ph[i][3]>49)
				while((getc(fp))!='\n');
		}
	fclose(fp);
	for (k=2;k<argc;k++) sscanf(argv[k],"%d",&key[k]);
	fi=fopen("INFO","r");
	fscanf(fi,"%d",&rgh);
	fclose(fi);
	fh=fopen("HEAD","r");
	for (i=0;i<rgh;i++)
	{
		fseek(fh,i*lh,0);
		for (j=0;j<nh;j++) fgets(head[j],1+ph[j][2],fh);
		for (k=2;k<argc;k++) printf("%s:",head[key[k]]);
		printf ("%5d\n",i);
	}
}
