#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int N = 62, MOD = 998244353;
ll cc[N][N][N], cnt[11][N][N];
int f[8] = {24, 12, 12, 4, 12, 6, 4, 1};
int chr(char c) {
  if ('a' <= c && c <= 'z') return c - 'a';
  if ('A' <= c && c <= 'Z') return 26 + c - 'A';
  return 52 + c - '0';
}
ll ans = 0;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  string s;
  cin >> n;
  set<string> ss;
  for (int i = 0; i < (n); i++) {
    cin >> s;
    ss.insert(s);
    reverse((s).begin(), (s).end());
    ss.insert(s);
  }
  for (string i : ss) cnt[i.size()][chr(i[0])][chr(i.back())]++;
  int d1, d2, d3;
  for (int i = 3; i <= 10; i++) {
    for (int c1 = 0; c1 < (N); c1++)
      for (int c2 = 0; c2 < (N); c2++)
        for (int c3 = 0; c3 < (N); c3++) cc[c1][c2][c3] = 0;
    for (int c1 = 0; c1 < (N); c1++)
      for (int c2 = 0; c2 < (c1 + 1); c2++)
        for (int c3 = 0; c3 < (c2 + 1); c3++) {
          for (int c4 = 0; c4 < (N); c4++)
            cc[c1][c2][c3] += cnt[i][c1][c4] * cnt[i][c2][c4] * cnt[i][c3][c4];
          cc[c1][c2][c3] %= MOD;
        }
    for (int c1 = 0; c1 < (N); c1++)
      for (int c2 = 0; c2 < (c1 + 1); c2++) {
        d1 = (c1 == c2 ? 1 : 0);
        for (int c3 = 0; c3 < (c2 + 1); c3++) {
          d2 = d1 * 2 + (c2 == c3 ? 1 : 0);
          for (int c4 = 0; c4 < (c3 + 1); c4++) {
            d3 = d2 * 2 + (c3 == c4 ? 1 : 0);
            ans =
                (ans + cc[c1][c2][c3] * cc[c1][c2][c4] % MOD * cc[c1][c3][c4] %
                           MOD * cc[c2][c3][c4] % MOD * f[d3]) %
                MOD;
          }
        }
      }
  }
  cout << ans;
}
