#include <bits/stdc++.h>
using namespace std;
const int Mod = 998244353;
const int sigma = 62;
int cnt[12][sigma][sigma], ways[sigma][sigma][sigma];
static int inm(int x, int y) { return (long long)x * y % Mod; }
static int inm(int x, int y, int z) { return (long long)x * y % Mod * z % Mod; }
static int inm(int x, int y, int z, int t) {
  return (long long)x * y % Mod * z % Mod * t % Mod;
}
static void add_to(int &x, int y) {
  x += y;
  if (x >= Mod) x -= Mod;
}
static int code(char c) {
  if (islower(c)) return c - 'a';
  if (isupper(c)) return c - 'A' + 26;
  return 52 + c - '0';
}
void prepare() {
  int i, n;
  string word;
  vector<string> words;
  cin >> n;
  for (i = 1; i <= n; ++i) {
    cin >> word;
    words.push_back(word);
    reverse(word.begin(), word.end());
    words.push_back(word);
  }
  sort(words.begin(), words.end());
  words.erase(unique(words.begin(), words.end()), words.end());
  for (auto &it : words) ++cnt[it.size()][code(it.front())][code(it.back())];
}
static int solve(int cnt[sigma][sigma]) {
  int i, j, k, p;
  int ans = 0;
  for (i = 0; i < sigma; ++i)
    for (j = i; j < sigma; ++j)
      for (k = j; k < sigma; ++k) {
        ways[i][j][k] = 0;
        for (p = 0; p < sigma; ++p)
          add_to(ways[i][j][k], inm(cnt[p][i], cnt[p][j], cnt[p][k]));
      }
  for (i = 0; i < sigma; ++i)
    for (j = i; j < sigma; ++j)
      for (k = j; k < sigma; ++k)
        for (p = k; p < sigma; ++p) {
          int curr =
              inm(ways[i][j][k], ways[i][j][p], ways[i][k][p], ways[j][k][p]);
          if (i == p)
            ;
          else if (i == k || j == p)
            curr = inm(curr, 4);
          else if (i == j && k == p)
            curr = inm(curr, 6);
          else if (i == j || j == k || k == p)
            curr = inm(curr, 12);
          else
            curr = inm(curr, 24);
          add_to(ans, curr);
        }
  return ans;
}
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  prepare();
  int i, ans = 0;
  for (i = 3; i <= 10; ++i) add_to(ans, solve(cnt[i]));
  cout << ans << '\n';
  return 0;
}
