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;
inline int gi() {
  char c = getchar();
  int x = 0;
  for (; c < '0' || c > '9'; c = getchar())
    ;
  for (; c >= '0' && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + c - '0';
  return x;
}
const int N = 400005;
int cnt = 1, lst = 1, pre[N], len[N], size[N], ch[N][30], id[N];
char s[N];
void extend(int x, int c) {
  int p = lst, np = ++cnt;
  lst = np;
  len[np] = len[p] + 1, size[np] = 1, id[x] = np;
  for (; p && !ch[p][c]; p = pre[p]) ch[p][c] = np;
  if (!p) {
    pre[np] = 1;
    return;
  }
  int q = ch[p][c];
  if (len[p] + 1 == len[q]) {
    pre[np] = q;
    return;
  }
  int nq = ++cnt;
  len[nq] = len[p] + 1;
  memcpy(ch[nq], ch[q], sizeof(ch[q]));
  pre[nq] = pre[q], pre[q] = pre[np] = nq;
  for (; ch[p][c] == q; p = pre[p]) ch[p][c] = nq;
}
int head[N], nxt[N], to[N], dep[N], fa[N], son[N], top[N], n, m, st[N], ed[N],
    tim;
int head2[N], nxt2[N], to2[N], tot, a[N], vis[N], stk[N];
int sa[N], sb[N];
long long ans;
void addedge(int u, int v, int now) {
  nxt[now] = head[u], head[u] = now, to[now] = v;
}
void addedge2(int u, int v) {
  nxt2[++tot] = head2[u], head2[u] = tot, to2[tot] = v;
}
bool cmp(int x, int y) { return st[x] < st[y]; }
void dfs(int u) {
  size[u] = 1, dep[u] = dep[fa[u]] + 1;
  for (int e = head[u]; e; e = nxt[e]) {
    if (to[e] == fa[u]) continue;
    fa[to[e]] = u;
    dfs(to[e]);
    size[u] += size[to[e]];
    if (size[to[e]] > size[son[u]]) son[u] = to[e];
  }
}
void dfs2(int u, int tp) {
  st[u] = ++tim;
  top[u] = tp;
  if (son[u]) dfs2(son[u], tp);
  for (int e = head[u]; e; e = nxt[e])
    if (to[e] != fa[u] && to[e] != son[u]) dfs2(to[e], to[e]);
  ed[u] = ++tim;
}
inline int lca(int u, int v) {
  while (top[u] ^ top[v])
    dep[top[u]] > dep[top[v]] ? u = fa[top[u]] : v = fa[top[v]];
  return dep[u] < dep[v] ? u : v;
}
void idfs(int u) {
  ;
  ans += 1ll * len[u] * sa[u] * sb[u];
  for (int e = head2[u]; e; e = nxt2[e]) {
    idfs(to2[e]);
    ans += 1ll * len[u] * sa[u] * sb[to2[e]];
    ans += 1ll * len[u] * sb[u] * sa[to2[e]];
    sa[u] += sa[to2[e]];
    sb[u] += sb[to2[e]];
  }
}
int main() {
  n = gi(), m = gi();
  scanf("%s", s + 1);
  for (int i = n; i; --i) extend(i, s[i] - 'a');
  for (int i = 2; i <= cnt; ++i) addedge(pre[i], i, i - 1);
  dfs(1), dfs2(1, 1);
  while (m--) {
    int xa = gi(), xb = gi(), k = 0;
    for (int i = 1; i <= xa; ++i) {
      int x = id[gi()];
      ++sa[x];
      if (vis[x] != m + 1) vis[x] = m + 1, a[++k] = x;
    }
    for (int i = 1; i <= xb; ++i) {
      int x = id[gi()];
      ++sb[x];
      if (vis[x] != m + 1) vis[x] = m + 1, a[++k] = x;
    }
    sort(a + 1, a + 1 + k, cmp);
    for (int i = 1; i < k; ++i) {
      int l = lca(a[i], a[i + 1]);
      if (vis[l] != m + 1) vis[l] = m + 1, a[++k] = l;
    }
    if (vis[1] != m + 1) a[++k] = 1;
    sort(a + 1, a + 1 + k, cmp);
    int tp = 0;
    tot = 0;
    for (int i = 1; i <= k; ++i) {
      while (tp && ed[stk[tp]] < st[a[i]]) --tp;
      if (stk[tp]) addedge2(stk[tp], a[i]);
      stk[++tp] = a[i];
    }
    ans = 0, idfs(1), printf("%lld\n", ans);
    for (int i = 1; i <= k; ++i) sa[a[i]] = sb[a[i]] = head2[a[i]] = 0;
  }
}