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 GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int arr = 2e5 + 10;
const int ar = 2e3 + 10;
const long double pi = acos(-1);
const long double eps = 1e-10;
const long long md = 1e9 + 7;
int n, q;
string s;
unsigned long long pp[(int)(1e6 + 10)];
unsigned long long h[(int)(1e6 + 10)];
unsigned long long magic(int a, int b) {
  return (a + 1) * b % (a == 1 ? 1 : a - 1) ^ 124 + a * b + a + b * 1000ul + a ^
         b + a ^ (b * 12442ull) + a * a ^
         (b % 124564ull) + a % (b == 0 ? 1 : b) + b % (a == 0 ? 1 : a) +
             b * a % (b % a == 0 ? 1 : b % a);
}
unsigned long long get_hash(int l, int r) {
  if (l == r) {
    return s[l];
  }
  unsigned long long res = h[r];
  res -= h[l];
  res *= pp[(int)(1e6 + 10) - l - 1];
  return res;
}
bool eq(int l1, int r1, int l2, int r2) {
  return r1 - l1 == r2 - l2 && s[l1] == s[l2] &&
         get_hash(l1, r1) == get_hash(l2, r2);
}
int lcp(int i, int j) {
  int l = 0, r = (int)(s.size()) - max(i, j);
  while (r - l > 0) {
    int m = (l + r + 1) / 2;
    if (eq(i, i + m - 1, j, j + m - 1)) {
      l = m;
    } else {
      r = m - 1;
    }
  }
  return l;
}
bool cmp(int i, int j) {
  int l = lcp(i, j);
  if (i + l - 1 == (int)(s.size()) - 1 || j + l - 1 == (int)(s.size()) - 1) {
    return i > j;
  }
  return s[i + l] < s[j + l];
}
int p[(int)(1e6 + 10)];
int lpc[(int)(1e6 + 10)];
const int M = 20;
int lg[(int)(1e6 + 10)];
int stb[(int)(1e6 + 10)][M];
int get_min(int l, int r) {
  int k = lg[r - l + 1];
  return min(stb[l][k], stb[r - (1ll << k) + 1][k]);
}
int L[(int)(1e6 + 10)];
int R[(int)(1e6 + 10)];
unsigned long long get_sum_min(vector<int> v) {
  vector<pair<int, int>> s;
  s.clear();
  for (int i = 0; i < (int)(v.size()); i++) {
    while (!s.empty() && s.back().first > v[i]) {
      s.pop_back();
    }
    if (s.empty()) {
      L[i] = -1;
    } else {
      L[i] = s.back().second;
    }
    s.push_back(make_pair(v[i], i));
  }
  s.clear();
  for (int i = (int)(v.size()) - 1; i >= 0; i--) {
    while (!s.empty() && s.back().first >= v[i]) {
      s.pop_back();
    }
    if (s.empty()) {
      R[i] = (int)(v.size());
    } else {
      R[i] = s.back().second;
    }
    s.push_back(make_pair(v[i], i));
  }
  unsigned long long res = 0;
  for (int i = 0; i < (int)(v.size()); i++) {
    res += 1ull * (i - L[i]) * (R[i] - i) * v[i];
  }
  return res;
}
int rp[(int)(1e6 + 10)];
unsigned long long get(vector<int> a) {
  for (auto &i : a) {
    i = rp[i];
  }
  sort(a.begin(), a.end());
  vector<int> v(0);
  for (int i = 0; i + 1 < (int)(a.size()); i++) {
    if (a[i] == a[i + 1]) {
      v.push_back((int)(s.size()) - p[a[i]]);
    } else {
      v.push_back(get_min(a[i], a[i + 1] - 1));
    }
  }
  return get_sum_min(v);
}
int class_eq[(int)(1e6 + 10)];
vector<pair<int, int>> vh[(int)(1e6 + 10)];
vector<int> vh1[(int)(1e6 + 10)];
bool cmp_magic(int i, int j) { return class_eq[i] < class_eq[j]; }
vector<pair<pair<int, int>, int>> vh_sort[(int)(1e6 + 10)];
void build_p() {
  s = s + "#";
  n++;
  for (int i = 0; i < n; i++) {
    class_eq[i] = s[i];
  }
  for (int j = 1; j < M; j++) {
    vector<pair<pair<int, int>, int>> v(0);
    for (int i = 0; i < n; i++) {
      v.push_back(make_pair(
          make_pair(class_eq[i], class_eq[(i + (1ll << (j - 1))) % n]), i));
    }
    int max_class_eq = *max_element(class_eq, class_eq + n);
    for (int i = 0; i <= max_class_eq; i++) {
      vh_sort[i].clear();
    }
    for (auto i : v) {
      int val = i.first.second;
      vh_sort[val].push_back(i);
    }
    v.clear();
    for (int i = 0; i <= max_class_eq; i++) {
      for (auto j : vh_sort[i]) {
        v.push_back(j);
      }
    }
    for (int i = 0; i <= max_class_eq; i++) {
      vh_sort[i].clear();
    }
    for (auto i : v) {
      int val = i.first.first;
      vh_sort[val].push_back(i);
    }
    v.clear();
    for (int i = 0; i <= max_class_eq; i++) {
      for (auto j : vh_sort[i]) {
        v.push_back(j);
      }
    }
    int last = 0;
    for (int i = 0; i < n; i++) {
      if (i == 0 || v[i].first != v[i - 1].first) {
        class_eq[v[i].second] = last++;
      } else {
        class_eq[v[i].second] = class_eq[v[i - 1].second];
      }
    }
  }
  n--;
  s.pop_back();
  sort(p, p + n, cmp_magic);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  for (int i = 2; i < (int)(1e6 + 10); i++) {
    lg[i] = lg[i / 2] + 1;
  }
  pp[0] = 1;
  for (int i = 1; i < (int)(1e6 + 10); i++) {
    pp[i] = pp[i - 1] * 12425ull;
  }
  cin >> n >> q;
  cin >> s;
  h[0] = 0;
  for (int i = 1; i < n; i++) {
    h[i] = h[i - 1] + pp[i] * magic(s[i - 1], s[i]);
  }
  for (int i = 0; i < n; i++) {
    p[i] = i;
  }
  build_p();
  for (int i = 0; i < n; i++) {
    rp[p[i]] = i;
  }
  for (int i = 1; i < n; i++) {
    lpc[i - 1] = lcp(p[i - 1], p[i]);
  }
  for (int i = 0; i < n - 1; i++) {
    stb[i][0] = lpc[i];
  }
  for (int j = 1; j < M; j++) {
    for (int i = 0; i + (1ll << j) - 1 < n - 1; i++) {
      stb[i][j] = min(stb[i][j - 1], stb[i + (1ll << (j - 1))][j - 1]);
    }
  }
  while (q--) {
    int s1, s2;
    cin >> s1 >> s2;
    vector<int> ab(0);
    vector<int> a(0);
    vector<int> b(0);
    while (s1--) {
      int x;
      cin >> x;
      x--;
      a.push_back(x);
      ab.push_back(x);
    }
    while (s2--) {
      int x;
      cin >> x;
      x--;
      b.push_back(x);
      ab.push_back(x);
    }
    cout << get(ab) - get(a) - get(b) << "\n";
  }
}