#include <cassert>
#include <cstdio>
#include <cstring>

#define maxn 110

char s[maxn][maxn];
int ex[maxn][26];

int main( void )
{
  freopen("bank.in", "r", stdin);
  freopen("bank.out", "w", stdout);

  int n;
  scanf("%d", &n);

  assert(2 <= n && n <= 100);

  while (getc(stdin) != '\n');

  for (int i = 0; i <= n; i++)
    gets(s[i]);

  int m = strlen(s[0]);

  assert(2 <= m && m <= 100);
  for (int i = 0; i <= n; i++)
  {
    assert((int)strlen(s[i]) == m);
    for (int j = 0; j < m; j++)
      assert('a' <= s[i][j] && s[i][j] <= 'z');
  }

  memset(ex, -1, sizeof(ex));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      ex[j][s[i][j] - 'a'] = i;

  int r = -1, rd = 1000000;
  for (int i = 0; i < n; i++)
  {
    int cd = 0;
    for (int j = 0; j < m; j++)
      if (s[n][j] != s[i][j])
        cd += ex[j][s[n][j] - 'a'] == -1 ? rd : 1;
    if (cd < rd)
      rd = cd, r = i;
  }

  if (r == -1)
  {
    printf("-1");
    return 0;
  }

  printf("%d\n", rd);
  for (int j = 0; j < m; j++)
    if (s[r][j] != s[n][j])
      printf("%d %d %d\n", r + 1, ex[j][s[n][j] - 'a'] + 1, j + 1);
 
  return 0;
}
