#include <bits/stdc++.h>
const uint32_t SIGMA = 62;
const uint32_t MAX_L = 10;
const uint32_t MIN_L = 3;
const uint32_t MOD = 998244353;
uint32_t wCnt[MAX_L + 1][SIGMA][SIGMA];
uint32_t reduce_char(char c) {
  if ((c >= 'a') && (c <= 'z')) {
    return c - 'a';
  } else if ((c >= 'A') && (c <= 'Z')) {
    return c - 'A' + 26;
  } else {
    return c - '0' + 52;
  }
}
void input() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  uint32_t n;
  std::cin >> n;
  std::vector<std::string> words;
  for (uint32_t i = 0; i < n; i++) {
    std::string s;
    std::cin >> s;
    words.emplace_back(s.rbegin(), s.rend());
    words.push_back(std::move(s));
  }
  std::sort(words.begin(), words.end());
  for (uint32_t i = 0; i < words.size(); i++) {
    if ((i > 0) && (words[i] == words[i - 1])) {
      continue;
    }
    const std::string &s = words[i];
    wCnt[s.size()][reduce_char(s.front())][reduce_char(s.back())]++;
  }
}
uint64_t helpDp[MAX_L + 1][SIGMA][SIGMA][SIGMA];
void calc_help_dp() {
  for (uint32_t l = MIN_L; l <= MAX_L; l++) {
    for (uint32_t i = 0; i < SIGMA; i++) {
      uint32_t *cwcnt = wCnt[l][i];
      for (uint32_t j1 = 0; j1 < SIGMA; j1++) {
        uint32_t p1 = cwcnt[j1];
        for (uint32_t j2 = 0; j2 < SIGMA; j2++) {
          uint32_t p2 = uint64_t(cwcnt[j2]) * p1 % MOD;
          for (uint32_t j3 = 0; j3 < SIGMA; j3++) {
            uint32_t p3 = uint64_t(cwcnt[j3]) * p2 % MOD;
            helpDp[l][j1][j2][j3] += p3;
          }
        }
      }
    }
  }
  for (uint32_t l = MIN_L; l <= MAX_L; l++) {
    for (uint32_t j1 = 0; j1 < SIGMA; j1++) {
      for (uint32_t j2 = 0; j2 < SIGMA; j2++) {
        for (uint32_t j3 = 0; j3 < SIGMA; j3++) {
          helpDp[l][j1][j2][j3] %= MOD;
          helpDp[l][j2][j1][j3] %= MOD;
          assert(helpDp[l][j1][j2][j3] == helpDp[l][j2][j1][j3]);
        }
      }
    }
  }
}
inline uint64_t calc_cnt(uint32_t l, uint32_t j1, uint32_t j2, uint32_t j3,
                         uint32_t j4) {
  uint64_t cur = helpDp[l][j1][j2][j3];
  cur = cur * helpDp[l][j1][j2][j4] % MOD;
  cur = cur * helpDp[l][j1][j3][j4] % MOD;
  cur = cur * helpDp[l][j2][j3][j4] % MOD;
  return cur;
}
uint32_t calc_ans() {
  uint64_t ans = 0;
  for (uint32_t l = MIN_L; l <= MAX_L; l++) {
    for (uint32_t j1 = 0; j1 < SIGMA; j1++) {
      ans += calc_cnt(l, j1, j1, j1, j1);
      ans %= MOD;
      for (uint32_t j2 = j1 + 1; j2 < SIGMA; j2++) {
        ans += calc_cnt(l, j1, j1, j1, j2) * 4;
        ans += calc_cnt(l, j1, j1, j2, j2) * 6;
        ans += calc_cnt(l, j1, j2, j2, j2) * 4;
        ans %= MOD;
        for (uint32_t j3 = j2 + 1; j3 < SIGMA; j3++) {
          ans += calc_cnt(l, j1, j2, j3, j3) * 12;
          ans += calc_cnt(l, j1, j2, j2, j3) * 12;
          ans += calc_cnt(l, j1, j1, j2, j3) * 12;
          ans %= MOD;
          for (uint32_t j4 = j3 + 1; j4 < SIGMA; j4++) {
            ans += calc_cnt(l, j1, j2, j3, j4) * 24;
          }
        }
      }
    }
  }
  return ans % MOD;
}
int main() {
  input();
  calc_help_dp();
  std::cout << calc_ans() << "\n";
}
