#include #include #include #define MAX 64 int main (void) { unsigned r, s, c; for (;;) { static unsigned char names[256][MAX], buf[MAX]; static unsigned vals[256]; size_t max, i; scanf ("%u%u%u", &r, &s, &c); if (r == 0 && s == 0 && c == 0) break; while (c-- != 0) { scanf ("%s", buf); memcpy (names[*buf], buf, sizeof (buf)); } while (r-- != 0) { scanf (" "); for (i = 0; i < s; i++) { unsigned char v; v = getchar (); if (v != '*') vals[v]++; } } max = 0; for (i = 1; i < 256; i++) { if (names[i][0] != 0 && vals[i] >= vals[max]) max = i; } printf ("Nejzravejsi cervotoc je %s.\n", names[max]); memset (names, 0, sizeof (names)); memset (vals, 0, sizeof (vals)); } return EXIT_SUCCESS; }