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;
char s[200001];
void CopyArray(int n, int s[], int t[]) {
  for (int i = 0; i <= n; ++i) {
    t[i] = s[i];
  }
}
int suffixArray[200001], posInSuffixArray[200001], lcpArray[200001],
    clas[200001], order[200001], cnt[200001], temp[200001], lg[200001],
    lcpTable[18][200001];
void InitialiseBaseOrder(int n) {
  for (int i = 0; i < 256; ++i) {
    cnt[i] = 0;
  }
  for (int i = 0; i <= n; ++i) {
    ++cnt[s[i]];
  }
  for (int i = 1; i < 256; ++i) {
    cnt[i] += cnt[i - 1];
  }
  for (int i = n; i >= 0; --i) {
    order[--cnt[s[i]]] = i;
  }
}
void InitialiseBaseClass(int n) {
  clas[order[0]] = 0;
  for (int i = 1; i <= n; ++i) {
    clas[order[i]] = clas[order[i - 1]] + (s[order[i]] != s[order[i - 1]]);
  }
}
void InitialiseBaseOrderAndClass(int n) {
  InitialiseBaseOrder(n);
  InitialiseBaseClass(n);
}
void UpdateOrder(int n, int k) {
  for (int i = 0; i <= n; ++i) {
    cnt[i] = 0;
  }
  for (int i = 0; i <= n; ++i) {
    int j = (order[i] - k + n + 1) % (n + 1);
    ++cnt[clas[j]];
  }
  for (int i = 1; i <= n; ++i) {
    cnt[i] += cnt[i - 1];
  }
  for (int i = n; i >= 0; --i) {
    int j = (order[i] - k + n + 1) % (n + 1);
    temp[--cnt[clas[j]]] = j;
  }
  CopyArray(n, temp, order);
}
void UpdateClass(int n, int k) {
  temp[order[0]] = 0;
  for (int i = 1; i <= n; ++i) {
    temp[order[i]] =
        temp[order[i - 1]] +
        (clas[order[i]] != clas[order[i - 1]] ||
         clas[(order[i] + k) % (n + 1)] != clas[(order[i - 1] + k) % (n + 1)]);
  }
  CopyArray(n, temp, clas);
}
void UpdateOrderAndClass(int n, int k) {
  UpdateOrder(n, k);
  UpdateClass(n, k);
}
void BuildSuffixArray(int n) {
  InitialiseBaseOrderAndClass(n);
  for (int k = 0; (1 << k) < n; ++k) {
    UpdateOrderAndClass(n, (1 << k));
  }
  for (int i = 1; i <= n; ++i) {
    suffixArray[i] = order[i] + 1;
    posInSuffixArray[i] = clas[i - 1];
  }
}
int LCP(int n, int i, int j, int ans) {
  ans = max(0, ans);
  i += ans, j += ans;
  for (; i < n && j < n && s[i] == s[j]; ++i, ++j, ++ans)
    ;
  return ans;
}
void BuildLCPArray(int n) {
  int ans = 0;
  for (int k = 0, i = order[0]; k <= n; ++k, i = (i + 1) % (n + 1)) {
    ans = (clas[i] == n) ? 0 : LCP(n, i, order[clas[i] + 1], ans - 1);
    lcpArray[clas[i]] = ans;
  }
}
void BuildLCPSparseTable(int n) {
  for (int i = 1; i <= n; ++i) {
    lcpTable[0][i] = lcpArray[i];
  }
  for (int k = 1; (1 << k) <= n; ++k) {
    for (int i = 1, j = i + (1 << (k - 1)); j <= n; ++i, ++j) {
      lcpTable[k][i] = min(lcpTable[k - 1][i], lcpTable[k - 1][j]);
    }
  }
}
void BuildSuffixAndLCPArray(int n) {
  for (int i = 2; i <= n; ++i) {
    lg[i] = 1 + lg[(i / 2)];
  }
  BuildSuffixArray(n);
  BuildLCPArray(n);
  BuildLCPSparseTable(n);
}
int LCP_RMQ(int i, int j) {
  --j;
  int k = lg[j - i + 1];
  return min(lcpTable[k][i], lcpTable[k][j - (1 << k) + 1]);
}
int LCP(int i, int j) {
  i = posInSuffixArray[i], j = posInSuffixArray[j];
  if (i > j) {
    swap(i, j);
  }
  return LCP_RMQ(i, j);
}
void TakeQueryInputs(int n, vector<int> &A) {
  for (int i = 1; i <= n; ++i) {
    int x;
    scanf("%d", &x);
    A.push_back(posInSuffixArray[x]);
  }
  sort(A.begin(), A.end());
}
void UpdateStacks(stack<int> &M, stack<int> &C, long long &s, int l, int r,
                  int val) {
  if (l == 0) {
    return;
  }
  int x = LCP_RMQ(l, r);
  for (; !M.empty() && M.top() >= x; val += C.top(), M.pop(), C.pop()) {
    s -= (1ll * M.top() * C.top());
  }
  s += (1ll * x * val);
  M.push(x);
  C.push(val);
}
long long Count(vector<int> A, vector<int> B) {
  stack<int> M, C;
  long long s = 0, ans = 0;
  reverse(A.begin(), A.end());
  reverse(B.begin(), B.end());
  for (int i = 0; A.size(); A.pop_back()) {
    UpdateStacks(M, C, s, i, A.back(), 0);
    for (; B.size() && B.back() < A.back(); i = B.back(), B.pop_back()) {
      UpdateStacks(M, C, s, B.back(), A.back(), 1);
    }
    UpdateStacks(M, C, s, i, A.back(), 0);
    ans += s;
  }
  return ans;
}
long long Query(int n) {
  int k, l;
  vector<int> A, B;
  long long ans = 0;
  scanf("%d%d", &k, &l);
  TakeQueryInputs(k, A);
  TakeQueryInputs(l, B);
  for (auto x : A) {
    int j = lower_bound(B.begin(), B.end(), x) - B.begin();
    if (j < B.size() && B[j] == x) {
      ans += (n - suffixArray[x] + 1);
    }
  }
  ans += Count(A, B);
  ans += Count(B, A);
  return ans;
}
int main() {
  int n, q;
  scanf("%d%d%s", &n, &q, s);
  BuildSuffixAndLCPArray(n);
  while (q--) {
    printf("%lld\n", Query(n));
  }
}