#include <bits/stdc++.h>
using namespace std;
char bracket;
int n[2010];
int T, N, K, p;
vector<int> regClose;
vector<int> irregs;
vector<int> swaps;
int nextClose(int open) {
  int b = open;
  while (n[b] != -1) {
    b++;
  }
  return b;
}
int main() {
  scanf("%d", &T);
  for (int t = 1; t <= T; t++) {
    scanf("%d %d", &N, &K);
    for (int j = 1; j < N + 1; j++) {
      scanf(" %c", &bracket);
      if (bracket == '(') n[j] = 1;
      if (bracket == ')') n[j] = -1;
    }
    p = 0;
    for (int j = 1; j < N + 1; j++) {
      p += n[j];
      if (p == 0) {
        regClose.push_back(j);
        if (irregs.size() % 2 == 1) irregs.push_back(j);
      }
      if (p < 0) {
        if (irregs.size() % 2 == 0) irregs.push_back(j);
      }
    }
    swaps = irregs;
    for (int j = 0; j < irregs.size(); j++) {
      if (j % 2 == 1) continue;
      reverse(begin(n) + irregs[j], begin(n) + irregs[j + 1] + 1);
    }
    if (regClose.size() > K) {
      int d = regClose.size() - K;
      for (int l = 0; l < d; l++) {
        swaps.push_back(regClose[l]);
        swaps.push_back(regClose[l] + 1);
        reverse(begin(n) + regClose[l], begin(n) + regClose[l] + 2);
      }
    }
    if (regClose.size() < K) {
      int d = K - regClose.size();
      int p = 0;
      for (int j = 1; j < N + 1; j++) {
        if (d == 0) break;
        p += n[j];
        if (p == 2) {
          swaps.push_back(j);
          swaps.push_back(nextClose(j));
          reverse(begin(n) + j, begin(n) + nextClose(j) + 1);
          p = 0;
          d--;
        }
      }
    }
    printf("%lu\n", swaps.size() / 2);
    for (int j = 0; j < swaps.size(); j++) {
      if (j % 2 == 1) continue;
      printf("%d %d\n", swaps[j], swaps[j + 1]);
    }
    swaps.clear();
    irregs.clear();
    regClose.clear();
  }
}
