#include <bits/stdc++.h>
using namespace std;
vector<int> v, pre, l, r;
int xcount() {
  int ans = 0;
  for (int i = 1; i < pre.size(); ++i)
    if (pre[i] == 0) ++ans;
  return ans;
}
void decrease() {
  int pos = 0;
  for (int i = 1; i < v.size(); ++i)
    if (pre[i] == 0) {
      pos = i;
      break;
    }
  swap(v[pos], v[pos + 1]);
  l.push_back(pos);
  r.push_back(pos + 1);
  for (int i = pos; i < v.size(); ++i) pre[i] = pre[i - 1] + v[i];
}
void increase() {
  int mx = -10, pos = 0, pos2 = 0;
  for (int i = 1; i < pre.size(); ++i)
    if (pre[i] == 2) {
      pos = i;
      break;
    }
  for (int i = pos + 1; i < v.size(); ++i)
    if (v[i] == -1) {
      pos2 = i;
      break;
    }
  swap(v[pos], v[pos2]);
  if (pos != pos2) {
    l.push_back(pos);
    r.push_back(pos2);
  }
  for (int i = pos; i < pre.size(); ++i) pre[i] = pre[i - 1] + v[i];
}
bool correct() {
  for (int i = 1; i < v.size(); ++i) {
    if (pre[i] < 0) {
      for (int j = i + 1; j < v.size(); ++j)
        if (v[j] == 1) {
          swap(v[i], v[j]);
          l.push_back(i);
          r.push_back(j);
          break;
        }
      for (int j = i; j < v.size(); ++j) pre[j] = pre[j - 1] + v[j];
      return false;
    }
  }
  return true;
}
int main() {
  int t, n, k;
  char tmp;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    v = pre = vector<int>(n + 1);
    l.clear();
    r.clear();
    for (int i = 1; i <= n; ++i) {
      cin >> tmp;
      if (tmp == '(')
        v[i] = 1;
      else
        v[i] = -1;
      pre[i] = pre[i - 1] + v[i];
    }
    while (!correct())
      ;
    int tmp = xcount();
    while (tmp > k) {
      decrease();
      --tmp;
    }
    while (tmp < k) {
      increase();
      ++tmp;
    }
    cout << l.size() << '\n';
    for (int i = 0; i < l.size(); ++i) cout << l[i] << " " << r[i] << '\n';
  }
  return 0;
}
