Problem: Let LCP(s, t) be the length of the longest common prefix of strings s and t. Also let s[x ... y] be the substring of s from index x to index y (inclusive). For example, if s =  "abcde", then s[1 ... 3] = "abc", s[2 ... 5] = "bcde".

You are given a string s of length n and q queries. Each query is a pair of integer sets a_1, a_2, ..., a_k and b_1, b_2, ..., b_l. Calculate ∑_{i = 1}^{i = k} ∑_{j = 1}^{j = l}{LCP(s[a_i ... n], s[b_j ... n])} for each query.

Input

The first line contains two integers n and q (1 ≤ n, q ≤ 2 ⋅ 10^5) — the length of string s and the number of queries, respectively.

The second line contains a string s consisting of lowercase Latin letters (|s| = n).

Next 3q lines contains descriptions of queries — three lines per query. The first line of each query contains two integers k_i and l_i (1 ≤ k_i, l_i ≤ n) — sizes of sets a and b respectively.

The second line of each query contains k_i integers a_1, a_2, ... a_{k_i} (1 ≤ a_1 < a_2 < ... < a_{k_i} ≤ n) — set a.

The third line of each query contains l_i integers b_1, b_2, ... b_{l_i} (1 ≤ b_1 < b_2 < ... < b_{l_i} ≤ n) — set b.

It is guaranteed that ∑_{i = 1}^{i = q}{k_i} ≤ 2 ⋅ 10^5 and ∑_{i = 1}^{i = q}{l_i} ≤ 2 ⋅ 10^5.

Output

Print q integers — answers for the queries in the same order queries are given in the input.

Example

Input

7 4
abacaba
2 2
1 2
1 2
3 1
1 2 3
7
1 7
1
1 2 3 4 5 6 7
2 2
1 5
1 5


Output

13
2
12
16

Note

