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;
vector<int> qry[200005];
vector<int> xqr[200005];
long long ans[200005];
vector<int> sort_cyclic_shifts(string const& s) {
  int n = s.size();
  const int alphabet = 200005;
  vector<int> p(n), c(n), cnt(alphabet, 0);
  for (int i = 0; i < n; i++) cnt[s[i]]++;
  for (int i = 1; i < alphabet; i++) cnt[i] += cnt[i - 1];
  for (int i = 0; i < n; i++) p[--cnt[s[i]]] = i;
  c[p[0]] = 0;
  int classes = 1;
  for (int i = 1; i < n; i++) {
    if (s[p[i]] != s[p[i - 1]]) classes++;
    c[p[i]] = classes - 1;
  }
  vector<int> pn(n), cn(n);
  for (int h = 0; (1 << h) < n; ++h) {
    for (int i = 0; i < n; i++) {
      pn[i] = p[i] - (1 << h);
      if (pn[i] < 0) pn[i] += n;
    }
    fill(cnt.begin(), cnt.end(), 0);
    for (int i = 0; i < n; i++) cnt[c[pn[i]]]++;
    for (int i = 1; i < classes; i++) cnt[i] += cnt[i - 1];
    for (int i = n - 1; i >= 0; i--) p[--cnt[c[pn[i]]]] = pn[i];
    cn[p[0]] = 0;
    classes = 1;
    for (int i = 1; i < n; i++) {
      pair<int, int> cur = make_pair(c[p[i]], c[(p[i] + (1 << h)) % n]);
      pair<int, int> prev =
          make_pair(c[p[i - 1]], c[(p[i - 1] + (1 << h)) % n]);
      if (cur != prev) ++classes;
      cn[p[i]] = classes - 1;
    }
    c.swap(cn);
  }
  return p;
}
vector<int> suffix_array_construction(string s) {
  s += "$";
  vector<int> sorted_shifts = sort_cyclic_shifts(s);
  sorted_shifts.erase(sorted_shifts.begin());
  return sorted_shifts;
}
vector<int> lcp_construction(string const& s, vector<int> const& p) {
  int n = s.size();
  vector<int> rank(n, 0);
  for (int i = 0; i < n; i++) rank[p[i]] = i;
  int k = 0;
  vector<int> lcp(n - 1, 0);
  for (int i = 0; i < n; i++) {
    if (rank[i] == n - 1) {
      k = 0;
      continue;
    }
    int j = p[rank[i] + 1];
    while (i + k < n && j + k < n && s[i + k] == s[j + k]) k++;
    lcp[rank[i]] = k;
    if (k) k--;
  }
  return lcp;
}
int sp[200005][18];
void init(vector<int>& vec) {
  int i, k;
  int sz = vec.size();
  for (i = 0; i < sz; i++) sp[i][0] = vec[i];
  for (k = 1; k < 18; k++) {
    for (i = 0; i <= sz - (1 << k); i++)
      sp[i][k] = min(sp[i][k - 1], sp[i + (1 << (k - 1))][k - 1]);
  }
}
int query(int l, int r) {
  int k = log(r - l + 1) / log(2);
  return min(sp[l][k], sp[r - (1 << k) + 1][k]);
}
int preMin[200005], postMin[200005];
int spos[200005];
int n;
long long calc(long long mid, vector<int>& a, vector<int>& b) {
  int an = a.size(), bn = b.size();
  if (an == 0 || bn == 0) return 0;
  reverse(b.begin(), b.end());
  for (int i = 0; i < an; i++) preMin[i] = query(a[i], mid);
  for (int i = 0; i < bn; i++) postMin[i] = query(mid, b[i] - 1);
  long long ans = 0;
  int i = 0, j = 0;
  while (i < an && j < bn) {
    if (preMin[i] < postMin[j])
      ans += 1LL * (bn - j) * preMin[i], i++;
    else
      ans += 1LL * (an - i) * postMin[j], j++;
  }
  return ans;
}
long long dnc(int l, int r, vector<int>& a, vector<int>& b, vector<int>& suf) {
  int an = a.size(), bn = b.size();
  if (an == 0 || bn == 0 || l > r) return 0;
  if (l == r) return n - suf[l];
  int mid = (l + r) >> 1;
  vector<int> al, bl, ar, br;
  for (int ai : a) {
    if (ai <= mid)
      al.push_back(ai);
    else
      ar.push_back(ai);
  }
  for (int bi : b) {
    if (bi <= mid)
      bl.push_back(bi);
    else
      br.push_back(bi);
  }
  long long ans = dnc(l, mid, al, bl, suf) + dnc(mid + 1, r, ar, br, suf);
  ans += calc(mid, al, br) + calc(mid, bl, ar);
  al.clear();
  ar.clear();
  bl.clear();
  br.clear();
  return ans;
}
int main() {
  int q;
  string str;
  cin >> n >> q >> str;
  vector<int> suf = suffix_array_construction(str);
  vector<int> lcp = lcp_construction(str, suf);
  init(lcp);
  for (int i = 0; i < n; i++) spos[suf[i]] = i;
  for (int i = 1; i <= q; i++) {
    int k, l;
    scanf("%d %d", &k, &l);
    vector<int> a, b;
    for (int j = 1; j <= k; j++) {
      int ai;
      scanf("%d", &ai);
      a.push_back(spos[ai - 1]);
    }
    for (int j = 1; j <= l; j++) {
      int bi;
      scanf("%d", &bi);
      b.push_back(spos[bi - 1]);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    printf("%lld\n", dnc(0, n - 1, a, b, suf));
  }
  return 0;
}