n=int(eval(input()))

s=list(eval(input()))

l=s[:n]

r=s[n:][::-1]

d={}

e={}

for i in range(1<<n):

  s=t=u=v=''

  for j in range(n):

    if (i>>j)&1:

      s+=l[j]

      t+=r[j]

    else:

      u+=l[j]

      v+=r[j]

  d[(s,u)]=d.get((s,u),0)+1

  e[(t,v)]=e.get((t,v),0)+1

a=0

for i in list(d.keys()):

  a+=d[i]*e.get(i,0)

print(a)
n=int(eval(input()));s=eval(input());l=s[:n];r=s[n:][::-1];d={};e={}

for i in range(1<<n):

 s=t=u=v=''

 for j in range(n):

  if i>>j&1:s+=l[j];t+=r[j]

  else:u+=l[j];v+=r[j]

 d[s,u]=d.get((s,u),0)+1

 e[t,v]=e.get((t,v),0)+1

print((sum(d[i]*e.get(i,0)for i in list(d.keys()))))
n = int(eval(input()))
s = list(eval(input()))
l = s[:n]
r = s[n:][::-1]
d = {}
e = {}
for i in range(1 << n):
    s = t = u = v = ""
    for j in range(n):
        if (i >> j) & 1:
            s += l[j]
            t += r[j]
        else:
            u += l[j]
            v += r[j]
    d[(s, u)] = d.get((s, u), 0) + 1
    e[(t, v)] = e.get((t, v), 0) + 1
a = 0
for i in list(d.keys()):
    a += d[i] * e.get(i, 0)
print(a)

n = int(eval(input()))
s = eval(input())
l = s[:n]
r = s[n:][::-1]
d = {}
e = {}
for i in range(1 << n):
    s = t = u = v = ""
    for j in range(n):
        if i >> j & 1:
            s += l[j]
            t += r[j]
        else:
            u += l[j]
            v += r[j]
    d[s, u] = d.get((s, u), 0) + 1
    e[t, v] = e.get((t, v), 0) + 1
print((sum(d[i] * e.get(i, 0) for i in list(d.keys()))))

-s = list(eval(input())) +s = eval(input()) -        if (i >> j) & 1: +        if i >> j & 1: -    d[(s, u)] = d.get((s, u), 0) + 1 -    e[(t, v)] = e.get((t, v), 0) + 1 -a = 0 -for i in list(d.keys()): -    a += d[i] * e.get(i, 0) -print(a) +    d[s, u] = d.get((s, u), 0) + 1 +    e[t, v] = e.get((t, v), 0) + 1 +print((sum(d[i] * e.get(i, 0) for i in list(d.keys()))))