#include <bits/stdc++.h>
long long in() {
  long long x = 0, f = 1;
  char ch;
  while (!isdigit(ch = getchar())) (ch == '-') && (f = -f);
  for (x = ch ^ 48; isdigit(ch = getchar());
       x = (x << 1) + (x << 3) + (ch ^ 48))
    ;
  return x * f;
}
const int maxn = 2e5 + 100;
const int inf = 0x7fffffff;
int n, m, T;
int H[maxn], c[maxn], x[maxn], y[maxn], sa[maxn], rk[maxn];
long long l[maxn], r[maxn];
char s[maxn];
int fuck1[maxn], fuck2[maxn], lg[maxn];
int f[maxn][25];
struct Tree {
 protected:
  struct node {
    node *ch[2];
    int siz, tag, l, r;
    long long val;
    node(int siz = 0, int tag = 0, int l = 0, int r = 0, long long val = 0)
        : siz(siz), tag(tag), l(l), r(r), val(val) {}
    void upd() {
      siz = ch[0]->siz + ch[1]->siz;
      val = ch[0]->val + ch[1]->val;
    }
    void clr() { siz = val = 0, tag = 1; }
    void dwn() {
      if (!tag) return;
      ch[0]->clr(), ch[1]->clr();
      tag = 0;
    }
  } * root;
  void build(node *&o, int l, int r) {
    o = new node(0, 0, l, r);
    if (l == r) return;
    int mid = (l + r) >> 1;
    build(o->ch[0], l, mid);
    build(o->ch[1], mid + 1, r);
  }
  void modify(node *o, int p, int x) {
    if (!p) return;
    if (o->r < p || o->l > p) return;
    if (o->l == o->r) return (void)(o->siz += x, o->val += 1LL * p * x);
    o->dwn();
    modify(o->ch[0], p, x);
    modify(o->ch[1], p, x);
    o->upd();
  }
  long long query(node *o, int l, int r) {
    if (o->r < l || o->l > r || l > r) return 0;
    if (l <= o->l && o->r <= r) {
      long long tmp = o->siz;
      o->clr();
      return tmp;
    }
    o->dwn();
    long long ans = query(o->ch[0], l, r) + query(o->ch[1], l, r);
    return o->upd(), ans;
  }

 public:
  void build(int len) { build(root, 1, len); }
  void lazy(int p, int x) { modify(root, p, x); }
  long long query(int l, int r) { return query(root, l, r); }
  void clr() { root->val = 0, root->siz = 0, root->tag = 1; }
  long long getans() { return root->val; }
} t;
void predoit() {
  m = 122;
  for (int i = 1; i <= n; i++) c[x[i] = s[i]]++;
  for (int i = 1; i <= m; i++) c[i] += c[i - 1];
  for (int i = n; i >= 1; i--) sa[c[x[i]]--] = i;
  for (int k = 1; k <= n; k <<= 1) {
    int num = 0;
    for (int i = n - k + 1; i <= n; i++) y[++num] = i;
    for (int i = 1; i <= n; i++)
      if (sa[i] > k) y[++num] = sa[i] - k;
    for (int i = 1; i <= m; i++) c[i] = 0;
    for (int i = 1; i <= n; i++) c[x[i]]++;
    for (int i = 1; i <= m; i++) c[i] += c[i - 1];
    for (int i = n; i >= 1; i--) sa[c[x[y[i]]]--] = y[i], y[i] = 0;
    std::swap(x, y);
    x[sa[1]] = 1, num = 1;
    for (int i = 2; i <= n; i++)
      x[sa[i]] = (y[sa[i]] == y[sa[i - 1]] && y[sa[i] + k] == y[sa[i - 1] + k])
                     ? num
                     : ++num;
    if (num == n) break;
    m = num;
  }
  for (int i = 1; i <= n; i++) rk[i] = x[i];
  int h = 0;
  for (int i = 1; i <= n; i++) {
    if (rk[i] == 1) continue;
    if (h) h--;
    int j = sa[rk[i] - 1];
    while (j + h <= n && s[i + h] == s[j + h]) h++;
    H[rk[i]] = h;
  }
}
void work_contribute() {
  lg[0] = -1;
  for (int i = 1; i <= n; i++) f[i][0] = H[i], lg[i] = lg[i >> 1] + 1;
  for (int j = 1; j <= 20; j++)
    for (int i = 1; i + (1 << j) - 1 <= n; i++)
      f[i][j] = std::min(f[i][j - 1], f[i + (1 << (j - 1))][j - 1]);
}
int getans(int l, int r) {
  if (l > r)
    std::swap(l, r);
  else if (l == r)
    return n - sa[l] + 1;
  else
    l++;
  int len = lg[r - l + 1];
  return std::min(f[l][len], f[r - (1 << len) + 1][len]);
}
void query() {
  long long ans = 0;
  int nnn = in(), mmm = in();
  for (int i = 1; i <= nnn; i++) fuck1[i] = rk[in()];
  for (int i = 1; i <= mmm; i++) fuck2[i] = rk[in()];
  std::sort(fuck1 + 1, fuck1 + nnn + 1);
  std::sort(fuck2 + 1, fuck2 + mmm + 1);
  for (int i = 1, j = 1; i <= nnn; i++) {
    if (i == 1)
      t.clr();
    else {
      int lcp = getans(fuck1[i - 1], fuck1[i]), tmp = 0;
      tmp = t.query(lcp + 1, n);
      if (lcp) t.lazy(lcp, tmp);
    }
    while (j <= mmm && fuck2[j] <= fuck1[i])
      t.lazy(getans(fuck2[j], fuck1[i]), 1), j++;
    ans += t.getans();
  }
  for (int i = 1, j = 1; i <= mmm; i++) {
    if (i == 1)
      t.clr();
    else {
      int lcp = getans(fuck2[i - 1], fuck2[i]), tmp = 0;
      tmp = t.query(lcp + 1, n);
      if (lcp) t.lazy(lcp, tmp);
    }
    while (j <= nnn && fuck1[j] < fuck2[i])
      t.lazy(getans(fuck1[j], fuck2[i]), 1), j++;
    while (j <= nnn && fuck1[j] <= fuck2[i])
      t.lazy(getans(fuck1[j], fuck2[i]), 1), ans -= getans(fuck1[j], fuck2[i]),
          j++;
    ans += t.getans();
  }
  printf("%lld\n", ans);
}
int main() {
  n = in(), T = in();
  t.build(n);
  scanf("%s", s + 1);
  predoit();
  work_contribute();
  while (T-- > 0) query();
  return 0;
}
