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

static char ring[40];
static unsigned iring = 0;

int
rgetc(FILE *ifp)
{
  int c;
  c = getc(ifp);
  ring[iring++] = c;
  iring %= sizeof(ring);
  return c;
}

char *
match(char *buf, int sz, const char *pat)
{
  int ofs, i;
  for (ofs = sz - strlen(pat) - 1; ofs >= 0; ofs--) {
    for (i = 0; pat[i]; i++) {
      if (pat[i] == 'Z') {
        if ((buf[ofs+i] < 'A') || (buf[ofs+i] > 'Z')) goto next;
      } else if (pat[i] == '9') {
        if ((buf[ofs+i] < '0') || (buf[ofs+i] > '9')) goto next;
      } else {
        if (buf[ofs+i] != pat[i]) goto next;
      }
    }
    buf[ofs+i] = '\0';
    return buf + ofs;
    next: ;
  }
  return NULL;
}

char *
heading(void)
{
  static char buf[sizeof ring];
  char *h;
  memcpy(buf, ring + iring, sizeof ring - iring);
  memcpy(buf + sizeof ring - iring, ring, iring);
  h = match(buf, sizeof ring, "ZZZZ99 ZZZZ");
  if (h) return h;
  return "______ ____";
}

int
main()
{
  int state = 0;
  int c;
  while ((c = rgetc(stdin)) != EOF) {
    switch (state) {
    default:
    case 0: state = (c == 'B') ? 'B' : 0; break;
    case 'B': state = (c == 'U') ? 'U' : 0; break;
    case 'U': state = (c == 'F') ? 'F' : 0; break;
    case 'F':
      if (c == 'R') {
        unsigned char buf[17];
	unsigned char *sec1;
	unsigned ed, ctr, sctr;
	fread(buf + 5, 1, 12, stdin); 
        ed = buf[8];
	sec1 = buf + 8;
	if (ed == 4) {
	  ctr = (sec1[5] << 8) | sec1[6];
	  sctr = (sec1[7] << 8) | sec1[8];
	} else {
	  ctr = sec1[6];
	  sctr = sec1[5];
	}
	printf("%s,%u,%5u,%5u\n", heading(), ed, ctr, sctr);
      }
      state = 0;
      break;
    }
  }
  return 0;
}
