#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
class Mint {
 private:
  int value;

 public:
  constexpr Mint() : value() {}
  template <typename T>
  Mint(const T& x) {
    value = (-mod <= x && x < mod) ? x : x % mod;
    if (value < 0) value += mod;
  }
  template <typename U>
  explicit operator U() const {
    return static_cast<U>(value);
  }
  Mint& operator+=(const Mint& a) {
    if ((value += a.value) >= mod) value -= mod;
    return *this;
  }
  Mint& operator-=(const Mint& a) {
    if ((value -= a.value) < 0) value += mod;
    return *this;
  }
  Mint& operator++() { return *this += 1; }
  Mint& operator--() { return *this -= 1; }
  Mint operator++(int) {
    Mint result(*this);
    *this += 1;
    return result;
  }
  Mint operator--(int) {
    Mint result(*this);
    *this -= 1;
    return result;
  }
  Mint operator-() const { return Mint(-value); }
  Mint& operator*=(const Mint& a) {
    value = (long long)value * a.value % mod;
    return *this;
  }
  Mint& operator/=(const Mint& a) {
    assert(a.value != 0);
    return *this *= inverse(a);
  }
  friend Mint pow(Mint a, int b) {
    Mint r = 1;
    for (; b; a *= a, b >>= 1) {
      if (b & 1) r *= a;
    }
    return r;
  }
  static Mint inverse(const Mint& a) { return pow(a, mod - 2); }
  friend bool operator==(const Mint& a, const Mint& b) {
    return a.value == b.value;
  }
  friend bool operator!=(const Mint& a, const Mint& b) {
    return a.value != b.value;
  }
  friend bool operator<(const Mint& a, const Mint& b) {
    return a.value < b.value;
  }
  friend Mint operator+(const Mint& a, const Mint& b) { return Mint(a) += b; }
  friend Mint operator-(const Mint& a, const Mint& b) { return Mint(a) -= b; }
  friend Mint operator*(const Mint& a, const Mint& b) { return Mint(a) *= b; }
  friend Mint operator/(const Mint& a, const Mint& b) { return Mint(a) /= b; }
  friend ostream& operator<<(ostream& stream, const Mint& a) {
    return stream << a.value;
  }
  friend istream& operator>>(istream& stream, Mint& a) {
    return stream >> a.value;
  }
  friend string to_string(const Mint& a) { return to_string(a.value); }
};
void foo() {
  int n;
  cin >> n;
  vector<string> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  const int S = 1 << n;
  using T = short;
  vector<vector<T>> cntL(n, vector<T>(26));
  for (int i = 0; i < n; i++) {
    for (char ch : a[i]) {
      cntL[i][ch - 'a']++;
    }
  }
  const T INF = 3e4;
  vector<Mint> cnt(S, Mint(1));
  cnt[0] = 0;
  vector<vector<T>> cache(S, vector<T>(26));
  cache[0].assign(26, INF);
  for (int m = 1; m < S; m++) {
    int rest = m & (m - 1);
    const vector<T>& other = cache[rest];
    const vector<T>& last = cntL[__builtin_ctz(m)];
    for (int c = 0; c < 26; c++) {
      cache[m][c] = min(other[c], last[c]);
      cnt[m] *= cache[m][c] + 1;
    }
    if (__builtin_parity(m) == 0) {
      cnt[m] = -cnt[m];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int s = S - 1; s > 0; s--) {
      if (s & (1 << i)) {
        cnt[s] += cnt[s ^ (1 << i)];
      }
    }
  }
  long long ans = 0;
  for (int s = 1; s < S; s++) {
    int sum = 0;
    int k = 0;
    for (int i = 0; i < n; i++) {
      if (s & (1 << i)) {
        sum += i + 1;
        k++;
      }
    }
    ans ^= (long long)cnt[s] * k * sum;
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  foo();
}

### Prompt

Please create a solution in CPP 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;
const int mod = 998244353;
class Mint {
 private:
  int value;

 public:
  constexpr Mint() : value() {}
  template <typename T>
  Mint(const T& x) {
    value = (-mod <= x && x < mod) ? x : x % mod;
    if (value < 0) value += mod;
  }
  template <typename U>
  explicit operator U() const {
    return static_cast<U>(value);
  }
  Mint& operator+=(const Mint& a) {
    if ((value += a.value) >= mod) value -= mod;
    return *this;
  }
  Mint& operator-=(const Mint& a) {
    if ((value -= a.value) < 0) value += mod;
    return *this;
  }
  Mint& operator++() { return *this += 1; }
  Mint& operator--() { return *this -= 1; }
  Mint operator++(int) {
    Mint result(*this);
    *this += 1;
    return result;
  }
  Mint operator--(int) {
    Mint result(*this);
    *this -= 1;
    return result;
  }
  Mint operator-() const { return Mint(-value); }
  Mint& operator*=(const Mint& a) {
    value = (long long)value * a.value % mod;
    return *this;
  }
  Mint& operator/=(const Mint& a) {
    assert(a.value != 0);
    return *this *= inverse(a);
  }
  friend Mint pow(Mint a, int b) {
    Mint r = 1;
    for (; b; a *= a, b >>= 1) {
      if (b & 1) r *= a;
    }
    return r;
  }
  static Mint inverse(const Mint& a) { return pow(a, mod - 2); }
  friend bool operator==(const Mint& a, const Mint& b) {
    return a.value == b.value;
  }
  friend bool operator!=(const Mint& a, const Mint& b) {
    return a.value != b.value;
  }
  friend bool operator<(const Mint& a, const Mint& b) {
    return a.value < b.value;
  }
  friend Mint operator+(const Mint& a, const Mint& b) { return Mint(a) += b; }
  friend Mint operator-(const Mint& a, const Mint& b) { return Mint(a) -= b; }
  friend Mint operator*(const Mint& a, const Mint& b) { return Mint(a) *= b; }
  friend Mint operator/(const Mint& a, const Mint& b) { return Mint(a) /= b; }
  friend ostream& operator<<(ostream& stream, const Mint& a) {
    return stream << a.value;
  }
  friend istream& operator>>(istream& stream, Mint& a) {
    return stream >> a.value;
  }
  friend string to_string(const Mint& a) { return to_string(a.value); }
};
void foo() {
  int n;
  cin >> n;
  vector<string> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  const int S = 1 << n;
  using T = short;
  vector<vector<T>> cntL(n, vector<T>(26));
  for (int i = 0; i < n; i++) {
    for (char ch : a[i]) {
      cntL[i][ch - 'a']++;
    }
  }
  const T INF = 3e4;
  vector<Mint> cnt(S, Mint(1));
  cnt[0] = 0;
  vector<vector<T>> cache(S, vector<T>(26));
  cache[0].assign(26, INF);
  for (int m = 1; m < S; m++) {
    int rest = m & (m - 1);
    const vector<T>& other = cache[rest];
    const vector<T>& last = cntL[__builtin_ctz(m)];
    for (int c = 0; c < 26; c++) {
      cache[m][c] = min(other[c], last[c]);
      cnt[m] *= cache[m][c] + 1;
    }
    if (__builtin_parity(m) == 0) {
      cnt[m] = -cnt[m];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int s = S - 1; s > 0; s--) {
      if (s & (1 << i)) {
        cnt[s] += cnt[s ^ (1 << i)];
      }
    }
  }
  long long ans = 0;
  for (int s = 1; s < S; s++) {
    int sum = 0;
    int k = 0;
    for (int i = 0; i < n; i++) {
      if (s & (1 << i)) {
        sum += i + 1;
        k++;
      }
    }
    ans ^= (long long)cnt[s] * k * sum;
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  foo();
}

```