#include <cstring>
#include <iostream>
#include <string>
using namespace std;
void caesar(string &s, int n) {
  int i;
  char c;
  for (i = 0; c = s[i]; i++) {
    if (c >= 'a' && c <= 'z') 
      s[i] = 'a' + (c - 'a' + n) % 26;
  }
}
int main() {
  int n;
  string s;
  while (getline(cin, s)) {
    for (n = 0; n < 26; n++) {
      caesar(s, 1);
      if (s.find("the") != string::npos || s.find("this") != string::npos || s.find("that") != string::npos) {
        cout << s << endl;
        break;
      }
    }
  }
  return 0;
}
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, q;
    
    while (scanf("%d %d", &n, &q) && n){
        int a[128] = {0};
        
        for (int i = 0; i < n; i++){
            int m;
            scanf("%d", &m);
            for (int j = 0; j < m; j++){
                int x;
                scanf("%d", &x);
                a[x]++;
            }
        }
        
        int mpos = 1;
        
        for (int i = 1; i < 128; i++){
            if (a[i] > a[mpos]) mpos = i;
        }
        
        printf("%d\n", mpos * (a[mpos] >= q));
    }
    
    return (0);
}