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>
#pragma GCC optimize(3)
using namespace std;
const int inf = 0x3f3f3f3f;
const int inf_ll = 0x3f3f3f3f3f3f3f3fLL;
const int maxn = 4e5 + 100;
char s[maxn];
int n;
int ans[maxn];
int first[maxn], des[maxn * 2], nxt[maxn * 2], tot;
int a[maxn];
inline void addEdge(int x, int y) {
  tot++;
  des[tot] = y;
  nxt[tot] = first[x];
  first[x] = tot;
}
struct Suffix_Automaton {
  int nxt[maxn * 2][26], fa[maxn * 2], l[maxn * 2];
  int last, cnt;
  int cntA[maxn * 2], A[maxn * 2];
  int num[maxn * 2];
  int end_pos[maxn * 2];
  void clear() {
    last = cnt = 1;
    fa[1] = l[1] = 0;
    memset(nxt[1], 0, sizeof nxt[1]);
  }
  void init(char *s) {
    while (*s) {
      add(*s - 'a');
      s++;
    }
  }
  void add(int c) {
    int p = last;
    int np = ++cnt;
    memset(nxt[cnt], 0, sizeof nxt[cnt]);
    l[np] = l[p] + 1;
    last = np;
    while (p && !nxt[p][c]) nxt[p][c] = np, p = fa[p];
    if (!p)
      fa[np] = 1;
    else {
      int q = nxt[p][c];
      if (l[q] == l[p] + 1)
        fa[np] = q;
      else {
        int nq = ++cnt;
        l[nq] = l[p] + 1;
        memcpy(nxt[nq], nxt[q], sizeof(nxt[q]));
        fa[nq] = fa[q];
        fa[np] = fa[q] = nq;
        while (nxt[p][c] == q) nxt[p][c] = nq, p = fa[p];
      }
    }
  }
  void build() {
    memset(cntA, 0, sizeof cntA);
    memset(num, 0, sizeof num);
    for (int i = 1; i <= cnt; i++) cntA[l[i]]++;
    for (int i = 1; i <= n; i++) cntA[i] += cntA[i - 1];
    for (int i = cnt; i >= 1; i--) A[cntA[l[i]]--] = i;
    int temp = 1;
    for (int i = 0; i < n; i++) {
      num[temp = nxt[temp][s[i] - 'a']] = 1;
    }
    for (int i = cnt; i >= 1; i--) {
      int x = A[i];
      num[fa[x]] += num[x];
      ans[l[x]] = max(ans[l[x]], num[x]);
    }
    for (int i = l[last]; i > 1; i--) {
      ans[i - 1] = max(ans[i - 1], ans[i]);
    }
  }
  void extract(char *s) {
    a[1] = 0;
    for (int i = 2; i <= cnt; i++) {
      a[i] = l[i];
      addEdge(i, fa[i]);
      addEdge(fa[i], i);
      (void(0));
    }
    int now = 1;
    for (int i = 0; i < n; i++) {
      now = nxt[now][s[i] - 'a'];
      end_pos[n - i] = now;
    }
  }
  void debug() {
    for (int i = cnt; i >= 1; i--) {
      printf("num[%d]=%d l[%d]=%d fa[%d]=%d\n", i, num[i], i, l[i], i, fa[i]);
    }
  }
} sam;
int dep[maxn], fa[maxn];
int sz[maxn], wson[maxn];
int top[maxn], tpos[maxn], cnt;
int l[maxn], r[maxn], dfs_clock;
namespace Tree_Chain_Division {
void dfs(int node, int father) {
  l[node] = ++dfs_clock;
  dep[node] = dep[father] + 1;
  fa[node] = father;
  sz[node] = 1;
  for (int t = first[node]; t; t = nxt[t]) {
    int v = des[t];
    if (v == father) {
      continue;
    }
    dfs(v, node);
    if (sz[v] > sz[wson[node]]) {
      wson[node] = v;
    }
    sz[node] += sz[v];
  }
  r[node] = dfs_clock;
}
void dfs2(int node, int father, int chain) {
  top[node] = chain;
  tpos[node] = ++cnt;
  if (wson[node]) {
    dfs2(wson[node], node, chain);
  }
  for (int t = first[node]; t; t = nxt[t]) {
    int v = des[t];
    if (v == father || v == wson[node]) {
      continue;
    }
    dfs2(v, node, v);
  }
}
void init(int root) {
  dfs(root, 0);
  dfs2(root, 0, root);
}
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]];
  }
  if (dep[x] < dep[y]) swap(x, y);
  return y;
}
}  // namespace Tree_Chain_Division
int color[maxn];
namespace Virtual_Tree {
int vis[maxn];
int dp[maxn][2];
int top;
int stk[maxn * 2];
int fa[maxn * 2];
long long solve(vector<int> node) {
  long long ans = 0;
  for (int i = 0; i < node.size(); i++) {
    vis[node[i]] = 1;
    dp[node[i]][0] = dp[node[i]][1] = 0;
  }
  auto cmp = [](int x, int y) { return l[x] < l[y]; };
  sort(node.begin(), node.end(), cmp);
  stringstream stm;
  for (auto x : node) {
    stm << x << " ";
  }
  (void(0));
  int sz = node.size();
  for (int i = 1; i < sz; i++) {
    int temp = Tree_Chain_Division::lca(node[i], node[i - 1]);
    (void(0));
    if (!vis[temp])
      vis[temp] = 2, node.push_back(temp), dp[temp][0] = dp[temp][1] = 0;
  }
  if (!vis[1]) vis[1] = 2, node.push_back(1), dp[1][0] = dp[1][1] = 0;
  sort(node.begin(), node.end(), cmp);
  top = 1;
  stk[0] = node[0];
  for (int i = 1; i < node.size(); i++) {
    while (l[node[i]] > r[stk[top - 1]]) top--;
    fa[node[i]] = stk[top - 1];
    stk[top++] = node[i];
  }
  for (int i = (int)node.size() - 1; i >= 0; i--) {
    (void(0));
    int u = node[i];
    if (u == 1) continue;
    assert(color[u] >= 0 && color[u] <= 3);
    if (color[u] >= 2) {
      ans += 1ll * dp[u][0] * a[u];
      dp[u][1]++;
      color[u] -= 2;
    }
    if (color[u] >= 1) {
      ans += 1ll * dp[u][1] * a[u];
      dp[u][0]++;
      color[u] -= 1;
    }
    ans += 1ll * dp[fa[u]][0] * dp[u][1] * a[fa[u]];
    ans += 1ll * dp[fa[u]][1] * dp[u][0] * a[fa[u]];
    dp[fa[u]][0] += dp[u][0];
    dp[fa[u]][1] += dp[u][1];
  }
  for (int i = 0; i < node.size(); i++) {
    int u = node[i];
    dp[u][0] = dp[u][1] = 0;
    color[u] = 0;
    vis[u] = 0;
    fa[u] = 0;
  }
  return ans;
}
}  // namespace Virtual_Tree
vector<int> node;
int N, M;
void solve() {
  node.clear();
  scanf("%d%d", &N, &M);
  for (int i = 0; i < N; i++) {
    int temp;
    scanf("%d", &temp);
    temp = sam.end_pos[temp];
    color[temp] += 1;
    node.push_back(temp);
    ;
  }
  for (int i = 0; i < M; i++) {
    int temp;
    scanf("%d", &temp);
    temp = sam.end_pos[temp];
    color[temp] += 2;
    node.push_back(temp);
    ;
  }
  sort(node.begin(), node.end());
  node.erase(unique(node.begin(), node.end()), node.end());
  stringstream stm;
  for (auto x : node) {
    stm << "color[" << x << "]= " << color[x] << " ";
  }
  (void(0));
  printf("%lld\n", Virtual_Tree::solve(node));
}
int main() {
  int m;
  scanf("%d%d", &n, &m);
  scanf("%s", s);
  reverse(s, s + n);
  sam.clear();
  sam.init(s);
  sam.extract(s);
  Tree_Chain_Division::init(1);
  while (m--) {
    solve();
  }
  return 0;
}