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 MN = 200010;
int D[MN << 1];
void radixSort(int *A, int *B, int *C, int N, int M) {
  for (int i = 0; i < M; i++) D[i] = 0;
  for (int i = 0; i < N; i++) D[B[A[i]]]++;
  for (int i = 1; i < M; i++) D[i] += D[i - 1];
  for (int i = N - 1; i >= 0; i--) C[--D[B[A[i]]]] = A[i];
}
int T[MN << 1], B[MN << 1];
void suffixArray(string &S, int *C, int N) {
  memset(T, -1, sizeof(T));
  memset(B, -1, sizeof(B));
  for (int i = 0; i < N; i++) {
    T[i] = i;
    B[i] = S[i];
  }
  radixSort(T, B, C, N, 129);
  for (int i = 1; i < N; i <<= 1) {
    int k = 0;
    for (int j = 0; j < i; j++) T[k++] = N - i + j;
    for (int j = 0; j < N; j++)
      if (C[j] >= i) T[k++] = C[j] - i;
    radixSort(T, B, C, N, max(N, 129));
    T[C[0]] = k = 0;
    for (int j = 1; j < N; j++) {
      if (B[C[j]] != B[C[j - 1]] || B[C[j] + i] != B[C[j - 1] + i]) k++;
      T[C[j]] = k;
    }
    for (int j = 0; j < N; j++) B[j] = T[j];
  }
}
int R[MN];
void LCP(string &S, int *C, int *L, int N) {
  for (int i = 0; i < N; i++) R[C[i]] = i;
  for (int i = 0, h = 0; i < N; i++) {
    if (R[i]) {
      while (i + h < N && C[R[i] - 1] + h < N && S[i + h] == S[C[R[i] - 1] + h])
        h++;
      L[R[i]] = h;
    }
    if (h) h--;
  }
}
int N, Q;
string S;
int sa[MN], lcp[MN];
struct BIT1 {
  vector<int> tree;
  void init() { tree = vector<int>(4 * N, 1e9); }
  void upd(int idx, int val, int l, int r, int n) {
    if (idx < l || r < idx) return;
    if (l == r) {
      tree[n] = val;
      return;
    }
    int m = (l + r) >> 1;
    upd(idx, val, l, m, 2 * n);
    upd(idx, val, m + 1, r, 2 * n + 1);
    tree[n] = min(tree[2 * n], tree[2 * n + 1]);
  }
  int quer(int a, int b, int l, int r, int n) {
    if (b < l || r < a) return 1e9;
    if (a <= l && r <= b) return tree[n];
    int m = (l + r) >> 1;
    int L = quer(a, b, l, m, 2 * n);
    int R = quer(a, b, m + 1, r, 2 * n + 1);
    return min(L, R);
  }
} bit1;
struct BIT2 {
  int Z;
  vector<long long> tree, lazy;
  void init(int Z_) {
    Z = Z_;
    tree = vector<long long>(4 * Z, 0);
    lazy = vector<long long>(4 * Z, 0);
  }
  void prop(int l, int r, int n) {
    if (l != r) {
      int m = (l + r) >> 1;
      tree[2 * n] += 1LL * (m - l + 1) * lazy[n];
      lazy[2 * n] += lazy[n];
      tree[2 * n + 1] += 1LL * (r - m) * lazy[n];
      lazy[2 * n + 1] += lazy[n];
      lazy[n] = 0;
    }
  }
  void upd(int a, int b, int d, int l, int r, int n) {
    if (b < l || r < a) return;
    if (a <= l && r <= b) {
      tree[n] += 1LL * (r - l + 1) * d;
      lazy[n] += d;
      return;
    }
    prop(l, r, n);
    int m = (l + r) >> 1;
    upd(a, b, d, l, m, 2 * n);
    upd(a, b, d, m + 1, r, 2 * n + 1);
    tree[n] = tree[2 * n] + tree[2 * n + 1];
  }
  long long quer(int a, int b, int l, int r, int n) {
    if (b < l || r < a) return 0;
    if (a <= l && r <= b) return tree[n];
    prop(l, r, n);
    int m = (l + r) >> 1;
    long long L = quer(a, b, l, m, 2 * n);
    long long R = quer(a, b, m + 1, r, 2 * n + 1);
    return L + R;
  }
  void upd(int a, int b, int d) { upd(a, b, d, 0, Z - 1, 1); }
  long long quer(int a, int b) { return quer(a, b, 0, Z - 1, 1); }
} bit2;
vector<int> a, b;
vector<pair<int, int> > stk;
void add(int x) {
  if (stk.size()) {
    int h = bit1.quer(b[stk.back().second] + 1, b[x], 0, N - 1, 1);
    while (stk.size() && stk.back().first >= h) {
      pair<int, int> t = stk.back();
      stk.pop_back();
      int l = stk.size() ? stk.back().second + 1 : 0;
      bit2.upd(l, t.second, -t.first);
    }
    int l = stk.size() ? stk.back().second + 1 : 0;
    stk.push_back(pair<int, int>(h, x - 1));
    bit2.upd(l, x - 1, h);
  }
  stk.push_back(pair<int, int>(N - sa[b[x]], x));
  bit2.upd(x, x, N - sa[b[x]]);
}
long long query(int x) {
  if (stk.size()) {
    long long ret = 0;
    int h = bit1.quer(b[stk.back().second] + 1, x, 0, N - 1, 1);
    int s = 0, e = (int)stk.size() - 1, p = -1;
    while (s <= e) {
      int m = (s + e) >> 1;
      if (stk[m].first <= h) {
        p = m;
        s = m + 1;
      } else
        e = m - 1;
    }
    if (p != -1) {
      ret += bit2.quer(0, stk[p].second);
    }
    int l = p == -1 ? 0 : stk[p].second + 1;
    ret += 1LL * (stk.back().second - l + 1) * h;
    return ret;
  } else
    return 0;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin >> N >> Q >> S;
  suffixArray(S, sa, N);
  LCP(S, sa, lcp, N);
  bit1.init();
  for (int i = 1; i < N; i++) bit1.upd(i, lcp[i], 0, N - 1, 1);
  for (int q = 0; q < Q; q++) {
    int n, m;
    cin >> n >> m;
    a.resize(n);
    b.resize(m);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      a[i] = R[--a[i]];
    }
    for (int i = 0; i < m; i++) {
      cin >> b[i];
      b[i] = R[--b[i]];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    long long ans = 0;
    bit2.init(m);
    stk.clear();
    int pos = 0;
    for (int i = 0; i < n; i++) {
      while (pos < m && b[pos] <= a[i]) {
        add(pos++);
      }
      ans += query(a[i]);
    }
    swap(n, m);
    swap(a, b);
    bit2.init(m);
    stk.clear();
    pos = 0;
    for (int i = 0; i < n; i++) {
      while (pos < m && b[pos] < a[i]) {
        add(pos++);
      }
      ans += query(a[i]);
    }
    cout << ans << '\n';
  }
}