#include typedef char str[101]; struct pp { str name, p1, p2, b, d; } p[1000]; int np, first; str buf, cmd, name, p1, p2, b, d; fix(char *s){ while (s[strlen(s)-1] == ' ') s[strlen(s)-1] = 0; } main(){ int i; while (gets(buf)) { *cmd = *name = *d = *p1 = *p2 = 0; sscanf(buf,"%s %[^:] : %[^:] : %[^:] : %[^:]",cmd,name,d,p1,p2); fix(name); fix(p1); fix(p2); fix(d); if (!strcmp(cmd,"BIRTH")) { strcpy(p[np].name, name); strcpy(p[np].b, d); if (strcmp(p1,p2) < 0) { strcpy(p[np].p1, p1); strcpy(p[np].p2, p2); } else { strcpy(p[np].p1, p2); strcpy(p[np].p2, p1); } np++; qsort(p,np,sizeof(struct pp),strcmp); } else if (!strcmp(cmd,"DEATH")) { for (i=0;i