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
10
o
bhkqtwx
aadfhmnost
klz
ls
bccijquvw
ghhjklsv
jlmouuv
jx
ggttx
 11
cnp
abgkkmnzz
elnoy
dgghiknprw
gkooqvxyy
efmmvwx
mss
akq
efluy
fgnnswx
dlms
 6
agjlpuy
aatux
cjmnprrs
ceqqv
bgii
dglwz
 4
dfns
oty
hkm
blqsy
 2
ffhjorstx
deghhptvx
 5
egkprtwz
ikmmsvv
ddkqtx
d
cu
 7
ehtwx
asz
adgnnsy
bdhiirrtu
nnpvww
giilqswzz
dhlqquwxz
 20
aellqsu
ccfjkoszz
cdeggv
np
v
aadgghi
ggp
au
dgllppqswx
definrtuvw
q
fhmmt
djy
fu
gvy
bijlnsuz
r
dkmt
eegoqxxyz
eflprsy
 18
jnoq
bceekmor
goqvvv
jwx
gns
vx
aahvw
adg
abcefio
aiirsvvv
emmnnpsy
gp
adddfppsvx
aghmmnoqr
bcdfijotv
abchrrw
bfkuwxyz
bcejll
 9
djkmnopruw
ccdgrs
fhnnnruvw
zz
jkm
w
nnq
bccimtu
bo
 3
iiwx
ceffgnpty
bvz
 12
befkkmnt
gi
cdosxy
bcx
acdhlnqsss
fopyz
adgkmn
aabccgmxx
aaffmmsvvx
gimy
cm
z
 15
m
cghjx
bp
dfhhkru
bdfijkkqwy
adeefmq
q
bqu
beefhklpwx
cw
cqrrtwwy
bddffotyy
gos
bflowwyyz
gjx
 16
e
qz
chmv
wx
aabbguw
mpssz
mnnp
nprrruvv
chhipstw
ax
adhklostv
jq
hlnqsstv
f
ajostu
efhqsty
 13
aahijklr
cikty
v
acdkors
aghxy
e
bcjlosuuwz
aeejlqqqv
cdeinrsy
jkmow
ggoprsxz
e
acilsuuvz
 14
lmz
abc
chkw
beflmprrt
aaijkrrs
acddeehhln
acijkz
fknsz
adfgklpquz
ejklqtvw
abegkllqty
bqw
dgiilqrvxy
hhiiv
 19
bbbggiou
stuyz
uw
eggjlln
ccfijjs
fggjnu
bfw
euw
l
giwx
g
dffgiknqsv
aceux
loqqsx
aabcdpssv
hmsv
bfghitwx
ruwxz
bkowzz
 8
dfiinnqtuy
dfjkmqtvwx
cgsx
entwxz
achimnpqs
effjmnopx
ilmt
blorsuuwxx
 17
borw
acr
jj
eemmnoww
hjjo
aeflx
ejlsv
dstuu
aaijnsst
s
o
admpq
jktvvx
efiknsuuz
ehjkkmnoqw
dffhps
bbegio
 1
v
 21
k
jkklq
gkpuvxz
bchnrtw
aefkww
ce
jy
hmv
bhmpqrxz
bips
prwx
ekmqv
chlmxy
dfy
t
abegiyy
x
ep
bbbcdikuux
abcelntwyz
u

486984 1547476 4942 3389 4944 2647 92058 7423800 2361812 717012 6604 2052956 1374160 3601600 3830984 7423524 1821732 462000 2454176 2 10174976

#include <bits/stdc++.h>
using namespace std;
long long cnt[23][26], mod = 998244353;
long long p[26];
long long dp[1 << 23];
void add(long long &x, long long y) {
  x += y;
  if (x >= mod) x -= mod;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (auto u : s) cnt[i][u - 'a']++;
  }
  for (long long mask = 1; mask < 1 << n; mask++) {
    for (long long i = 0; i < 26; i++) p[i] = 1e9;
    for (long long i = 0; i < n; i++)
      if (mask & (1 << i)) {
        for (long long j = 0; j < 26; j++) p[j] = min(p[j], cnt[i][j]);
      }
    dp[mask] = 1;
    for (long long i = 0; i < 26; i++) {
      dp[mask] = dp[mask] * (p[i] + 1) % mod;
    }
  }
  for (long long i = 0; i < n; i++)
    for (long long mask = 0; mask < 1 << n; mask++)
      if (mask & (1 << i)) {
        add(dp[mask], mod - dp[mask - (1 << i)]);
      }
  long long ans = 0;
  for (long long mask = 1; mask < 1 << n; mask++) {
    long long k = __builtin_popcount(mask);
    long long sum = 0;
    for (long long i = 0; i < n; i++)
      if (mask & (1 << i)) {
        sum = sum + k * (i + 1);
      }
    if (k & 1)
      ans ^= (sum * dp[mask]);
    else
      ans ^= (sum * (mod - dp[mask]));
  }
  cout << ans;
  return 0;
}
