#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > ans;
inline void solve(int n, int k, string s) {
  if (k != 1) {
    if (s.back() == ')') {
      int t;
      for (t = s.size() - 2; t > -1; --t)
        if (s[t] == '(') break;
      ans.push_back({t + 1, s.size() - 1});
      swap(s[t], s[s.size() - 2]);
      s.pop_back();
      s.pop_back();
      solve(n - 2, k - 1, s);
    } else {
      int t;
      for (t = s.size() - 2; t > -1; --t)
        if (s[t] == ')') break;
      ans.push_back({t + 1, s.size()});
      swap(s[t], s[s.size() - 1]);
      s.pop_back();
      s.pop_back();
      solve(n - 2, k - 1, s);
    }
    return;
  }
  int last = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == '(') {
      ans.push_back({last + 1, i + 1});
      ++last;
    }
  }
}
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    solve(n, k, s);
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); ++i)
      cout << ans[i].first << " " << ans[i].second << endl;
    ans.clear();
  }
}
