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;
const int N = 400005, M = 26;
struct edge {
  int v, nt;
};
int q[N], ind = 0, n, m, k, pos[N], x, l, tot = 0, a[N], b[N];
char s[N];
long long ans = 0;
struct graph {
  edge e[N];
  int h[N], cnt;
  int fa[N], id[N], sz[N], top[N], son[N], dep[N], tot;
  void init() {
    cnt = 0;
    tot = 0;
  }
  inline void add(int u, int v) {
    e[++cnt] = (edge){v, h[u]};
    h[u] = cnt;
  }
  inline void dfs1(int u) {
    id[u] = ++tot;
    for (int i = h[u]; i; i = e[i].nt) {
      int v = e[i].v;
      if (v == fa[u]) continue;
      sz[v] = 1;
      fa[v] = u;
      dep[v] = dep[u] + 1;
      dfs1(v);
      sz[u] += sz[v];
      if (sz[son[u]] < sz[v]) son[u] = v;
    }
  }
  inline void dfs2(int u, int ntop) {
    top[u] = ntop;
    if (son[u]) dfs2(son[u], ntop);
    for (int i = h[u]; i; i = e[i].nt) {
      int v = e[i].v;
      if (v == fa[u] || v == son[u]) continue;
      dfs2(v, v);
    }
  }
  inline void mkrt(int u) {
    dep[u] = 1;
    fa[u] = 0;
    sz[u] = 1;
    dfs1(u);
    dfs2(u, u);
  }
  int lca(int x, int y) {
    while (top[x] != top[y]) {
      if (dep[top[x]] < dep[top[y]]) swap(x, y);
      x = fa[top[x]];
    }
    return dep[x] < dep[y] ? x : y;
  }
} t;
struct sam {
  int ch[N][M], fa[N], len[N], lst, gt;
  void init() { lst = gt = 1; }
  void ins(int c) {
    int f = lst, p = ++gt;
    lst = p;
    len[p] = len[f] + 1;
    while (f && !ch[f][c]) ch[f][c] = p, f = fa[f];
    if (!f) {
      fa[p] = 1;
      return;
    }
    int x = ch[f][c], y = ++gt;
    if (len[x] == len[f] + 1) {
      fa[p] = x;
      gt--;
      return;
    }
    len[y] = len[f] + 1;
    fa[y] = fa[x];
    fa[x] = fa[p] = y;
    for (int i = 0; i < M; i++) ch[y][i] = ch[x][i];
    while (f && ch[f][c] == x) ch[f][c] = y, f = fa[f];
  }
} g;
bool cmp(const int &a, const int &b) { return t.id[a] < t.id[b]; }
int ov1[N], ov2[N], d1[N], d2[N], sta[N], p;
vector<int> e1[N];
void ins(int x) {
  if (p == 1) {
    sta[++p] = x;
    return;
  }
  int lc = t.lca(sta[p], x);
  if (lc == sta[p]) {
    sta[++p] = x;
    return;
  }
  while (p > 1 && t.id[sta[p - 1]] >= t.id[lc])
    e1[sta[p - 1]].push_back(sta[p]), p--;
  if (lc != sta[p]) e1[lc].push_back(sta[p]), sta[p] = lc;
  sta[++p] = x;
}
void ins2(int x) {
  if (!p) {
    sta[++p] = x;
    return;
  }
  int lc = t.lca(x, sta[p]);
  while (t.id[lc] < t.id[sta[p]]) {
    if (t.id[lc] >= t.id[sta[p - 1]]) {
      e1[lc].push_back(sta[p--]);
      if (lc != sta[p]) sta[++p] = lc;
      break;
    } else
      e1[sta[p - 1]].push_back(sta[p]), p--;
  }
  sta[++p] = x;
}
void dfs3(int u) {
  d1[u] = ov1[u];
  d2[u] = ov2[u];
  ans += 1ll * d1[u] * d2[u] * g.len[u];
  for (int i = 0; i < (int)e1[u].size(); i++) {
    int v = e1[u][i];
    dfs3(v);
    ans += 1ll * (1ll * d1[u] * d2[v] + 1ll * d2[u] * d1[v]) * g.len[u];
    d1[u] += d1[v];
    d2[u] += d2[v];
  }
  e1[u].clear();
  ov1[u] = ov2[u] = 0;
}
void bdt() {
  p = 0;
  sort(q + 1, q + 1 + ind, cmp);
  for (int i = 1; i <= k; i++) ov1[pos[a[i]]] = 1;
  for (int i = 1; i <= l; i++) ov2[pos[b[i]]] = 1;
  for (int i = 1; i <= ind; i++) ins2(q[i]);
  while (p > 1) e1[sta[p - 1]].push_back(sta[p]), p--;
  dfs3(sta[1]);
  for (int i = 1; i <= ind; i++) d1[q[i]] = d2[q[i]] = 0;
}
int main() {
  g.init();
  t.init();
  scanf("%d%d%s", &n, &m, s + 1);
  reverse(s + 1, s + 1 + n);
  for (int i = 1; i <= n; i++) g.ins(s[i] - 'a'), pos[i] = g.lst;
  for (int i = 2; i <= g.gt; i++) t.add(g.fa[i], i);
  t.mkrt(1);
  while (m--) {
    scanf("%d%d", &k, &l);
    tot = 0;
    ans = 0;
    for (int i = 1; i <= k; i++)
      scanf("%d", &a[i]), a[i] = n - a[i] + 1, q[++tot] = pos[a[i]];
    for (int i = 1; i <= l; i++)
      scanf("%d", &b[i]), b[i] = n - b[i] + 1, q[++tot] = pos[b[i]];
    sort(q + 1, q + 1 + tot);
    ind = unique(q + 1, q + 1 + tot) - q - 1;
    bdt();
    printf("%lld\n", ans);
  }
  return 0;
}