#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353ll;
const int alph = 62;
int N;
long long sol = 0;
string str;
unordered_set<string> strings;
int let(char c) {
  if ('a' <= c && c <= 'z') {
    return c - 'a';
  } else if ('A' <= c && c <= 'Z') {
    return 26 + c - 'A';
  } else {
    return 52 + c - '0';
  }
}
bool rev() {
  int v = str.size();
  for (int i = 0; i < v; i++) {
    if (str[i] != str[v - i - 1]) {
      return true;
    }
  }
  return false;
}
int coun[11][70][70];
long long ways[70][70][70];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> str;
    if (strings.count(str) != 0) {
      continue;
    }
    int n = str.size();
    int v1 = let(str[0]), v2 = let(str[n - 1]);
    coun[n][v1][v2]++;
    if (rev()) {
      coun[n][v2][v1]++;
    }
    reverse(str.begin(), str.end());
    strings.insert(str);
  }
  for (int si = 3; si <= 10; si++) {
    for (int a = 0; a < alph; a++) {
      for (int b = a; b < alph; b++) {
        for (int c = b; c < alph; c++) {
          ways[a][b][c] = 0;
          for (int m = 0; m < alph; m++) {
            long long v = 1ll;
            v *= (long long)coun[si][m][a];
            v *= (long long)coun[si][m][b];
            v *= (long long)coun[si][m][c];
            v %= mod;
            ways[a][b][c] += v;
          }
          ways[a][b][c] %= mod;
        }
      }
    }
    for (int a = 0; a < alph; a++) {
      for (int b = a; b < alph; b++) {
        for (int c = b; c < alph; c++) {
          for (int d = c; d < alph; d++) {
            long long val = ways[a][b][c];
            val *= ways[a][b][d];
            val %= mod;
            val *= ways[a][c][d];
            val %= mod;
            val *= ways[b][c][d];
            val %= mod;
            int coun = 4 - (a == b) - (b == c) - (c == d);
            long long mult;
            if (coun == 1) {
              mult = 1ll;
            } else if (coun == 2) {
              if (a == b && c == d) {
                mult = 6ll;
              } else {
                mult = 4ll;
              }
            } else if (coun == 3) {
              mult = 12ll;
            } else if (coun == 4) {
              mult = 24ll;
            }
            sol += val * mult;
            sol %= mod;
          }
        }
      }
    }
  }
  cout << sol << '\n';
  return 0;
}
