#include <bits/stdc++.h>
using namespace std;
void print() { cout << "\n"; }
template <typename T, typename... Types>
void print(T arg, Types... args) {
  cout << arg << " ";
  print(args...);
}
const int mod = 1e9 + 7;
const int N = 2e5 + 7;
long long gcdExtended(long long a, long long b, long long *x, long long *y) {
  if (a == 0) {
    *x = 0, *y = 1;
    return b;
  }
  long long x1, y1;
  long long gcd = gcdExtended(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
long long modInv(long long a, long long m) {
  long long x, y;
  long long g = gcdExtended(a, m, &x, &y);
  long long res = (x % m + m) % m;
  return res;
}
long long mpower(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long power(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = res * x;
    y = y >> 1;
    x = x * x;
  }
  return res;
}
bool isPrime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  long long p = sqrt(n);
  for (int i = 5; i <= p; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int tc = 1;
  cin >> tc;
  while (tc--) {
    int n, k, p;
    string s, t;
    cin >> n >> k;
    cin >> s;
    p = n / 2;
    for (int i = 0; i < k - 1; i++) {
      t += "()";
    }
    for (int i = 0; i < p - k + 1; i++) t += '(';
    for (int i = 0; i < p - k + 1; i++) t += ')';
    std::vector<int> open, close;
    for (int i = 0; i < n; i++) {
      if (s[i] != t[i]) {
        if (s[i] == '(')
          open.push_back(i);
        else
          close.push_back(i);
      }
    }
    vector<pair<int, int> > res;
    int l = open.size();
    int x, y;
    for (int i = 0; i < l; i++) {
      x = open[i], y = close[i];
      if (x > y) swap(x, y);
      res.push_back({x, y});
      if (y - x > 2) {
        res.push_back({x + 1, y - 1});
      }
    }
    l = res.size();
    cout << l << "\n";
    for (auto i : res) {
      cout << (i.first + 1) << " " << (i.second + 1) << "\n";
    }
  }
  return 0;
}
