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 = 412000;
namespace tree_split1 {
struct graph {
  long long Begin[N * 2], to[N * 2], Next[N * 2], e, weight[N * 2];
  void add(int u, int v) {
    to[++e] = v;
    Next[e] = Begin[u];
    Begin[u] = e;
  }
  void add(int u, int v, int w) {
    to[++e] = v;
    Next[e] = Begin[u];
    Begin[u] = e;
    weight[e] = w;
  }
  void init_graph() {
    e = 0;
    memset(Begin, -1, sizeof(Begin));
  }
};
class tree_array1 {
 public:
  int n;
  long long sum1[N], sum2[N];
  long long a[N];
  tree_array1(int n1) { n = n1; }
  void init() {
    for (int i = 1; i <= n; ++i) a[i] += a[i - 1];
    memset(sum1, 0, sizeof(sum1));
    memset(sum2, 0, sizeof(sum2));
  }
  void add(int p, long long x) {
    for (int i = p; i <= n; i += i & -i) {
      sum1[i] += x;
      sum2[i] += x * p;
    }
  }
  void range_add(int l, int r, long long x) {
    add(l, x);
    add(r + 1, -x);
  }
  long long ask(int p) {
    long long res = 0;
    for (int i = p; i != 0; i -= i & -i) res += (p + 1) * sum1[i] - sum2[i];
    return res;
  }
  long long range_ask(int l, int r) {
    return ask(r) - ask(l - 1) + a[r] - a[l - 1];
  }
};
int id[N];
class tree_split {
 public:
  long long dep[N], fa[N], top[N], size1[N], son[N], weight[N], new_weight[N];
  int len;
  graph g;
  void query(tree_array1 &p, int x, int y, int k) {
    while (top[x] != top[y]) {
      if (dep[top[x]] < dep[top[y]]) swap(x, y);
      p.range_add(id[top[x]], id[x], k);
      x = fa[top[x]];
    }
    if (dep[x] > dep[y]) swap(x, y);
    p.range_add(id[x], id[y], k);
  }
  long long query2(tree_array1 &p, int x, int y) {
    long long ans = 0;
    while (top[x] != top[y]) {
      if (dep[top[x]] < dep[top[y]]) swap(x, y);
      ans += p.range_ask(id[top[x]], id[x]);
      x = fa[top[x]];
    }
    if (dep[x] > dep[y]) swap(x, y);
    ans += p.range_ask(id[x], id[y]);
    return ans;
  }
  tree_split() {
    memset(fa, 0, sizeof(fa));
    memset(top, 0, sizeof(top));
    memset(size1, 0, sizeof(size1));
    memset(son, 0, sizeof(son));
    memset(g.Begin, -1, sizeof(g.Begin));
    memset(weight, 0, sizeof(weight));
    len = 0;
  }
  void clear() {
    memset(fa, 0, sizeof(fa));
    memset(top, 0, sizeof(top));
    memset(size1, 0, sizeof(size1));
    memset(son, 0, sizeof(son));
    memset(g.Begin, -1, sizeof(g.Begin));
    memset(weight, 0, sizeof(weight));
    len = 0;
  }
  void init(int root) {
    dep[root] = 0;
    dfs1(root, root);
    dfs2(root, root);
  }
  void add_weight(int i, int w) { weight[i] = w; }
  void add_edge(int u, int v) { g.add(u, v); }
  void dfs0(int u) {
    int maxx = 0, son = 0;
    top[u] = u;
    size1[u] = 1;
    for (int i = g.Begin[u]; i != -1; i = g.Next[i]) {
      if (g.to[i] == fa[u]) continue;
      fa[g.to[i]] = u;
      dep[g.to[i]] = dep[u] + 1;
      dfs0(g.to[i]);
      size1[u] += size1[g.to[i]];
      if (size1[g.to[i]] > maxx) {
        son = g.to[i];
        maxx = size1[son];
      }
    }
    if (son != 0) top[son] = u;
  }
  void dfs1(int u, int father) {
    dep[u] = dep[father] + 1;
    fa[u] = father;
    size1[u] = 1;
    for (int i = g.Begin[u]; i != -1; i = g.Next[i]) {
      if (g.to[i] != father) {
        dfs1(g.to[i], u);
        size1[u] += size1[g.to[i]];
        if (size1[g.to[i]] > size1[son[u]]) son[u] = g.to[i];
      }
    }
  }
  void dfs2(int u, int topf) {
    id[u] = ++len;
    new_weight[len] = weight[u];
    top[u] = topf;
    if (son[u] == 0) return;
    dfs2(son[u], topf);
    for (int i = g.Begin[u]; i != -1; i = g.Next[i]) {
      if (g.to[i] == fa[u] || g.to[i] == son[u]) continue;
      dfs2(g.to[i], g.to[i]);
    }
  }
  int find(int u) { return top[u] = top[u] == u ? u : find(top[u]); }
  int LCA(int u, int v) {
    if (find(u) != find(v))
      return dep[top[u]] > dep[top[v]] ? LCA(fa[top[u]], v)
                                       : LCA(u, fa[top[v]]);
    else
      return dep[u] > dep[v] ? v : u;
  }
};
struct virtual_tree {
  graph g;
  tree_split ts;
  int root, top;
  int st[N];
  list<int> Del;
  virtual_tree() { memset(g.Begin, -1, sizeof(g.Begin)); }
  static bool cmp(const int &a, const int &b) {
    if (id[a] < id[b])
      return true;
    else
      return false;
  }
  void init(int root1) {
    ts.init(root1);
    root = root1;
  }
  void clear_virtual() {
    g.e = 0;
    for (auto &s : Del) g.Begin[s] = -1;
    Del.clear();
  }
  void clear_all() {
    g.init_graph();
    ts.clear();
  }
  void add_edge(int u, int v) {
    g.add(u, v);
    g.add(v, u);
    Del.push_back(u);
    Del.push_back(v);
  }
  void insert(int x) {
    if (top == 1) {
      st[++top] = x;
      return;
    }
    int lca = ts.LCA(x, st[top]);
    if (lca == st[top]) {
      st[++top] = x;
      return;
    }
    while (top > 1 && id[st[top - 1]] >= id[lca])
      add_edge(st[top - 1], st[top]), top--;
    if (lca != st[top]) add_edge(lca, st[top]), st[top] = lca;
    st[++top] = x;
  }
  void build(int *p, int sum) {
    sort(p, p + sum, cmp);
    top = 1;
    st[top] = root;
    for (int i = 0; i < sum; ++i) insert(p[i]);
    while (top > 1) {
      add_edge(st[top - 1], st[top]);
      top--;
    }
  }
  map<int, long long> dp, dp2, pre;
  set<int> sum;
  void dfs(int cur) {
    sum.insert(cur);
    for (int i = g.Begin[cur]; i != -1; i = g.Next[i]) {
      int k = g.to[i];
      if (id[k] > id[cur]) {
        pre[k] = cur;
        dfs(k);
        dp[cur] += dp[k];
        dp2[cur] += dp2[k];
      }
    }
  }
} v_t;
}  // namespace tree_split1
using namespace tree_split1;
namespace Suffix_Tree {
const int maxn = 410010;
const int maxc = 29;
struct ST {
  const static int inf = 1e9;
  int t[maxn][maxc], len[maxn], start[maxn], link[maxn], s[maxn], tot, n, rem,
      now, pool[maxn];
  int cnt;
  int ans[maxn], calc[maxn], pre[maxn];
  ST() : tot(1), n(0), rem(0), now(1) { len[0] = inf; }
  void init() {
    memset(t, 0, sizeof(t));
    memset(start, 0, sizeof(start));
    memset(len, 0, sizeof(len));
    tot = 1;
    n = 0;
    rem = 0;
    now = 1;
    len[0] = inf;
  }
  int node(int sta, int l) {
    start[++tot] = sta, len[tot] = l, link[tot] = 1;
    return tot;
  }
  void add(int x) {
    s[++n] = x, ++rem;
    for (int last = 1; rem;) {
      while (rem > len[t[now][s[n - rem + 1]]])
        rem -= len[now = t[now][s[n - rem + 1]]];
      int ed = s[n - rem + 1];
      int &v = t[now][ed];
      int c = s[start[v] + rem - 1];
      if (!v) {
        v = node(n - rem + 1, inf);
        link[last] = now;
        last = now;
      } else if (x == c) {
        link[last] = now;
        last = now;
        break;
      } else {
        int u = node(start[v], rem - 1);
        t[u][x] = node(n, inf);
        t[u][c] = v, start[v] += rem - 1, len[v] -= rem - 1;
        link[last] = v = u, last = v;
      }
      if (now == 1)
        --rem;
      else
        now = link[now];
    }
  }
  void dfs(int cur) {
    if (len[cur] > 2e8) {
      ans[cur] += n - start[cur];
      return;
    }
    ans[cur] += len[cur];
    for (int i = 1; i <= 26; ++i)
      if (t[cur][i]) {
        ans[t[cur][i]] += ans[cur];
        dfs(t[cur][i]);
        pre[t[cur][i]] = cur;
      }
  }
  void topo() {
    cnt = 0;
    memset(ans, 0, sizeof(ans));
    memset(calc, 0, sizeof(calc));
    queue<int> que;
    que.push(1);
    int cur;
    while (!que.empty()) {
      cur = que.front();
      que.pop();
      pool[cnt++] = cur;
      if (len[cur] > 2e8)
        ans[cur] += n - start[cur];
      else
        ans[cur] += len[cur];
      if (t[cur][27])
        calc[cur] = 1;
      else if (len[cur] > 2e8) {
        calc[cur] = 1;
        continue;
      }
      for (int i = 1; i < 27; ++i)
        if (t[cur][i]) {
          v_t.ts.add_edge(cur, t[cur][i]);
          v_t.ts.add_edge(t[cur][i], cur);
          que.push(t[cur][i]);
          ans[t[cur][i]] += ans[cur];
          pre[t[cur][i]] = cur;
        }
    }
  }
} st;
}  // namespace Suffix_Tree
using namespace Suffix_Tree;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string str;
  long long a, b, q, q2, len;
  cin >> len >> q;
  cin >> str;
  for (auto &s : str) st.add(s - 'a' + 1);
  st.add(27);
  st.topo();
  v_t.init(1);
  int trans[N];
  memset(trans, 0, sizeof(trans));
  for (int i = 1; i <= st.tot; ++i)
    if (st.t[i][27] || st.len[i] > 2e8) trans[len - st.ans[i] + 1] = i;
  int qa[N], qb[N], all[N];
  set<int> qc;
  while (q--) {
    qc.clear();
    cin >> a >> b;
    for (int i = 0; i < a; ++i) {
      cin >> qa[i];
      qc.insert(trans[qa[i]]);
    }
    for (int i = 0; i < b; ++i) {
      cin >> qb[i];
      qc.insert(trans[qb[i]]);
    }
    int p = 0;
    for (auto &L : qc) all[p++] = L;
    v_t.build(all, qc.size());
    for (int i = 0; i < a; ++i) v_t.dp[trans[qa[i]]] = 1;
    for (int i = 0; i < b; ++i) v_t.dp2[trans[qb[i]]] = 1;
    v_t.dfs(1);
    long long ans = 0;
    v_t.pre[1] = 1;
    for (auto &s : v_t.sum)
      ans += v_t.dp[s] * v_t.dp2[s] * (st.ans[s] - st.ans[v_t.pre[s]]);
    v_t.dp2.clear();
    v_t.pre.clear();
    v_t.sum.clear();
    cout << ans << endl;
    v_t.dp.clear();
    v_t.clear_virtual();
  }
  return 0;
}