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 n;
char s[200001];
int s_pow2[20][200001];
int suffix_array[200001];
int suffix_index[200001];
int lcp[200000];
struct Str {
  int index;
  int part1, part2;
};
bool operator<(const Str& A, const Str& B) {
  if (A.part1 != B.part1) return A.part1 < B.part1;
  return A.part2 < B.part2;
}
void Process(vector<Str>& a, int* out) {
  sort(a.begin(), a.end());
  int next_id = 0;
  for (int i = 0, j; i <= n; i = j) {
    for (j = i; j <= n && !(a[i] < a[j]); ++j) {
      out[a[j].index] = next_id;
    }
    ++next_id;
  }
}
int GetLcp(int i, int j) {
  int p = 0;
  while ((1 << p) < n) ++p;
  int ret = 0;
  for (--p; p >= 0; --p) {
    if (s_pow2[p][i + ret] == s_pow2[p][j + ret]) {
      ret += (1 << p);
    }
  }
  return ret;
}
void BuildSuffixArray() {
  vector<Str> a;
  a.reserve(n + 1);
  for (int i = 0; i <= n; ++i) {
    a.push_back(Str{i, s[i], -1});
  }
  Process(a, s_pow2[0]);
  int p = 0;
  for (; (1 << p) <= n; ++p) {
    a.clear();
    for (int i = 0; i <= n; ++i) {
      const int j = i + (1 << p);
      const int part1 = s_pow2[p][i];
      const int part2 = j <= n ? s_pow2[p][j] : -1;
      a.push_back(Str{i, part1, part2});
    }
    Process(a, s_pow2[p + 1]);
  }
  for (int i = 0; i <= n; ++i) {
    suffix_index[i] = s_pow2[p][i];
    suffix_array[suffix_index[i]] = i;
  }
  for (int i = 0; i < n; ++i) {
    lcp[i] = GetLcp(suffix_array[i], suffix_array[i + 1]);
  }
}
vector<int> ReadSuffixes(int k) {
  vector<int> a;
  a.reserve(k);
  for (int i = 0; i < k; ++i) {
    int x;
    scanf("%d", &x);
    --x;
    a.push_back(suffix_index[x]);
  }
  sort(a.begin(), a.end());
  return std::move(a);
}
int rqm[20][200000];
void ComputeRQM() {
  for (int i = 0; i < n; ++i) {
    rqm[0][i] = lcp[i];
  }
  for (int p = 0; (1 << p) <= n; ++p) {
    for (int i = 0; i + (1 << p) <= n; ++i) {
      rqm[p + 1][i] = min(rqm[p][i], rqm[p][i + (1 << p)]);
    }
  }
}
int GetMin(int i, int j) {
  const int len = j - i;
  int p = 0;
  for (; (1 << p) <= len; ++p)
    ;
  --p;
  return min(rqm[p][i], rqm[p][i + len - (1 << p)]);
}
struct Steps {
  long long sum;
  vector<pair<int, int>> a;
  void Clear() {
    sum = 0;
    a.clear();
    a.emplace_back(-1, 0);
  }
  void Add(int h, int cnt) {
    if (cnt > 0 && h > 0) {
      sum += (long long)h * cnt;
      a.emplace_back(h, cnt);
    }
  }
  void Trim(int h) {
    int cnt = 0;
    while (a.back().first >= h) {
      sum -= (long long)a.back().first * a.back().second;
      cnt += a.back().second;
      a.pop_back();
    }
    Add(h, cnt);
  }
};
Steps steps_a;
Steps steps_b;
int main() {
  int q;
  scanf("%d%d", &n, &q);
  scanf("%s", s);
  BuildSuffixArray();
  ComputeRQM();
  for (int qq = 0; qq < q; ++qq) {
    int na, nb;
    scanf("%d%d", &na, &nb);
    const vector<int> a = ReadSuffixes(na);
    const vector<int> b = ReadSuffixes(nb);
    long long ret = 0;
    steps_a.Clear();
    steps_b.Clear();
    auto it_a = a.begin();
    auto it_b = b.begin();
    int prev = 0;
    while (it_a != a.end() || it_b != b.end()) {
      int curr = n;
      if (it_a != a.end()) curr = min(curr, *it_a);
      if (it_b != b.end()) curr = min(curr, *it_b);
      const int h = GetMin(prev, curr);
      steps_a.Trim(h);
      steps_b.Trim(h);
      for (; it_a != a.end() && *it_a == curr; ++it_a) {
        ret += steps_b.sum;
        const int suffix_len = n - suffix_array[*it_a];
        steps_a.Add(suffix_len, 1);
      }
      for (; it_b != b.end() && *it_b == curr; ++it_b) {
        ret += steps_a.sum;
        const int suffix_len = n - suffix_array[*it_b];
        steps_b.Add(suffix_len, 1);
      }
      prev = curr;
    }
    printf("%lld\n", ret);
  }
  return 0;
}