#include <stdio.h>
#include <ctype.h>

main (argc, argv)

int	argc;
char	*argv[];
{
  FILE	*f;
  int	c;
  char	*fn= argv[1];
  int	width, height;
  int	nfields;
  int	nwords;
  char	s[1000];

  if (argc != 2) {
    fprintf(stderr, "Usage: %s iconfile\n", argv[0]);
    exit(1);
  }

  if ((f= fopen(fn, "r")) < 0) {
    perror(fn);
    exit(1);
  }

  nfields= fscanf(f, "%*s %*s Width=%d, Height=%d", &width, &height);
  if (nfields != 2) {
    fprintf(stderr, "%s has bad format (found %d fields)\n", fn, nfields);
    exit(1);
  }
  printf("%d\n%d\n", width, height);
  nwords= height * ((width + 15)/16);
  fgets(s, 1000, f);
  fgets(s, 1000, f);
  for (; nwords > 0; nwords--) {
    int m;
    while ((m= fgetc(f)) != EOF && m != 'x')
      ;
    if ((nfields= fscanf(f, "%x", &m)) != 1) {
	fprintf(stderr, "%s has bad format (cannot read enough words)\n", fn);
	exit(1);
    }
    printf("%04x", m);
  }
  printf("\n");
  exit(0);
}
