#include <bits/stdc++.h>
using namespace std;
struct STree {
  vector<int> st;
  int n;
  STree(int n) : st(4 * n + 5, 0), n(n) {}
  void upd(int k, int s, int e, int p, int v) {
    if (s + 1 == e) {
      st[k] = v;
      return;
    }
    int m = (s + e) / 2;
    if (p < m)
      upd(2 * k, s, m, p, v);
    else
      upd(2 * k + 1, m, e, p, v);
    st[k] = (st[2 * k] | st[2 * k + 1]);
  }
  int query(int k, int s, int e, int pos, int v) {
    if (e - 1 < pos) return -1;
    if (s >= pos) {
      if (!(st[k] & v)) return -1;
      if (s + 1 == e) return s;
    }
    int m = (s + e) / 2;
    int ans = query(2 * k, s, m, pos, v);
    if (ans == -1) ans = query(2 * k + 1, m, e, pos, v);
    return ans;
  }
  void upd(int p, int v) { upd(1, 0, n, p, v); }
  int query(int a, int b) { return query(1, 0, n, a, b); }
};
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;
    STree st(n);
    for (int i = 0, ThxDem = n; i < ThxDem; ++i) st.upd(i, 1 << (s[i] == ')'));
    cout << n << "\n";
    for (int i = 0, ThxDem = n; i < ThxDem; ++i) {
      int wh = st.query(i, 1 << a[i]);
      swap(s[i], s[wh]);
      st.upd(i, 1 << (s[i] == ')'));
      st.upd(wh, 1 << (s[wh] == ')'));
      cout << i + 1 << " " << wh + 1 << "\n";
    }
  }
}
