#include <bits/stdc++.h>
using namespace std;
typedef struct item* pitem;
struct item {
  int pr, cnt, val;
  int msk;
  pitem l, r;
  bool rev;
  item(int val)
      : pr(rand()), cnt(1), val(1 << val), msk(1 << val), l(0), r(0), rev(0) {}
};
void push(pitem it) {
  if (it) {
    if (it->rev) {
      swap(it->l, it->r);
      if (it->l) it->l->rev ^= true;
      if (it->r) it->r->rev ^= true;
      it->rev = false;
    }
  }
}
int val(pitem t) { return t ? t->val : 0; }
int cnt(pitem t) { return t ? t->cnt : 0; }
int msk(pitem t) { return t ? t->msk : 0; }
void upd_cnt(pitem t) {
  if (t) {
    t->cnt = cnt(t->l) + cnt(t->r) + 1;
    t->msk = msk(t->l) | msk(t->r) | val(t);
  }
}
void merge(pitem& t, pitem l, pitem r) {
  push(l);
  push(r);
  if (!l || !r)
    t = l ? l : r;
  else if (l->pr > r->pr)
    merge(l->r, l->r, r), t = l;
  else
    merge(r->l, l, r->l), t = r;
  upd_cnt(t);
}
void split(pitem t, pitem& l, pitem& r, int sz) {
  if (!t) {
    l = r = 0;
    return;
  }
  push(t);
  if (sz <= cnt(t->l))
    split(t->l, l, t->l, sz), r = t;
  else
    split(t->r, t->r, r, sz - 1 - cnt(t->l)), l = t;
  upd_cnt(t);
}
void reverse(pitem t, int l, int r) {
  pitem t1, t2, t3;
  split(t, t2, t3, r);
  split(t2, t1, t2, l);
  t2->rev ^= 1;
  merge(t, t1, t2);
  merge(t, t, t3);
}
int get(pitem t, int v) {
  if (msk(t->l) & v) return get(t->l, v);
  if (val(t) & v) return cnt(t->l);
  return cnt(t->l) + 1 + get(t->r, v);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    string s;
    int n, k;
    cin >> n >> k >> s;
    vector<int> a(n);
    int ne = n / 2 - k;
    for (int i = 0, ThxDem = 2 * (k - 1); i < ThxDem; ++i) a[i] = i % 2;
    for (int i = 2 * (k - 1), ThxDem = n; i < ThxDem; ++i)
      a[i] = i - 2 * (k - 1) > ne;
    pitem rt = 0;
    for (int i = 0, ThxDem = n; i < ThxDem; ++i)
      merge(rt, rt, new item(s[i] == ')'));
    cout << n << "\n";
    for (int i = 0, ThxDem = n; i < ThxDem; ++i) {
      pitem t1, t2;
      split(rt, t1, t2, i);
      int len = get(t2, 1 << a[i]) + 1;
      merge(rt, t1, t2);
      reverse(rt, i, i + len);
      cout << i + 1 << " " << i + len << "\n";
    }
  }
}
