#include <cstdio>
#include <cstring>

#define forn(i, n) for (int i = 0; i < (int)(n); i++)

#define m 103

char s[m][m], a[m];
int n, l, r, ans, is[m][26];

int main()
{
  freopen("bank.in", "r", stdin);
  freopen("bank.out", "w", stdout);
  scanf("%d", &n);
  forn (i, n)
    scanf("%s", s[i]);
  scanf("%s", a);
  l = strlen(a);
  memset(is, -1, sizeof(is));
  forn (i, n)
    forn (j, l)
      is[j][s[i][j] - 'a'] = i;
  ans = l + 1, r = -1;
  forn (i, n)
  {
    int res = 0;
    bool ok = true;
    forn (j, l)
      if (a[j] != s[i][j])
        if (is[j][a[j] - 'a'] != -1)
          res++;
        else
          ok = false;
    if (ok && ans > res)
      ans = res, r = i;
  }
  printf("%d\n", r == -1 ? -1 : ans);
  if (ans <= l)
    forn (i, l)
      if (a[i] != s[r][i])
        printf("%d %d %d\n", r + 1, is[i][a[i] - 'a'] + 1, i + 1);
  return 0;
}