Description of queries: 

  1. In the first query s[1 ... 7] = abacaba and s[2 ... 7] = bacaba are considered. The answer for the query is LCP(abacaba, abacaba) + LCP(abacaba, bacaba) + LCP(bacaba, abacaba) + LCP(bacaba, bacaba) = 7 + 0 + 0 + 6 = 13.
  2. In the second query s[1 ... 7] = abacaba, s[2 ... 7] = bacaba, s[3 ... 7] = acaba and s[7 ... 7] = a are considered. The answer for the query is LCP(abacaba, a) + LCP(bacaba, a) + LCP(acaba, a) = 1 + 0 + 1 = 2.
  3. In the third query s[1 ... 7] = abacaba are compared with all suffixes. The answer is the sum of non-zero values: LCP(abacaba, abacaba) + LCP(abacaba, acaba) + LCP(abacaba, aba) + LCP(abacaba, a) = 7 + 1 + 3 + 1 = 12.
  4. In the fourth query s[1 ... 7] = abacaba and s[5 ... 7] = aba are considered. The answer for the query is LCP(abacaba, abacaba) + LCP(abacaba, aba) + LCP(aba, abacaba) + LCP(aba, aba) = 7 + 3 + 3 + 3 = 16. 

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &x) {
  x = 0;
  T f = 1;
  char ch = getchar();
  while (!(ch >= '0' && ch <= '9')) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
template <class T>
inline void write(T x) {
  if (x < 0) x = -x, putchar('-');
  if (x / 10) write(x / 10);
  putchar('0' + x % 10);
}
const int N = 4e5 + 10;
int ch[N][26], pre[N], mxl[N], last = 1, cnt = 1, pos[N], dfn[N], tot, bel[N],
                               prt[N], sz[N], son[N], dep[N];
struct Edge {
  int b, nt;
} e[N];
int e_num, head[N];
inline void anode(int u, int v) {
  e[++e_num].b = v;
  e[e_num].nt = head[u];
  head[u] = e_num;
}
inline int Extend(int c) {
  int p = last, np = ++cnt;
  last = np;
  mxl[np] = mxl[p] + 1;
  for (; p && !ch[p][c]; p = pre[p]) ch[p][c] = np;
  if (!p) {
    pre[np] = 1;
    return np;
  }
  int q = ch[p][c], nq = ++cnt;
  if (mxl[q] == mxl[p] + 1) {
    pre[np] = q;
    --cnt;
    return np;
  }
  memcpy(ch[nq], ch[q], sizeof(ch[q]));
  mxl[nq] = mxl[p] + 1, pre[nq] = pre[q], pre[q] = pre[np] = nq;
  for (; ch[p][c] == q; p = pre[p]) ch[p][c] = nq;
  return np;
}
inline void dfs1(int u) {
  sz[u] = 1;
  for (int i = head[u]; i; i = e[i].nt) {
    int v = e[i].b;
    dep[v] = dep[u] + 1, prt[v] = u;
    dfs1(v);
    sz[u] += sz[v];
    if (sz[v] > sz[son[u]]) son[u] = v;
  }
}
inline void dfs2(int u, int chain) {
  dfn[u] = ++tot;
  bel[u] = chain;
  if (son[u]) dfs2(son[u], chain);
  for (int i = head[u]; i; i = e[i].nt) {
    int v = e[i].b;
    if (v == son[u]) continue;
    dfs2(v, v);
  }
}
inline int LCA(int x, int y) {
  while (bel[x] != bel[y]) {
    if (dep[bel[x]] < dep[bel[y]]) swap(x, y);
    x = prt[bel[x]];
  }
  if (dep[x] < dep[y]) swap(x, y);
  return y;
}
int numa[N], numb[N], sza[N], szb[N], stk[N], top, b[N], ntot;
inline bool cmp(const int &a, const int &b) { return dfn[a] < dfn[b]; }
vector<int> ve[N];
char s[N];
inline void add(int fa, int u) {
  sza[fa] += sza[u];
  szb[fa] += szb[u];
}
int mem[N], mtot;
inline void vbuild(int x) {
  if (top == 1) {
    stk[++top] = x;
    return;
  }
  int lca = LCA(x, stk[top]);
  if (lca == stk[top]) {
    stk[++top] = x;
    return;
  }
  while (top > 1 && dfn[stk[top - 1]] >= dfn[lca])
    ve[stk[top - 1]].push_back(stk[top]), add(stk[top - 1], stk[top]),
        mem[++mtot] = stk[top], --top;
  if (stk[top] != lca)
    ve[lca].push_back(stk[top]), add(lca, stk[top]), mem[++mtot] = stk[top],
                                                     stk[top] = lca;
  stk[++top] = x;
}
long long ans;
inline void dp(int u) {
  ans += 1ll * numb[u] * sza[u] * mxl[u];
  for (int i = 0, siz = ve[u].size(); i < siz; i++) {
    int v = ve[u][i];
    dp(v);
    ans += 1ll * szb[v] * (sza[u] - sza[v]) * mxl[u];
  }
  ve[u].clear();
}
int main() {
  int n, Q;
  read(n), read(Q);
  scanf("%s", s + 1);
  for (int i = n; i >= 1; i--) pos[i] = Extend(s[i] - 'a');
  for (int i = 2; i <= cnt; i++) anode(pre[i], i);
  dfs1(1), dfs2(1, 1);
  while (Q--) {
    for (int i = 1; i <= mtot; i++)
      numa[mem[i]] = numb[mem[i]] = sza[mem[i]] = szb[mem[i]] = 0;
    ans = ntot = mtot = 0;
    int cnta, cntb;
    read(cnta), read(cntb);
    for (int i = 1; i <= cnta; i++) {
      int x;
      read(x);
      ++numa[pos[x]], ++sza[pos[x]];
      b[++ntot] = pos[x];
    }
    for (int i = 1; i <= cntb; i++) {
      int x;
      read(x);
      ++numb[pos[x]], ++szb[pos[x]];
      b[++ntot] = pos[x];
    }
    sort(b + 1, b + 1 + ntot, cmp);
    ntot = unique(b + 1, b + 1 + ntot) - b - 1;
    stk[top = 1] = 1;
    mem[++mtot] = 1;
    for (int i = 1; i <= ntot; i++) vbuild(b[i]);
    while (top > 1)
      ve[stk[top - 1]].push_back(stk[top]), add(stk[top - 1], stk[top]),
          mem[++mtot] = stk[top], --top;
    dp(1);
    write(ans), putchar('\n'), putchar('\n');
  }
  return 0;
}