#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx2,tune=native")
using namespace std;
const int LOG = 6, HRF = 62,
          MUL[2][2][2] = {{{2, 2}, {3, 4}}, {{12, 6}, {4, 1}}};
const unsigned long long MOD = 998244353, DOM = (1LL << 62) / MOD;
int N, L;
unsigned long long P, Q, H;
unsigned long long A[11][HRF][HRF];
unsigned long long B[HRF][HRF][HRF];
string S;
unordered_map<unsigned long long, bool> M[11];
int angka(char x) {
  if (x >= 'a') return x - 'a';
  if (x >= 'A') return x - 'A' + 26;
  return x - '0' + 52;
}
void balik() {
  for (int i = 0; i < L - 1 - i; i++) {
    swap(S[i], S[L - 1 - i]);
  }
  return;
}
unsigned long long ubah() {
  unsigned long long ret;
  ret = 0;
  for (int i = 0; i < L; i++) {
    ret <<= LOG;
    ret += angka(S[i]);
  }
  return ret;
}
inline unsigned long long rem(unsigned long long a) {
  return a - MOD * ((a >> 30) * DOM >> 32);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> S;
    L = S.length();
    P = ubah();
    balik();
    Q = ubah();
    if (M[L][min(P, Q)]) {
      continue;
    }
    M[L][min(P, Q)] = 1;
    A[L][angka(S[0])][angka(S[L - 1])]++;
    if (P != Q) {
      A[L][angka(S[L - 1])][angka(S[0])]++;
    }
  }
  for (int i = 3; i <= 10; i++) {
    for (int a = 0; a < HRF; a++) {
      for (int b = a; b < HRF; b++) {
        for (int c = b; c < HRF; c++) {
          B[a][b][c] = 0;
          for (int x = 0; x < HRF; x++) {
            B[a][b][c] += A[i][a][x] * A[i][b][x] * A[i][c][x];
          }
          B[a][b][c] %= MOD;
        }
      }
    }
    for (int a = 0; a < HRF; a++) {
      for (int b = a; b < HRF; b++) {
        for (int c = b; c < HRF; c++) {
          P = 0;
          for (int d = c + 1; d < HRF; d++) {
            P += rem(rem(B[a][b][c] * B[a][b][d]) *
                     rem(B[a][c][d] * B[b][c][d]));
          }
          H += ((P * MUL[0][c == b][b == a]) +
                rem(rem(B[a][b][c] * B[a][b][c]) *
                    rem(B[a][c][c] * B[b][c][c]))) *
               MUL[1][c == b][b == a];
        }
      }
    }
  }
  cout << H % MOD << '\n';
  return 0;
}
