#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int itest;
  cin >> itest;
  while (itest--) {
    int n;
    cin >> n;
    int k;
    cin >> k;
    vector<pair<int, int> > res;
    auto change = [&](int i, int j) {
      if (i > j) swap(i, j);
      if (i < j) res.push_back(pair<int, int>(i, j));
      if (i + 2 < j) res.push_back(pair<int, int>(i + 1, j - 1));
    };
    priority_queue<int, vector<int>, greater<int> > pq[2];
    for (int i = 1; i <= n; ++i) {
      char c;
      cin >> c;
      pq[c == '('].push(i);
    }
    for (int i = 1; i < k; ++i) {
      int a = pq[1].top();
      pq[1].pop();
      if (a != 2 * i - 1) {
        change(a, 2 * i - 1);
        pq[0].pop();
        pq[0].push(a);
      }
      int b = pq[0].top();
      pq[0].pop();
      if (b != 2 * i) {
        change(b, 2 * i);
        pq[1].pop();
        pq[1].push(b);
      }
    }
    for (int i = 2 * k - 1; i < n / 2 + k; ++i) {
      int a = pq[1].top();
      pq[1].pop();
      if (a != i) change(a, i);
    }
    cout << res.size() << "\n";
    for (pair<int, int> kk : res) cout << kk.first << " " << kk.second << "\n";
  }
}
