#include <bits/stdc++.h>
using namespace std;
int n;
string a[100005];
long long val[200][200];
long long d[200][200][200];
inline long long norm(long long a) {
  return (a < 0 ? a + 998244353 : a >= 998244353 ? a - 998244353 : a);
}
inline long long mul(long long a, long long b) {
  return norm(a * b % 998244353);
}
bool dx(string s) {
  int len = s.length();
  for (int i = 0; i < len; ++i)
    if (s[i] != s[len - i - 1]) return 0;
  return 1;
}
bool check(int c) {
  if ('0' <= c && c <= '9') return 1;
  if ('a' <= c && c <= 'z') return 1;
  if ('A' <= c && c <= 'Z') return 1;
  return 0;
}
long long value(int i, int j, int k, int h) {
  int a = (i == j), b = (j == k), c = (k == h);
  if (a == 0) swap(a, c);
  if (a == 0 && b == 1) return 12;
  if (a == 0 && b == 0) return 24;
  if (c == 1 && b == 1) return 1;
  if (c == 1 && b == 0) return 6;
  if (b == 1) return 4;
  return 12;
}
long long get(int len) {
  memset(val, 0, sizeof val);
  memset(d, 0, sizeof d);
  for (int i = 0; i < n; ++i)
    if ((i == 0 || a[i] != a[i - 1]) && (a[i].length() == len)) {
      val[a[i][0]][a[i][len - 1]]++;
      if (!dx(a[i])) val[a[i][len - 1]][a[i][0]]++;
    }
  for (int h = 48; h <= 'z'; ++h)
    for (int i = 48; check(h) && i <= 'z'; ++i)
      for (int j = i; check(i) && j <= 'z'; ++j)
        for (int k = j; check(j) && k <= 'z'; ++k)
          d[i][j][k] =
              norm(d[i][j][k] + mul(val[i][h], mul(val[j][h], val[k][h])));
  long long ans = 0;
  for (int i = 48; i <= 'z'; ++i)
    for (int j = i; check(i) && j <= 'z'; ++j)
      for (int k = j; check(j) && k <= 'z'; ++k)
        for (int h = k; check(k) && h <= 'z'; ++h)
          ans = norm(ans +
                     mul(value(i, j, k, h),
                         mul(d[i][j][k],
                             mul(d[i][j][h], mul(d[i][k][h], d[j][k][h])))));
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    string s = a[i];
    reverse(s.begin(), s.end());
    a[i] = max(a[i], s);
  }
  sort(a, a + n);
  long long ans = 0;
  for (int i = 3; i <= 10; ++i) ans = norm(ans + get(i));
  cout << ans;
  return 0;
}
