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;
using ll = long long;
const int MAXN = 200010;
int N, Q;
char S[MAXN];
int sa[MAXN], val[MAXN];
int buf[MAXN], newval[MAXN], ptr[MAXN];
const int L = 21;
const int MAXV = 2 * MAXN;
vector<int> evts[MAXN];
int par[MAXV];
vector<int> adj[MAXV];
int anc[MAXV][L];
int len[MAXV];
int V, root;
int getpar(int a) { return par[a] == -1 ? a : (par[a] = getpar(par[a])); }
void build_lcp() {
  iota(sa, sa + N, 0);
  sort(sa, sa + N, [&](int a, int b) { return S[a] < S[b]; });
  val[sa[0]] = 0;
  for (int i = 0; i + 1 < N; i++) {
    val[sa[i + 1]] = val[sa[i]] + (S[sa[i]] != S[sa[i + 1]]);
  }
  for (int l = 1; true; l *= 2) {
    if (val[sa[N - 1]] == N - 1) {
      break;
    }
    int sz = 0;
    for (int i = N - l; i < N; i++) {
      buf[sz++] = i;
    }
    for (int i = 0; i < N; i++) {
      if (sa[i] >= l) {
        buf[sz++] = sa[i] - l;
      }
    }
    for (int i = N - 1; i >= 0; i--) {
      ptr[val[sa[i]]] = i;
    }
    assert(sz == N);
    for (int i = 0; i < N; i++) {
      sa[ptr[val[buf[i]]]++] = buf[i];
    }
    newval[sa[0]] = 0;
    for (int i = 0; i + 1 < N; i++) {
      if (val[sa[i]] != val[sa[i + 1]]) {
        newval[sa[i + 1]] = newval[sa[i]] + 1;
      } else {
        int cur = (sa[i] + l < N ? val[sa[i] + l] : -1);
        int nxt = (sa[i + 1] + l < N ? val[sa[i + 1] + l] : -1);
        newval[sa[i + 1]] = newval[sa[i]] + (cur != nxt);
      }
    }
    copy_n(newval, N, val);
  }
  for (int i = 0, l = 0; i < N; i++) {
    if (val[i] == N - 1) {
      l = 0;
    } else {
      l = max(l - 1, 0);
      int j = sa[val[i] + 1];
      while (i + l < N && j + l < N && S[i + l] == S[j + l]) {
        l++;
      }
      evts[l].push_back(val[i]);
    }
  }
  for (int i = 0; i < N; i++) {
    len[i] = N - i;
  }
  V = N;
  fill_n(par, 2 * N, -1);
  for (int l = N - 1; l >= 0; l--) {
    for (int e : evts[l]) {
      int i = getpar(sa[e]);
      int j = getpar(sa[e + 1]);
      assert(i != j);
      len[V] = l;
      anc[V][0] = -1;
      anc[i][0] = anc[j][0] = V;
      par[i] = par[j] = V;
      adj[V].push_back(i);
      adj[V].push_back(j);
      V++;
    }
  }
  root = V;
  anc[V - 1][0] = V;
  anc[V][0] = -1;
  adj[V].push_back(V - 1);
  V++;
  assert(V == 2 * N);
}
int ind;
int st[MAXV];
int depth[MAXV];
void dfs(int cur = root) {
  for (int i = 1; i < L; i++) {
    anc[cur][i] = (anc[cur][i - 1] == -1 ? -1 : anc[anc[cur][i - 1]][i - 1]);
  }
  st[cur] = ind++;
  for (int nxt : adj[cur]) {
    depth[nxt] = depth[cur] + 1;
    dfs(nxt);
  }
}
int lca(int a, int b) {
  if (depth[a] < depth[b]) {
    swap(a, b);
  }
  int d = depth[a] - depth[b];
  for (int i = 0; (1 << i) <= d; i++) {
    if (d & (1 << i)) {
      a = anc[a][i];
    }
  }
  assert(depth[a] == depth[b]);
  if (a == b) return a;
  int i = 0;
  while (anc[a][i] != -1) i++;
  while (i) {
    i--;
    if (anc[a][i] != anc[b][i]) {
      a = anc[a][i];
      b = anc[b][i];
    }
  }
  assert(anc[a][0] == anc[b][0] && anc[a][0] != -1);
  return anc[a][0];
}
vector<int> stk;
vector<int> vadj[MAXV];
int cnt[MAXV][2];
void reset() { stk = {root}; }
void insert(int v) {
  if (stk.size() <= 1) {
    stk.push_back(v);
    return;
  }
  int a = lca(stk.back(), v);
  if (a != stk.back()) {
    while (stk.size() > 1 && st[stk.end()[-2]] >= st[a]) {
      vadj[stk.end()[-2]].push_back(stk.back());
      stk.pop_back();
    }
    if (a != stk.back()) {
      vadj[a].push_back(stk.back());
      stk.back() = a;
    }
  }
  stk.push_back(v);
}
ll ans;
void go(int cur = root) {
  for (int nxt : vadj[cur]) {
    go(nxt);
    for (int i = 0; i < 2; i++) {
      cnt[cur][i] += cnt[nxt][i];
    }
  }
  if (vadj[cur].empty()) {
    ans += ll(len[cur]) * cnt[cur][0] * cnt[cur][1];
  } else if (vadj[cur].size() == 2) {
    for (int i = 0; i < 2; i++) {
      int a = vadj[cur][i];
      int b = vadj[cur][1 - i];
      ans += ll(cnt[a][0]) * cnt[b][1] * len[cur];
    }
  }
  for (int nxt : vadj[cur]) {
    for (int i = 0; i < 2; i++) {
      cnt[nxt][i] = 0;
    }
  }
  vadj[cur].clear();
}
int main() {
  scanf("%d %d %s", &N, &Q, S);
  build_lcp();
  dfs();
  for (int v = 0; v < V; v++) assert(anc[v][L - 1] == -1);
  for (int q = 0; q < Q; q++) {
    int n[2];
    scanf("%d %d", &n[0], &n[1]);
    vector<int> verts;
    for (int w = 0; w < 2; w++) {
      for (int i = 0; i < n[w]; i++) {
        int p;
        scanf("%d", &p);
        p--;
        verts.push_back(p);
        cnt[p][w]++;
      }
    }
    sort(verts.begin(), verts.end(),
         [&](int a, int b) { return st[a] < st[b]; });
    verts.erase(unique(verts.begin(), verts.end()), verts.end());
    reset();
    for (int v : verts) {
      insert(v);
    }
    while (stk.size() > 1) {
      vadj[stk.end()[-2]].push_back(stk.back());
      stk.pop_back();
    }
    ans = 0;
    go();
    for (int i = 0; i < 2; i++) {
      cnt[root][i] = 0;
    }
    printf("%lld\n", ans);
  }
  return 0;
}