#include <bits/stdc++.h>
using namespace std;
void solve() {
  unsigned long long T;
  cin >> T;
  while (T--) {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    set<int> open, close;
    for (int i = 0; i < n; i++) {
      if (s[i] == '(')
        open.insert(i);
      else
        close.insert(i);
    }
    int last = 0;
    vector<pair<int, int> > ans;
    for (int i = 0; i < n && k > 1; i++, last++) {
      if (i & 1) {
        if (s[i] != ')') {
          int pos = *close.lower_bound(i);
          ans.push_back({i, pos});
          close.erase(pos), open.insert(pos), s[pos] = '(';
        }
        k--;
      } else {
        if (s[i] != '(') {
          int pos = *open.lower_bound(i);
          ans.push_back({i, pos});
          open.erase(pos), close.insert(pos), s[pos] = ')';
        }
      }
    }
    int x = (n - last) / 2;
    for (int i = last; i < last + x; i++) {
      if (s[i] != '(') {
        int pos = *open.lower_bound(i);
        ans.push_back({i, pos});
        open.erase(pos), close.insert(pos), s[pos] = ')';
      }
    }
    cout << ans.size() << "\n";
    for (int i = 0; i < ans.size(); i++) {
      cout << ans[i].first + 1 << " " << ans[i].second + 1 << "\n";
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  solve();
  return 0;
}
