#include <bits/stdc++.h>
using namespace std;
map<string, bool> mymap;
const int mod = 998244353;
int cong(int x, int y) {
  if (1ll * x + 1ll * y >= mod)
    return (1ll * x + 1ll * y) % mod;
  else
    return 1ll * x + 1ll * y;
}
int nhan(int x, int y) {
  if (1ll * x * 1ll * y >= mod)
    return (1ll * x * 1ll * y) % mod;
  else
    return 1ll * x * 1ll * y;
}
int cnt[15][65][65], dp[15][65][65][65];
int name[125];
int n;
int main() {
  cin.tie(0), ios::sync_with_stdio(0);
  cin >> n;
  int lmao = 0;
  for (int i = (int)('a'); i <= (int)('z'); ++i) name[i] = lmao++;
  for (int i = (int)('A'); i <= (int)('Z'); ++i) name[i] = lmao++;
  for (int i = (int)('0'); i <= (int)('9'); ++i) name[i] = lmao++;
  lmao--;
  for (int i = 1; i <= n; ++i) {
    string s;
    cin >> s;
    string t = s;
    if (mymap.count(s)) continue;
    reverse(s.begin(), s.end());
    mymap[s] = 1;
    int m = s.length();
    cnt[m][name[(int)(s[0])]][name[(int)(s[m - 1])]]++;
    if (s != t) cnt[m][name[(int)(s[m - 1])]][name[(int)(s[0])]]++;
  }
  int sum = 0;
  for (int len = 3; len <= 10; ++len) {
    for (int i = 0; i <= lmao; ++i) {
      for (int j = i; j <= lmao; ++j) {
        for (int k = j; k <= lmao; ++k) {
          int x = 0;
          for (int l = 0; l <= lmao; ++l)
            x = cong(
                x, nhan(nhan(cnt[len][l][i], cnt[len][l][j]), cnt[len][l][k]));
          dp[len][i][j][k] = x;
          dp[len][i][k][j] = x;
          dp[len][j][i][k] = x;
          dp[len][j][k][i] = x;
          dp[len][k][i][j] = x;
          dp[len][k][j][i] = x;
        }
      }
    }
    for (int i = 0; i <= lmao; ++i) {
      for (int j = i; j <= lmao; ++j) {
        for (int k = 0; k <= lmao; ++k) {
          for (int l = k; l <= lmao; ++l) {
            int x = nhan(nhan(nhan(dp[len][i][j][k], dp[len][i][j][l]),
                              dp[len][i][l][k]),
                         dp[len][j][l][k]);
            if (i != j) x = nhan(x, 2);
            if (k != l) x = nhan(x, 2);
            sum = cong(sum, x);
          }
        }
      }
    }
  }
  cout << sum;
}
