#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<pair<int, int> > ans;
    int pos = 0;
    while (k > 1) {
      int i = pos + 1;
      for (; i < n; ++i) {
        if (s[i] != s[i - 1]) {
          break;
        }
      }
      ans.push_back(make_pair((pos), (i)));
      reverse(s.begin() + pos, s.begin() + i + 1);
      if (s[pos] == ')') {
        swap(s[pos], s[pos + 1]);
        ans.push_back(make_pair((pos), (pos + 1)));
      }
      pos += 2;
      k--;
    }
    k = 0;
    for (int i = pos; i < n; ++i) {
      if (s[i] == '(') {
        ans.push_back(make_pair((pos + k), (i)));
        k++;
      }
    }
    cout << ans.size() << '\n';
    for (auto e : ans) {
      cout << e.first + 1 << ' ' << e.second + 1 << '\n';
    }
  }
  return 0;
}
