#include <bits/stdc++.h>
using namespace std;
template <typename T>
istream& operator>>(istream& is, vector<T>& a) {
  for (T& ai : a) is >> ai;
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> const& a) {
  os << "[ ";
  for (const T& ai : a) os << ai << " ";
  return os << "]";
}
template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& a) {
  return is >> a.first >> a.second;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2> const& a) {
  return os << "(" << a.first << ", " << a.second << ")";
}
void f() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  string t(n, ' ');
  for (int i = 0; i < k - 1; ++i) {
    t[2 * i] = '(';
    t[2 * i + 1] = ')';
  }
  for (int i = 2 * (k - 1), j = n - 1; i < j; ++i, --j) {
    t[i] = '(';
    t[j] = ')';
  }
  vector<pair<int, int> > r;
  for (int i = 0, a = 0, b = 0; i < n; ++i) {
    if (s[i] == t[i]) continue;
    if (s[i] == '(') {
      a = max(a, i);
      while (s[a] == '(') ++a;
      swap(s[i], s[a]);
      r.emplace_back(i + 1, a + 1);
    } else {
      b = max(b, i);
      while (s[b] == ')') ++b;
      swap(s[i], s[b]);
      r.emplace_back(i + 1, b + 1);
    }
  }
  cout << r.size() << "\n";
  for (const pair<int, int>& ri : r)
    cout << ri.first << " " << ri.second << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) f();
  return 0;
}
