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;
int cmp_for_sa(int *r, int a, int b, int l) {
  return (r[a] == r[b]) && (r[a + l] == r[b + l]);
}
int wa[((int)(2e5 + 5))], wb[((int)(2e5 + 5))], wws[((int)(2e5 + 5))],
    wv[((int)(2e5 + 5))], rnk[((int)(2e5 + 5))], lcp[((int)(2e5 + 5))],
    sa[((int)(2e5 + 5))], data[((int)(2e5 + 5))];
void DA(int *r, int *sa, int n, int m) {
  int i, j, p, *x = wa, *y = wb, *t;
  for (i = 0; i < m; i++) wws[i] = 0;
  for (i = 0; i < n; i++) wws[x[i] = r[i]]++;
  for (i = 1; i < m; i++) wws[i] += wws[i - 1];
  for (i = n - 1; i >= 0; i--) sa[--wws[x[i]]] = i;
  for (j = 1, p = 1; p < n; j *= 2, m = p) {
    for (p = 0, i = n - j; i < n; i++) y[p++] = i;
    for (i = 0; i < n; i++)
      if (sa[i] >= j) y[p++] = sa[i] - j;
    for (i = 0; i < n; i++) wv[i] = x[y[i]];
    for (i = 0; i < m; i++) wws[i] = 0;
    for (i = 0; i < n; i++) wws[wv[i]]++;
    for (i = 1; i < m; i++) wws[i] += wws[i - 1];
    for (i = n - 1; i >= 0; i--) sa[--wws[wv[i]]] = y[i];
    for (t = x, x = y, y = t, p = 1, x[sa[0]] = 0, i = 1; i < n; i++)
      x[sa[i]] = cmp_for_sa(y, sa[i - 1], sa[i], j) ? p - 1 : p++;
  }
}
void cal_lcp(int *r, int *sa, int n) {
  int i, j, k = 0;
  for (i = 1; i <= n; i++) rnk[sa[i]] = i;
  for (i = 0; i < n; lcp[rnk[i++]] = k)
    for (k ? k-- : 0, j = sa[rnk[i] - 1]; r[i + k] == r[j + k]; k++)
      ;
}
void suffix_array(char *A) {
  int n = strlen(A);
  for (int i = 0; i <= 128; i++) {
    wa[i] = wb[i] = wws[i] = wv[i] = rnk[i] = lcp[i] = sa[i] = data[i] = 0;
  }
  for (int i = 0; i <= n; i++) {
    wa[i] = wb[i] = wws[i] = wv[i] = rnk[i] = lcp[i] = sa[i] = data[i] = 0;
    if (i < n) data[i] = A[i];
  }
  DA(data, sa, n + 1, 128);
  cal_lcp(data, sa, n);
  for (int i = 0; i < n; i++) {
    sa[i] = sa[i + 1];
    lcp[i] = lcp[i + 2];
    rnk[i]--;
  }
}
int arr[2][((int)(2e5 + 5))];
int choto(int n, int l, int r, bool b) {
  int m;
  while (l < r) {
    m = (l + r + 1) / 2;
    if (arr[b][m] == n)
      return m;
    else if (arr[b][m] < n)
      l = m;
    else
      r = m - 1;
  }
  if (arr[b][l] <= n) return l;
  return l - 1;
}
int boro(int n, int l, int r, bool b) {
  int m;
  while (l < r) {
    m = (l + r) / 2;
    if (arr[b][m] <= n)
      l = m + 1;
    else
      r = m;
  }
  if (arr[b][l] <= n) return l + 1;
  return l;
}
int tr[((int)(2e5 + 5)) * 4];
void init(int n, int b, int e) {
  if (b > e) return;
  if (b == e) {
    tr[n] = lcp[b];
    return;
  }
  int l, r, m;
  m = (b + e) >> 1;
  l = 1 + (n << 1);
  r = l + 1;
  init(l, b, m);
  init(r, m + 1, e);
  tr[n] = min(tr[l], tr[r]);
}
int getlcp(int n, int b, int e, int i, int j) {
  if (i > j || j < b || e < i || b > e) return ((int)(1e7));
  if (i <= b && j >= e) return tr[n];
  int l, r, m;
  m = (b + e) >> 1;
  l = 1 + (n << 1);
  r = l + 1;
  return min(getlcp(l, b, m, i, j), getlcp(r, m + 1, e, i, j));
}
char s[((int)(2e5 + 5))];
queue<pair<int, int> > v[((int)(2e5 + 5))];
int nxt[((int)(2e5 + 5))];
int main() {
  int n, q, i, a, b, j, k, h, l, sz, sz1, c, last;
  long long sum, pre, ans;
  pair<int, int> p;
  bool cur;
  scanf("%d %d", &n, &q);
  scanf("%s", s);
  suffix_array(s);
  init(0, 0, n - 2);
  while (q--) {
    scanf("%d %d", &a, &b);
    for (i = 0; i < a; i++) {
      scanf("%d", &arr[0][i]);
      arr[0][i]--;
      arr[0][i] = rnk[arr[0][i]];
    }
    for (i = 0; i < b; i++) {
      scanf("%d", &arr[1][i]);
      arr[1][i]--;
      arr[1][i] = rnk[arr[1][i]];
    }
    sort(arr[0], arr[0] + a);
    sort(arr[1], arr[1] + b);
    if (a > b) {
      cur = 0;
      sz = a;
      sz1 = b;
    } else {
      cur = 1;
      sz = b;
      sz1 = a;
    }
    pre = ans = sum = 0;
    last = -1;
    for (i = 0; i < sz; i++) {
      while (!v[i].empty()) v[i].pop();
      j = choto(arr[cur][i], 0, sz1 - 1, !cur);
      sum = 0;
      for (h = j; h > last; h--) {
        k = arr[!cur][h];
        l = getlcp(0, 0, n - 2, k, arr[cur][i] - 1);
        if (l == ((int)(1e7))) l = n - sa[k];
        sum += l;
        v[i].push(make_pair(l, 1));
      }
      last = j;
      j = i - 1;
      l = getlcp(0, 0, n - 2, arr[cur][j], arr[cur][i] - 1);
      c = 0;
      while (j >= 0) {
        while (!v[j].empty()) {
          p = v[j].front();
          if (p.first < l) break;
          v[j].pop();
          c += p.second;
          sum -= (long long)p.first * (long long)p.second;
        }
        if (!v[j].empty()) break;
        j = nxt[j];
      }
      nxt[i] = j;
      if (c > 0) v[i].push(make_pair(l, c));
      sum += (long long)l * (long long)c;
      sum += pre;
      pre = sum;
      ans += sum;
    }
    pre = 0;
    last = sz1;
    for (i = sz - 1; i >= 0; i--) {
      while (!v[i].empty()) v[i].pop();
      j = boro(arr[cur][i], 0, sz1 - 1, !cur);
      sum = 0;
      for (h = j; h < last; h++) {
        k = arr[!cur][h];
        l = getlcp(0, 0, n - 2, arr[cur][i], k - 1);
        sum += l;
        v[i].push(make_pair(l, 1));
      }
      last = j;
      j = i + 1;
      l = getlcp(0, 0, n - 2, arr[cur][i], arr[cur][j] - 1);
      c = 0;
      while (j < sz) {
        while (!v[j].empty()) {
          p = v[j].front();
          if (p.first < l) break;
          v[j].pop();
          c += p.second;
          sum -= p.first * p.second;
        }
        if (!v[j].empty()) break;
        j = nxt[j];
      }
      nxt[i] = j;
      if (c > 0) v[i].push(make_pair(l, c));
      sum += l * c;
      sum += pre;
      pre = sum;
      ans += sum;
    }
    printf("%lld\n", ans);
  }
  return 0;
}