#include <bits/stdc++.h>
// mrrrowwww meeowwwww :3
// go play vivid/stasis! !! !!! https://vividstasis.gay
#define fo(i, a, b) for (auto i = (a); i < (b); i++)
#define of(i, a, b) for (auto i = (b); i-- > (a);)
#define f first
#define s second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define be(a) a.begin(), a.end()
using namespace std;
int ____init = []{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
return 0;
}();
int arrs[4100][4100];
int diff_count[4100][4100];
int main() {
int n, m, k; cin >> n >> m >> k;
fo(i, 0, n) {
string a; cin >> a;
fo(j, 0, m) {
switch (a[j]) {
case 'A': arrs[i][j] = 0; break;
case 'C': arrs[i][j] = 1; break;
case 'G': arrs[i][j] = 2; break;
case 'T': arrs[i][j] = 3; break;
}
}
fo(k, 0, i) {
fo(j, 0, m) {
diff_count[i][k] += arrs[i][j] != arrs[k][j];
diff_count[k][i] += arrs[i][j] != arrs[k][j];
}
}
}
fo(i, 0, n) {
fo(j, 0, n)
if (i != j && diff_count[i][j] != k) goto cont;
cout << i + 1;
cont:;
}
}