#include <bits/stdc++.h>
using namespace std;
map<int, int> ma;
int main() {
  int n, k;
  cin >> n >> k;
  string pwd;
  for (int i = 0; i < n; i++) {
    string tmp;
    cin >> tmp;
    ma[tmp.size()] += 1;
  }
  cin >> pwd;
  int psz = pwd.size();
  int prev = 0;
  for (auto ele : ma) {
    if (ele.first != psz) {
      prev += ele.second;
    } else {
      int val1 = (prev / k) * 5 + prev + 1;
      prev += ele.second;
      prev--;
      int val2 = (prev / k) * 5 + prev + 1;
      cout << val1 << " " << val2 << "\n";
    }
  }
  return 0;
}
