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 rd(T &x) {
  x = 0;
  short f = 1;
  char c = getchar();
  while (c < '0' || c > '9') f = c == '-' ? -1 : 1, c = getchar();
  while (c <= '9' && c >= '0') x = x * 10 + c - '0', c = getchar();
  x *= f;
}
int n, q, id[400005], sza, szb, qu[400005], tot, rt, siz1[400005], siz2[400005],
    ty1[400005], ty2[400005];
int cnt, head[400005], nxt[400005 << 1], to[400005 << 1], dep[400005],
    f[400005][20], dfn[400005], num;
char s[400005];
bool vis[400005];
long long ans;
vector<int> vec[400005];
struct qwq {
  int pos, key;
  qwq(const int pp = 0, const int kk = 0) { pos = pp, key = kk; }
  inline bool operator<(const qwq &x) const { return key < x.key; }
} a[400005 << 1];
inline void add(int x, int y) {
  to[++cnt] = y, nxt[cnt] = head[x], head[x] = cnt;
  to[++cnt] = x, nxt[cnt] = head[y], head[y] = cnt;
}
struct SAM {
  int lst, cnt, ch[400005 << 1][26], fa[400005 << 1], l[400005 << 1];
  inline void insert(int c, int pos) {
    int p = lst, np = ++cnt;
    id[pos] = cnt;
    lst = np;
    l[np] = l[p] + 1;
    while (p && !ch[p][c]) ch[p][c] = np, p = fa[p];
    if (!p)
      fa[np] = 1;
    else {
      int q = ch[p][c];
      if (l[p] + 1 == l[q])
        fa[np] = q;
      else {
        int nq = ++cnt;
        l[nq] = l[p] + 1;
        memcpy(ch[nq], ch[q], sizeof ch[q]);
        fa[nq] = fa[q], fa[q] = fa[np] = nq;
        while (ch[p][c] == q) ch[p][c] = nq, p = fa[p];
      }
    }
  }
  inline void build() {
    scanf("%s", s + 1);
    int len = strlen(s + 1);
    lst = cnt = 1;
    for (int i = len; i; i--) insert(s[i] - 'a', i);
    for (int i = 1; i <= cnt; i++)
      if (fa[i]) add(fa[i], i);
  }
} sam;
void dfs(int u, int fa) {
  dfn[u] = ++num;
  for (int i = head[u], v; i; i = nxt[i])
    if ((v = to[i]) != fa) {
      dep[v] = dep[u] + 1;
      f[v][0] = u;
      for (int j = 1; j <= 18; j++) f[v][j] = f[f[v][j - 1]][j - 1];
      dfs(v, u);
    }
}
inline int LCA(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 18; i >= 0; i--)
    if (dep[f[x][i]] >= dep[y]) x = f[x][i];
  if (x == y) return x;
  for (int i = 18; i >= 0; i--)
    if (f[x][i] != f[y][i]) x = f[x][i], y = f[y][i];
  return f[x][0];
}
inline void init() {
  for (int i = 1; i <= sam.cnt; i++)
    vec[i].clear(), vis[i] = 0, ty1[i] = ty2[i] = 0;
  tot = 0;
}
void dfs2(int u, int fa) {
  siz1[u] = ty1[u], siz2[u] = ty2[u];
  for (int i = 0; i < vec[u].size(); i++)
    dfs2(vec[u][i], u), siz1[u] += siz1[vec[u][i]], siz2[u] += siz2[vec[u][i]];
  ans += 1LL * siz1[u] * siz2[u] * (sam.l[u] - sam.l[fa]);
}
inline long long solve() {
  ans = 0;
  int pt = tot, now = 0;
  for (int i = 1; i < pt; i++) {
    int z = LCA(a[i].pos, a[i + 1].pos);
    if (!vis[z]) vis[z] = 1, a[++tot] = qwq(z, dfn[z]);
  }
  sort(a + 1, a + tot + 1);
  qu[++now] = rt = a[1].pos;
  for (int i = 2; i <= tot; i++) {
    if (a[i].pos == a[i - 1].pos) continue;
    while (now > 1 && LCA(qu[now], a[i].pos) != qu[now]) now--;
    vec[qu[now]].push_back(a[i].pos);
    qu[++now] = a[i].pos;
  }
  dfs2(rt, 0);
  return ans;
}
int main() {
  rd(n);
  rd(q);
  sam.build();
  dfs(1, 0);
  while (q--) {
    rd(sza), rd(szb);
    int x;
    for (int i = 1; i <= sza; i++) {
      rd(x);
      a[++tot] = qwq(id[x], dfn[id[x]]);
      vis[id[x]] = 1;
      ty1[id[x]] = 1;
    }
    for (int i = 1; i <= szb; i++) {
      rd(x);
      if (!vis[id[x]]) a[++tot] = qwq(id[x], dfn[id[x]]);
      vis[id[x]] = 1;
      ty2[id[x]] = 1;
    }
    sort(a + 1, a + tot + 1);
    printf("%I64d\n", solve());
    if (q) {
      for (int i = 1; i <= tot; i++)
        x = a[i].pos, vec[x].clear(), vis[x] = 0, ty1[x] = ty2[x] = 0;
      tot = 0;
    }
  }
  return 0;
}