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 long long N = 2e5 + 5;
long long n, k, l, q;
int a[N], b[N], c[2 * N], sa[N], rnk[N], lcp[N], s[N];
long long lm[2 * N], rm[2 * N], t[4 * N];
string S;
void build(int id, int x, int y) {
  if (x == y) {
    t[id] = lcp[x];
    return;
  }
  int mid = (x + y) >> 1;
  build(2 * id, x, mid);
  build(2 * id + 1, mid + 1, y);
  t[id] = min(t[2 * id], t[2 * id + 1]);
}
int get_lcp(int l, int r, int id = 1, int x = 0, int y = n - 2) {
  if (l > y or r < x) return N;
  if (l <= x and r >= y) return t[id];
  int mid = (x + y) >> 1;
  return min(get_lcp(l, r, 2 * id, x, mid),
             get_lcp(l, r, 2 * id + 1, mid + 1, y));
}
void kasai() {
  int k = 0;
  for (int i = 0; i < n; i++) rnk[sa[i]] = i;
  for (int i = 0; i < n; i++, k ? k-- : 0) {
    if (rnk[i] == n - 1) {
      k = 0;
      continue;
    }
    int j = sa[rnk[i] + 1];
    while (i + k < n && j + k < n && s[i + k] == s[j + k]) k++;
    lcp[rnk[i]] = k;
  }
  build(1, 0, n - 2);
}
inline bool leq(int a1, int a2, int b1, int b2) {
  return (a1 < b1 || a1 == b1 && a2 <= b2);
}
inline bool leq(int a1, int a2, int a3, int b1, int b2, int b3) {
  return (a1 < b1 || a1 == b1 && leq(a2, a3, b2, b3));
}
static void radixPass(int* a, int* b, int* r, int n, int K) {
  int* c = new int[K + 1];
  for (int i = 0; i <= K; i++) c[i] = 0;
  for (int i = 0; i < n; i++) c[r[a[i]]]++;
  for (int i = 0, sum = 0; i <= K; i++) {
    int t = c[i];
    c[i] = sum;
    sum += t;
  }
  for (int i = 0; i < n; i++) b[c[r[a[i]]]++] = a[i];
  delete[] c;
}
void suffixArray(int* s, int* SA, int n, int K) {
  int n0 = (n + 2) / 3, n1 = (n + 1) / 3, n2 = n / 3, n02 = n0 + n2;
  int* s12 = new int[n02 + 3];
  s12[n02] = s12[n02 + 1] = s12[n02 + 2] = 0;
  int* SA12 = new int[n02 + 3];
  SA12[n02] = SA12[n02 + 1] = SA12[n02 + 2] = 0;
  int* s0 = new int[n0];
  int* SA0 = new int[n0];
  for (int i = 0, j = 0; i < n + (n0 - n1); i++)
    if (i % 3 != 0) s12[j++] = i;
  radixPass(s12, SA12, s + 2, n02, K);
  radixPass(SA12, s12, s + 1, n02, K);
  radixPass(s12, SA12, s, n02, K);
  int name = 0, c0 = -1, c1 = -1, c2 = -1;
  for (int i = 0; i < n02; i++) {
    if (s[SA12[i]] != c0 || s[SA12[i] + 1] != c1 || s[SA12[i] + 2] != c2) {
      name++;
      c0 = s[SA12[i]];
      c1 = s[SA12[i] + 1];
      c2 = s[SA12[i] + 2];
    }
    if (SA12[i] % 3 == 1)
      s12[SA12[i] / 3] = name;
    else
      s12[SA12[i] / 3 + n0] = name;
  }
  if (name < n02) {
    suffixArray(s12, SA12, n02, name);
    for (int i = 0; i < n02; i++) s12[SA12[i]] = i + 1;
  } else
    for (int i = 0; i < n02; i++) SA12[s12[i] - 1] = i;
  for (int i = 0, j = 0; i < n02; i++)
    if (SA12[i] < n0) s0[j++] = 3 * SA12[i];
  radixPass(s0, SA0, s, n0, K);
  for (int p = 0, t = n0 - n1, k = 0; k < n; k++) {
    int i = (SA12[t] < n0 ? SA12[t] * 3 + 1 : (SA12[t] - n0) * 3 + 2);
    int j = SA0[p];
    if (SA12[t] < n0 ? leq(s[i], s12[SA12[t] + n0], s[j], s12[j / 3])
                     : leq(s[i], s[i + 1], s12[SA12[t] - n0 + 1], s[j],
                           s[j + 1], s12[j / 3 + n0])) {
      SA[k] = i;
      t++;
      if (t == n02)
        for (k++; p < n0; p++, k++) SA[k] = SA0[p];
    } else {
      SA[k] = j;
      p++;
      if (p == n0)
        for (k++; t < n02; t++, k++)
          SA[k] = (SA12[t] < n0 ? SA12[t] * 3 + 1 : (SA12[t] - n0) * 3 + 2);
    }
  }
  delete[] s12;
  delete[] SA12;
  delete[] SA0;
  delete[] s0;
}
long long solve(int* a, int m) {
  for (long long i = 1; i < m; i++) {
    if (a[i] == a[i + 1])
      a[i] = n - sa[a[i]];
    else
      a[i] = get_lcp(a[i], a[i + 1] - 1);
  }
  m--;
  stack<long long> s;
  while (!s.empty()) s.pop();
  for (long long i = 1; i <= m; i++) {
    while (!s.empty() and a[s.top()] > a[i]) {
      rm[s.top()] = i;
      s.pop();
    }
    s.push(i);
  }
  while (!s.empty()) {
    rm[s.top()] = m + 1;
    s.pop();
  }
  for (long long i = m; i > 0; i--) {
    while (!s.empty() and a[s.top()] >= a[i]) {
      lm[s.top()] = i;
      s.pop();
    }
    s.push(i);
  }
  while (!s.empty()) {
    lm[s.top()] = 0;
    s.pop();
  }
  long long ans = 0;
  for (long long i = 1; i <= m; i++) {
    ans += 1ll * a[i] * (i - lm[i]) * (rm[i] - i);
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> q;
  cin >> S;
  if (n == 1) {
    while (q--) {
      cin >> k >> l;
      cout << 1ll * k * l << endl;
      cin >> k >> l;
    }
    return 0;
  }
  for (int i = 0; i < n; i++) s[i] = S[i] - 'a' + 1;
  suffixArray(s, sa, n, 26);
  kasai();
  while (q--) {
    cin >> k >> l;
    for (long long i = 1; i <= k; i++) {
      cin >> a[i];
      a[i] = rnk[a[i] - 1];
      c[i] = a[i];
    }
    for (long long i = 1; i <= l; i++) {
      cin >> b[i];
      b[i] = rnk[b[i] - 1];
      c[i + k] = b[i];
    }
    sort(a + 1, a + k + 1);
    sort(b + 1, b + l + 1);
    sort(c + 1, c + k + l + 1);
    long long ans = solve(c, k + l) - solve(a, k) - solve(b, l);
    cout << ans << endl;
  }
}