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;
struct T {
  int id;
  int c1;
  int c2;
};
bool operator<(T a, T b) {
  if (a.c1 != b.c1) {
    return a.c1 < b.c1;
  } else {
    return a.c2 < b.c2;
  }
}
const int N = 200000 + 7;
int n;
int top;
int p[N];
int c[N];
int f[N];
int tab[N];
int kol[N];
int ant[N];
int nxt[N];
int stk[N];
int tree[4 * N];
string s;
void build(int v, int tl, int tr) {
  if (tl == tr) {
    tree[v] = tab[tl];
  } else {
    int tm = (tl + tr) / 2;
    build(2 * v, tl, tm);
    build(2 * v + 1, tm + 1, tr);
    tree[v] = min(tree[2 * v], tree[2 * v + 1]);
  }
}
void build() { build(1, 0, n - 1); }
int get_min(int v, int tl, int tr, int l, int r) {
  if (tr < l || r < tl) {
    return N;
  }
  if (l <= tl && tr <= r) {
    return tree[v];
  } else {
    int tm = (tl + tr) / 2;
    return min(get_min(2 * v, tl, tm, l, r),
               get_min(2 * v + 1, tm + 1, tr, l, r));
  }
}
int get_min(int l, int r) { return get_min(1, 0, n - 1, l, r); }
vector<T> so(vector<T> a) {
  int n = (int)a.size();
  vector<T> b(n);
  int mc = 0;
  for (auto &it : a) {
    mc = max(mc, it.c1);
    mc = max(mc, it.c2);
  }
  for (int i = 0; i <= mc; i++) {
    f[i] = 0;
  }
  for (auto &it : a) {
    f[it.c2]++;
  }
  for (int i = 1; i <= mc; i++) {
    f[i] += f[i - 1];
  }
  for (int i = 0; i < n; i++) {
    b[--f[a[i].c2]] = a[i];
  }
  for (int i = 0; i <= mc; i++) {
    f[i] = 0;
  }
  for (auto &it : b) {
    f[it.c1]++;
  }
  for (int i = 1; i <= mc; i++) {
    f[i] += f[i - 1];
  }
  for (int i = n - 1; i >= 0; i--) {
    a[--f[b[i].c1]] = b[i];
  }
  return a;
}
int lcp(int i, int j) {
  i = c[i];
  j = c[j];
  if (i == j) {
    return kol[i];
  }
  if (i > j) {
    swap(i, j);
  }
  return get_min(i + 1, j);
}
bool cmp(pair<int, int> a, pair<int, int> b) {
  if (a.second == b.second) {
    return a.first > b.first;
  } else {
    return c[a.second] < c[b.second];
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int q;
  cin >> n >> q >> s;
  s += "$";
  n = (int)s.size();
  for (int i = 0; i < n; i++) {
    f[s[i]]++;
  }
  for (int x = 1; x < 1000; x++) {
    f[x] += f[x - 1];
  }
  for (int i = 0; i < n; i++) {
    p[--f[s[i]]] = i;
    c[i] = s[i];
  }
  for (int l = 1; l <= n; l *= 2) {
    vector<T> vec;
    for (int i = 0; i < n; i++) {
      vec.push_back({i, c[i], c[(i + l) % n]});
    }
    vec = so(vec);
    for (int i = 0; i < n; i++) {
      p[i] = vec[i].id;
    }
    c[vec[0].id] = 0;
    int cur = 0;
    for (int i = 1; i < n; i++) {
      if (vec[i - 1].c1 != vec[i].c1 || vec[i - 1].c2 != vec[i].c2) {
        cur++;
      }
      c[vec[i].id] = cur;
    }
  }
  int k = 0;
  for (int i = 0; i < n - 1; i++) {
    int pi = c[i];
    int j = p[pi - 1];
    while (s[i + k] == s[j + k]) {
      k++;
    }
    tab[pi] = k;
    k = max(0, k - 1);
  }
  for (int i = 0; i < n; i++) {
    kol[c[i]] = n - i - 1;
  }
  build();
  top = 0;
  stk[0] = -1;
  for (int i = 0; i < n; i++) {
    while (top && tab[i] <= tab[stk[top]]) {
      top--;
    }
    ant[i] = stk[top];
    stk[++top] = i;
  }
  top = 0;
  stk[0] = n;
  for (int i = n - 1; i >= 0; i--) {
    while (top && tab[i] < tab[stk[top]]) {
      top--;
    }
    nxt[i] = stk[top];
    stk[++top] = i;
  }
  while (q--) {
    int l1, l2;
    cin >> l1 >> l2;
    vector<int> v1(l1), v2(l2);
    set<int> s1;
    long long sol = 0;
    for (auto &p : v1) {
      cin >> p;
      p--;
      s1.insert(p);
    }
    for (auto &p : v2) {
      cin >> p;
      p--;
      if (s1.count(p)) {
        sol += n - p - 1;
      }
    }
    vector<pair<int, int>> vec;
    for (auto &p : v1) {
      vec.push_back({1, p});
    }
    for (auto &p : v2) {
      vec.push_back({2, p});
    }
    sort(vec.begin(), vec.end(), cmp);
    map<int, int> mp;
    long long sum = 0;
    int ant = -1;
    for (auto &it : vec) {
      int i = it.second;
      if (ant != -1) {
        int x = lcp(ant, i);
        while (!mp.empty()) {
          auto it = mp.end();
          it--;
          if (it->first > x) {
            sum -= (long long)it->first * it->second;
            sum += (long long)x * it->second;
            mp[x] += it->second;
            mp.erase(it);
          } else {
            break;
          }
        }
      }
      ant = i;
      if (it.first == 1) {
        sum += n - i - 1;
        mp[n - i - 1]++;
      } else {
        sol += sum;
      }
    }
    for (auto &it : vec) {
      it.first = 3 - it.first;
    }
    sort(vec.begin(), vec.end(), cmp);
    mp.clear();
    sum = 0;
    ant = -1;
    for (auto &it : vec) {
      int i = it.second;
      if (ant != -1) {
        int x = lcp(ant, i);
        while (!mp.empty()) {
          auto it = mp.end();
          it--;
          if (it->first > x) {
            sum -= (long long)it->first * it->second;
            sum += (long long)x * it->second;
            mp[x] += it->second;
            mp.erase(it);
          } else {
            break;
          }
        }
      }
      ant = i;
      if (it.first == 1) {
        sum += n - i - 1;
        mp[n - i - 1]++;
      } else {
        sol += sum;
      }
    }
    cout << sol << "\n";
  }
}