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 comment(linker, '/STACK:200000')
using namespace std;
struct SuffixArray {
  vector<int> lcp;
  vector<vector<pair<int, int> > > rmq;
  int n, h;
  vector<int> sa, invsa;
  bool cmp(int a, int b) { return invsa[a + h] < invsa[b + h]; }
  void ternary_sort(int a, int b) {
    if (a == b) return;
    int pivot = sa[a + rand() % (b - a)];
    int left = a, right = b;
    for (int i = a; i < b; ++i)
      if (cmp(sa[i], pivot)) swap(sa[i], sa[left++]);
    for (int i = b - 1; i >= left; --i)
      if (cmp(pivot, sa[i])) swap(sa[i], sa[--right]);
    ternary_sort(a, left);
    for (int i = left; i < right; ++i) invsa[sa[i]] = right - 1;
    if (right - left == 1) sa[left] = -1;
    ternary_sort(right, b);
  }
  SuffixArray() {}
  SuffixArray(vector<int> v) : n(v.size()), sa(n) {
    v.push_back(INT_MIN);
    invsa = v;
    iota(sa.begin(), sa.end(), 0);
    h = 0;
    ternary_sort(0, n);
    for (h = 1; h <= n; h *= 2) {
      for (int j = 0, i = j; i != n; i = j) {
        if (sa[i] < 0) {
          while (j < n && sa[j] < 0) j += -sa[j];
          sa[i] = -(j - i);
        } else {
          j = invsa[sa[i]] + 1;
          ternary_sort(i, j);
        }
      }
    }
    for (int i = 0; i < n; ++i) sa[invsa[i]] = i;
    lcp.resize(n);
    int res = 0;
    for (int i = 0; i < n; ++i) {
      if (invsa[i] > 0)
        while (v[i + res] == v[sa[invsa[i] - 1] + res]) ++res;
      lcp[invsa[i]] = res;
      res = max(res - 1, 0);
    }
    int logn = 0;
    while ((1 << logn + 1) <= n) ++logn;
    rmq.resize(logn + 1, vector<pair<int, int> >(n));
    for (int i = 0; i < n; ++i) rmq[0][i] = make_pair(lcp[i], i);
    for (int l = 1; l <= logn; ++l)
      for (int i = 0; i + (1 << l) <= n; ++i)
        rmq[l][i] = min(rmq[l - 1][i], rmq[l - 1][i + (1 << l - 1)]);
  }
  pair<int, int> rmq_query(int a, int b) {
    int size = b - a + 1, l = 31 - __builtin_clz(size);
    return min(rmq[l][a], rmq[l][b - (1 << l) + 1]);
  }
  int get_lcp(int a, int b) {
    if (a == b) return n - a;
    int ia = invsa[a];
    int ib = invsa[b];
    return rmq_query(min(ia, ib) + 1, max(ia, ib)).first;
  }
  int get_lcp2(int ia, int ib) {
    return rmq_query(min(ia, ib) + 1, max(ia, ib)).first;
  }
  pair<int, int> get_range(int strpos, int size) {
    int pos = invsa[strpos];
    int start, end;
    {
      int l = 0, r = pos;
      while (l < r) {
        int m = (l + r) / 2;
        if (get_lcp2(m, pos) < size)
          l = m + 1;
        else
          r = m;
      }
      start = l;
    }
    {
      int l = pos, r = n - 1;
      while (l < r) {
        int m = (l + r + 1) / 2;
        if (get_lcp2(m, pos) < size)
          r = m - 1;
        else
          l = m;
      }
      end = l;
    }
    return {start, end};
  }
};
const int N = (int)2e5 + 1;
SuffixArray *sa;
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  if (sa->invsa[a.first] != sa->invsa[b.first])
    return sa->invsa[a.first] < sa->invsa[b.first];
  return a.second < b.second;
}
int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  vector<int> s;
  for (int i = 0; i < n; ++i) {
    char c;
    scanf(" %c", &c);
    s.emplace_back(c - 'a');
  }
  sa = new SuffixArray(s);
  while (q--) {
    int k, l;
    scanf("%d %d", &k, &l);
    vector<pair<long long, long long> > all;
    for (int i = 0; i < k; ++i) {
      int x;
      scanf("%d", &x);
      x--;
      all.emplace_back(pair<long long, long long>(x, 0));
    }
    for (int i = 0; i < l; ++i) {
      int x;
      scanf("%d", &x);
      x--;
      all.emplace_back(pair<long long, long long>(x, 1));
    }
    long long ans = 0;
    sort(all.begin(), all.end(), cmp);
    for (int z = 0; z < 2; ++z) {
      map<long long, long long> cnt;
      long long sum = 0;
      for (int i = 0; i < all.size(); ++i) {
        int x = all[i].first, t = all[i].second;
        if (t == 0)
          ans += sum;
        else {
          cnt[n - x]++;
          sum += (n - x);
        }
        if (i + 1 < all.size()) {
          int tam = sa->get_lcp(all[i].first, all[i + 1].first);
          while (!cnt.empty()) {
            auto it = --cnt.end();
            if (it->first <= tam) break;
            sum -= it->first * 1ll * it->second;
            cnt[tam] += it->second;
            sum += it->second * 1ll * tam;
            cnt.erase(it);
          }
        }
      }
      reverse(all.begin(), all.end());
    }
    printf("%lld\n", ans);
  }
  return 0;
}