#include <cstdio>
#include <cassert>
#include <algorithm>

using namespace std;

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

#define m 103

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

int main()
{
  freopen("bank.in", "r", stdin);
  freopen("bank.out", "w", stdout);
  scanf("%d", &n);
  assert(2 <= n && n <= 100);
  forn (i, n)
    scanf("%s", s[i]);
  l = strlen(s[0]);
  assert(2 <= l && l <= 100);
  forn (i, n)
    assert(strlen(s[i]) == l);
  scanf("%s", a);
  assert(strlen(a) == l);
  memset(is, -1, sizeof(is));
  forn (i, n)
    forn (j, l)
    {
      assert('a' <= s[i][j] && s[i][j] <= 'z');
      is[j][s[i][j] - 'a'] = i;
    }
  forn (i, l)
    assert('a' <= a[i] && a[i] <= 'z');
  int ans = l + 1, rr = -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;
          break;
        }
    if (ok && ans > res)
      ans = res, rr = i;
  }
  if (ans > l)
    puts("-1");
  else
  {
    printf("%d\n", ans);
    forn (i, l)
      if (a[i] != s[rr][i])
        printf("%d %d %d\n", rr + 1, is[i][a[i] - 'a'] + 1, i + 1);
  }
  return 0;
}
