#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T cei(T x, T y) {
  T t = (x + y - 1) / y;
  return t;
}
template <typename T>
inline T power(T base, T powerRaised) {
  if (powerRaised != 0)
    return (base * power(base, powerRaised - 1));
  else
    return 1;
}
template <typename T>
inline T gcd(T a, T b) {
  while (b) {
    b ^= a ^= b ^= a %= b;
  }
  return a;
}
template <typename T>
inline T lcm(T x, T y) {
  return x * y / gcd(x, y);
}
template <typename T>
inline T findLessPower(T base, T n) {
  if (n == 1) {
    return 0;
  }
  T temp = log(n) / log(base);
  if (power(base, temp) == n) {
    return temp - 1;
  } else {
    return temp;
  }
}
extern const int MOD = 998244353;
template <const int &MOD>
struct _m_int {
  int val;
  _m_int(int64_t v = 0) {
    if (v < 0) v = v % MOD + MOD;
    if (v >= MOD) v %= MOD;
    val = int(v);
  }
  _m_int(uint64_t v) {
    if (v >= MOD) v %= MOD;
    val = int(v);
  }
  _m_int(int v) : _m_int(int64_t(v)) {}
  _m_int(unsigned v) : _m_int(uint64_t(v)) {}
  explicit operator int() const { return val; }
  explicit operator unsigned() const { return val; }
  explicit operator int64_t() const { return val; }
  explicit operator uint64_t() const { return val; }
  explicit operator double() const { return val; }
  explicit operator long double() const { return val; }
  _m_int &operator+=(const _m_int &other) {
    val -= MOD - other.val;
    if (val < 0) val += MOD;
    return *this;
  }
  _m_int &operator-=(const _m_int &other) {
    val -= other.val;
    if (val < 0) val += MOD;
    return *this;
  }
  static unsigned fast_mod(uint64_t x, unsigned m = MOD) {
    return unsigned(x % m);
    unsigned x_high = unsigned(x >> 32), x_low = unsigned(x);
    unsigned quot, rem;
    asm("divl %4\n" : "=a"(quot), "=d"(rem) : "d"(x_high), "a"(x_low), "r"(m));
    return rem;
  }
  _m_int &operator*=(const _m_int &other) {
    val = fast_mod(uint64_t(val) * other.val);
    return *this;
  }
  _m_int &operator/=(const _m_int &other) { return *this *= other.inv(); }
  friend _m_int operator+(const _m_int &a, const _m_int &b) {
    return _m_int(a) += b;
  }
  friend _m_int operator-(const _m_int &a, const _m_int &b) {
    return _m_int(a) -= b;
  }
  friend _m_int operator*(const _m_int &a, const _m_int &b) {
    return _m_int(a) *= b;
  }
  friend _m_int operator/(const _m_int &a, const _m_int &b) {
    return _m_int(a) /= b;
  }
  _m_int &operator++() {
    val = val == MOD - 1 ? 0 : val + 1;
    return *this;
  }
  _m_int &operator--() {
    val = val == 0 ? MOD - 1 : val - 1;
    return *this;
  }
  _m_int operator++(int) {
    _m_int before = *this;
    ++*this;
    return before;
  }
  _m_int operator--(int) {
    _m_int before = *this;
    --*this;
    return before;
  }
  _m_int operator-() const { return val == 0 ? 0 : MOD - val; }
  friend bool operator==(const _m_int &a, const _m_int &b) {
    return a.val == b.val;
  }
  friend bool operator!=(const _m_int &a, const _m_int &b) {
    return a.val != b.val;
  }
  friend bool operator<(const _m_int &a, const _m_int &b) {
    return a.val < b.val;
  }
  friend bool operator>(const _m_int &a, const _m_int &b) {
    return a.val > b.val;
  }
  friend bool operator<=(const _m_int &a, const _m_int &b) {
    return a.val <= b.val;
  }
  friend bool operator>=(const _m_int &a, const _m_int &b) {
    return a.val >= b.val;
  }
  static const int SAVE_INV = int(1e6) + 5;
  static _m_int save_inv[SAVE_INV];
  static void prepare_inv() {
    for (int64_t p = 2; p * p <= MOD; p += p % 2 + 1) assert(MOD % p != 0);
    save_inv[0] = 0;
    save_inv[1] = 1;
    for (int i = 2; i < SAVE_INV; i++)
      save_inv[i] = save_inv[MOD % i] * (MOD - MOD / i);
  }
  _m_int inv() const {
    if (save_inv[1] == 0) prepare_inv();
    if (val < SAVE_INV) return save_inv[val];
    _m_int product = 1;
    int v = val;
    do {
      product *= MOD - MOD / v;
      v = MOD % v;
    } while (v >= SAVE_INV);
    return product * save_inv[v];
  }
  _m_int pow(int64_t p) const {
    if (p < 0) return inv().pow(-p);
    _m_int a = *this, result = 1;
    while (p > 0) {
      if (p & 1) result *= a;
      p >>= 1;
      if (p > 0) a *= a;
    }
    return result;
  }
  friend ostream &operator<<(ostream &os, const _m_int &m) {
    return os << m.val;
  }
};
template <const int &MOD>
_m_int<MOD> _m_int<MOD>::save_inv[_m_int<MOD>::SAVE_INV];
using mod_int = _m_int<MOD>;
const int maxn = 1e5 + 5;
const uint16_t INF = 2e15;
const char min_char = 'a';
const int alphabet = 26;
template <typename T_out, typename T_in>
vector<T_out> mobius_transform(int n, const vector<T_in> &values) {
  assert(int(values.size()) == 1 << n);
  vector<T_out> dp(values.begin(), values.end());
  for (int i = 0; i < n; i++)
    for (int base = 0; base < 1 << n; base += 1 << (i + 1))
      for (int mask = base; mask < base + (1 << i); mask++)
        dp[mask + (1 << i)] -= dp[mask];
  return dp;
}
void solve() {
  int n;
  cin >> n;
  vector<vector<uint16_t> > S(n, vector<uint16_t>(26, 0));
  for (int i = 0; i < n; ++i) {
    string str;
    cin >> str;
    for (char c : str) {
      S[i][c - min_char]++;
    }
  }
  vector<mod_int> dp(1 << n, 0);
  for (int mask = 1; mask < 1 << n; mask++) {
    vector<uint16_t> mins(26, INF);
    for (int i = 0; i < n; i++) {
      if (mask >> i & 1) {
        for (int c = 0; c < 26; c++) {
          mins[c] = min(mins[c], S[i][c]);
        }
      }
    }
    mod_int product = 1;
    for (int c : mins) {
      product *= c + 1;
    }
    dp[mask] = product;
  }
  vector<mod_int> dp_u = mobius_transform<mod_int>(n, dp);
  for (int i = 1; i < 1 << n; i++) {
    if (__builtin_popcount(i) % 2 == 0) {
      dp_u[i] = -dp_u[i];
    }
  }
  for (int i = 1; i < 1 << n; i++) {
  }
  int64_t ans = 0;
  for (int mask = 0; mask < 1 << n; mask++) {
    int k = __builtin_popcount(mask), sum = 0;
    for (int i = 0; i < n; i++) {
      if (mask >> i & 1) {
        sum += i + 1;
      }
    }
    ans ^= int64_t(dp_u[mask]) * sum * k;
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
}

### Prompt

Please formulate a Cpp solution to the following problem:

For a sequence of strings [t_1, t_2, ..., t_m], let's define the function f([t_1, t_2, ..., t_m]) as the number of different strings (including the empty string) that are subsequences of at least one string t_i. f([]) = 0 (i. e. the number of such strings for an empty sequence is 0).

You are given a sequence of strings [s_1, s_2, ..., s_n]. Every string in this sequence consists of lowercase Latin letters and is sorted (i. e., each string begins with several (maybe zero) characters a, then several (maybe zero) characters b, ..., ends with several (maybe zero) characters z).

For each of 2^n subsequences of [s_1, s_2, ..., s_n], calculate the value of the function f modulo 998244353.

Input

The first line contains one integer n (1 ≤ n ≤ 23) — the number of strings.

Then n lines follow. The i-th line contains the string s_i (1 ≤ |s_i| ≤ 2 ⋅ 10^4), consisting of lowercase Latin letters. Each string s_i is sorted.

Output

Since printing up to 2^{23} integers would be really slow, you should do the following:

For each of the 2^n subsequences (which we denote as [s_{i_1}, s_{i_2}, ..., s_{i_k}]), calculate f([s_{i_1}, s_{i_2}, ..., s_{i_k}]), take it modulo 998244353, then multiply it by k ⋅ (i_1 + i_2 + ... + i_k). Print the XOR of all 2^n integers you get.

The indices i_1, i_2, ..., i_k in the description of each subsequences are 1-indexed (i. e. are from 1 to n).

Examples

Input


3
a
b
c


Output


92


Input


2
aa
a


Output


21


Input


2
a
a


Output


10


Input


2
abcd
aabb


Output


124


Input


3
ddd
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaabbbbbbbbbbbcccccccccccciiiiiiiiiiiiiiiiiiiiiiooooooooooqqqqqqqqqqqqqqqqqqvvvvvzzzzzzzzzzzz


Output


15706243380

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T cei(T x, T y) {
  T t = (x + y - 1) / y;
  return t;
}
template <typename T>
inline T power(T base, T powerRaised) {
  if (powerRaised != 0)
    return (base * power(base, powerRaised - 1));
  else
    return 1;
}
template <typename T>
inline T gcd(T a, T b) {
  while (b) {
    b ^= a ^= b ^= a %= b;
  }
  return a;
}
template <typename T>
inline T lcm(T x, T y) {
  return x * y / gcd(x, y);
}
template <typename T>
inline T findLessPower(T base, T n) {
  if (n == 1) {
    return 0;
  }
  T temp = log(n) / log(base);
  if (power(base, temp) == n) {
    return temp - 1;
  } else {
    return temp;
  }
}
extern const int MOD = 998244353;
template <const int &MOD>
struct _m_int {
  int val;
  _m_int(int64_t v = 0) {
    if (v < 0) v = v % MOD + MOD;
    if (v >= MOD) v %= MOD;
    val = int(v);
  }
  _m_int(uint64_t v) {
    if (v >= MOD) v %= MOD;
    val = int(v);
  }
  _m_int(int v) : _m_int(int64_t(v)) {}
  _m_int(unsigned v) : _m_int(uint64_t(v)) {}
  explicit operator int() const { return val; }
  explicit operator unsigned() const { return val; }
  explicit operator int64_t() const { return val; }
  explicit operator uint64_t() const { return val; }
  explicit operator double() const { return val; }
  explicit operator long double() const { return val; }
  _m_int &operator+=(const _m_int &other) {
    val -= MOD - other.val;
    if (val < 0) val += MOD;
    return *this;
  }
  _m_int &operator-=(const _m_int &other) {
    val -= other.val;
    if (val < 0) val += MOD;
    return *this;
  }
  static unsigned fast_mod(uint64_t x, unsigned m = MOD) {
    return unsigned(x % m);
    unsigned x_high = unsigned(x >> 32), x_low = unsigned(x);
    unsigned quot, rem;
    asm("divl %4\n" : "=a"(quot), "=d"(rem) : "d"(x_high), "a"(x_low), "r"(m));
    return rem;
  }
  _m_int &operator*=(const _m_int &other) {
    val = fast_mod(uint64_t(val) * other.val);
    return *this;
  }
  _m_int &operator/=(const _m_int &other) { return *this *= other.inv(); }
  friend _m_int operator+(const _m_int &a, const _m_int &b) {
    return _m_int(a) += b;
  }
  friend _m_int operator-(const _m_int &a, const _m_int &b) {
    return _m_int(a) -= b;
  }
  friend _m_int operator*(const _m_int &a, const _m_int &b) {
    return _m_int(a) *= b;
  }
  friend _m_int operator/(const _m_int &a, const _m_int &b) {
    return _m_int(a) /= b;
  }
  _m_int &operator++() {
    val = val == MOD - 1 ? 0 : val + 1;
    return *this;
  }
  _m_int &operator--() {
    val = val == 0 ? MOD - 1 : val - 1;
    return *this;
  }
  _m_int operator++(int) {
    _m_int before = *this;
    ++*this;
    return before;
  }
  _m_int operator--(int) {
    _m_int before = *this;
    --*this;
    return before;
  }
  _m_int operator-() const { return val == 0 ? 0 : MOD - val; }
  friend bool operator==(const _m_int &a, const _m_int &b) {
    return a.val == b.val;
  }
  friend bool operator!=(const _m_int &a, const _m_int &b) {
    return a.val != b.val;
  }
  friend bool operator<(const _m_int &a, const _m_int &b) {
    return a.val < b.val;
  }
  friend bool operator>(const _m_int &a, const _m_int &b) {
    return a.val > b.val;
  }
  friend bool operator<=(const _m_int &a, const _m_int &b) {
    return a.val <= b.val;
  }
  friend bool operator>=(const _m_int &a, const _m_int &b) {
    return a.val >= b.val;
  }
  static const int SAVE_INV = int(1e6) + 5;
  static _m_int save_inv[SAVE_INV];
  static void prepare_inv() {
    for (int64_t p = 2; p * p <= MOD; p += p % 2 + 1) assert(MOD % p != 0);
    save_inv[0] = 0;
    save_inv[1] = 1;
    for (int i = 2; i < SAVE_INV; i++)
      save_inv[i] = save_inv[MOD % i] * (MOD - MOD / i);
  }
  _m_int inv() const {
    if (save_inv[1] == 0) prepare_inv();
    if (val < SAVE_INV) return save_inv[val];
    _m_int product = 1;
    int v = val;
    do {
      product *= MOD - MOD / v;
      v = MOD % v;
    } while (v >= SAVE_INV);
    return product * save_inv[v];
  }
  _m_int pow(int64_t p) const {
    if (p < 0) return inv().pow(-p);
    _m_int a = *this, result = 1;
    while (p > 0) {
      if (p & 1) result *= a;
      p >>= 1;
      if (p > 0) a *= a;
    }
    return result;
  }
  friend ostream &operator<<(ostream &os, const _m_int &m) {
    return os << m.val;
  }
};
template <const int &MOD>
_m_int<MOD> _m_int<MOD>::save_inv[_m_int<MOD>::SAVE_INV];
using mod_int = _m_int<MOD>;
const int maxn = 1e5 + 5;
const uint16_t INF = 2e15;
const char min_char = 'a';
const int alphabet = 26;
template <typename T_out, typename T_in>
vector<T_out> mobius_transform(int n, const vector<T_in> &values) {
  assert(int(values.size()) == 1 << n);
  vector<T_out> dp(values.begin(), values.end());
  for (int i = 0; i < n; i++)
    for (int base = 0; base < 1 << n; base += 1 << (i + 1))
      for (int mask = base; mask < base + (1 << i); mask++)
        dp[mask + (1 << i)] -= dp[mask];
  return dp;
}
void solve() {
  int n;
  cin >> n;
  vector<vector<uint16_t> > S(n, vector<uint16_t>(26, 0));
  for (int i = 0; i < n; ++i) {
    string str;
    cin >> str;
    for (char c : str) {
      S[i][c - min_char]++;
    }
  }
  vector<mod_int> dp(1 << n, 0);
  for (int mask = 1; mask < 1 << n; mask++) {
    vector<uint16_t> mins(26, INF);
    for (int i = 0; i < n; i++) {
      if (mask >> i & 1) {
        for (int c = 0; c < 26; c++) {
          mins[c] = min(mins[c], S[i][c]);
        }
      }
    }
    mod_int product = 1;
    for (int c : mins) {
      product *= c + 1;
    }
    dp[mask] = product;
  }
  vector<mod_int> dp_u = mobius_transform<mod_int>(n, dp);
  for (int i = 1; i < 1 << n; i++) {
    if (__builtin_popcount(i) % 2 == 0) {
      dp_u[i] = -dp_u[i];
    }
  }
  for (int i = 1; i < 1 << n; i++) {
  }
  int64_t ans = 0;
  for (int mask = 0; mask < 1 << n; mask++) {
    int k = __builtin_popcount(mask), sum = 0;
    for (int i = 0; i < n; i++) {
      if (mask >> i & 1) {
        sum += i + 1;
      }
    }
    ans ^= int64_t(dp_u[mask]) * sum * k;
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
}

```