#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define pii pair<ll,ll>
#define ppi pair<pii,ll>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);

    int n,t,k,i,j;
    cin>>t;
    string s,temp;
    while(t--){
        vector<pii>ans;
        cin>>n>>k;
        cin>>s;
        int o,c;
        c=o=0;

        stack<char>par;
        for(i=0;i<n;i++){
            if(s[i]==')'){

                for(j=i+1;j<n;j++){
                    if(s[j]=='('){
                        //if(j==i+1){;break;}
                        reverse(s.begin()+i,s.begin()+j+1);
                        ans.push_back(make_pair(i+1,j+1));
                      //  i++;
                        break;
                    }
                }
            }
            else{
                for(j=i+1;j<n;j++){

                    if(s[j]==')'){
                        if(i+1==j){i++;break;}
                        reverse(s.begin()+i+1,s.begin()+j+1);
                        ans.push_back(make_pair(i+1,j+1));
                         i++;
                        break;
                    }
                }
            }
        }
      //  cout<<s<<endl;

//        for(i=0;i<n;i++){
//            if(s[i]=='(')
//                par.push('(');
//            else if(!par.empty()){
//                par.pop();
//            }
//            else{
//                for(j=i;j<n;j++){
//                    if(s[j]=='(')o++;
//                    else c++;
//                    if(o==c){
//                        reverse(s.begin()+i,s.begin()+j+1);
//                        ans.push_back(make_pair(i+1,j+1));
//                        i=j;
//                        break;
//                    }
//                }
//            }
//        }
//        while(!par.empty()){
//            par.pop();
//        }
//        j=0;
//        int l=n/2;
//        for(i=0;;i++){
//            if(i==n){
//                j=0;
//                i=0;
//                while(!par.empty())par.pop();
//            }
//            if(s[i]=='(')par.push(s[i]);
//            else{
//                par.pop();
//                if(par.empty()){
//                     //if(i==n-1)continue;
//                    j++;
//                }
//                else{
//                    if(par.size()==1){
//                        j++;
//                    }
//                    reverse(s.begin()+i-1,s.begin()+i+1);
//                    ans.push_back(make_pair(i,i+1));
//
//                }
//            }
//            //cout<<j<<" "<<i<<endl;
//            if(j==l)break;
//        }
        j=0;

        for(i=0;i<n;i++){
            if(s[i]=='(')par.push(s[i]);
            else par.pop();
            if(par.empty())j++;
            if(j>k){
                j--;
                reverse(s.begin()+i-2,s.begin()+i);
                ans.push_back(make_pair(i-1,i));
            }
        }

        cout<<ans.size()<<endl;
        for(i=0;i<ans.size();i++){
            cout<<ans[i].first<<" "<<ans[i].second<<endl;
        }

    }

    return 0;
}
/*
1
10 5
((((()))))
*/


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define pii pair<ll,ll>
#define ppi pair<pii,ll>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);

    int n,t,k,i,j;
    cin>>t;
    string s,temp;
    while(t--){
        vector<pii>ans;
        cin>>n>>k;
        cin>>s;

        stack<char>par;

        for(i=0;i<n;i++){
            if(s[i]=='('){
                for(j=i+1;j<n;j++){
                    if(s[j]==')'){
                        if(j==i+1){
                            i++;
                            break;
                        }
                        i++;
                        reverse(s.begin()+i,s.begin()+j+1);
                        ans.push_back(make_pair(i+1,j+1));
                        break;
                    }
                }
            }
            else{
                for(j=i+1;j<n;j++){
                    if(s[j]=='('){
                        reverse(s.begin()+i,s.begin()+j+1);
                        ans.push_back(make_pair(i+1,j+1));
                        i++;
                        break;
                    }
                }
            }
        }
        //cout<<s<<endl;
        j=n/2;
        for(i=2;i<n;i+=2){
            if(j==k)break;
            reverse(s.begin()+i-1,s.begin()+i+1);
            ans.push_back(make_pair(i,i+1));
            j--;
        }
      //  cout<<s<<endl;
        cout<<ans.size()<<endl;
        for(i=0;i<ans.size();i++){
            cout<<ans[i].first<<" "<<ans[i].second<<endl;
        }

    }

    return 0;
}
/*
1
10 5
((((()))))
*/


#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound
    #define ub upper_bound
    #define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define mi          map<int,int>
    #define mii         map<pi,int>
	#define vi vector<int>
	#define vvi vector<vi>
    #define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size()
	#define PI 3.14159265358979323846

	 const int N =2e5+5;

     int mod= 1e9+7;
     int dx[4]={0,0,+1,-1};
     int dy[4]={+1,-1,0,0};

    void solve() {
	    int n,m;
	    cin>>n>>m;
	    string s;
	    cin>>s;

	    string p="";
	    int n1=n-2*m;
	    rep(i,0,m-1)
	      p+="()";
	    rep1(i,0,n1/2) p+='(';
	    rep1(i,0,n1/2) p+=')';

	    //~ cout<<p<<endl;

	    vector<pi> vp;
	   rep(i,0,n) {
		   if(s[i]!=p[i]) {
			   cout<<i;
		     rep(j,i,n) {
				   if(p[i]==s[j]) {
					   cout<<" "<<j<<endl;
					     vp.pb({i+1,j+1});
					     reverse(s.begin()+i,s.begin()+j+1);
					     //~ cout<<s<<endl;
					     break;
					   }
				 }
			 }
		   }
		   //~ cout<<s<<endl;

		   cout<<sz(vp)<<endl;
		   for(auto to:vp)
		     cout<<to.fe<<" "<<to.se<<endl;

     }

	int32_t main() {
	  cool;
	  int t=1;
       cin>>t;

	  while (t--)
		 solve();

	  return 0;
	}


#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound
    #define ub upper_bound
    #define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define mi          map<int,int>
    #define mii         map<pi,int>
	#define vi vector<int>
	#define vvi vector<vi>
    #define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size()
	#define PI 3.14159265358979323846

	 const int N =2e5+5;

     int mod= 1e9+7;
     int dx[4]={0,0,+1,-1};
     int dy[4]={+1,-1,0,0};

    void solve() {
	    int n,m;
	    cin>>n>>m;
	    string s;
	    cin>>s;

	    string p="";
	    int n1=n-2*m;
	    rep(i,0,m-1)
	      p+="()";
	    rep1(i,0,n1/2) p+='(';
	    rep1(i,0,n1/2) p+=')';

	    //~ cout<<p<<endl;

	    vector<pi> vp;
	   rep(i,0,n) {
		   if(s[i]!=p[i]) {
		     rep(j,i,n) {
				   if(p[j]==s[i]) {
					     vp.pb({i+1,j+1});
					     reverse(s.begin()+i,s.begin()+j);
					   }
				 }
			 }
		   }
		   //~ cout<<s<<endl;

		   cout<<sz(vp)<<endl;
		   for(auto to:vp)
		     cout<<to.fe<<" "<<to.se<<endl;

     }

	int32_t main() {
	  cool;
	  int t=1;
       cin>>t;

	  while (t--)
		 solve();

	  return 0;
	}


#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound
    #define ub upper_bound
    #define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define mi          map<int,int>
    #define mii         map<pi,int>
	#define vi vector<int>
	#define vvi vector<vi>
    #define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size()
	#define PI 3.14159265358979323846

	 const int N =2e5+5;

     int mod= 1e9+7;
     int dx[4]={0,0,+1,-1};
     int dy[4]={+1,-1,0,0};

    void solve() {
	    int n,m;
	    cin>>n>>m;
	    string s;
	    cin>>s;

	    string p="";
	    int n1=n-2*m;
	    rep(i,0,m-1)
	      p+="()";
	    rep1(i,0,n1/2) p+='(';
	    rep1(i,0,n1/2) p+=')';

	    //~ cout<<p<<endl;

	    vector<pi> vp;
	   rep(i,0,n) {
		   if(s[i]!=p[i]) {
			   //~ cout<<i;
		     rep(j,i,n) {
				   if(p[i]==s[j]) {
					   //~ cout<<" "<<j<<endl;
					     vp.pb({i+1,j+1});
					     reverse(s.begin()+i,s.begin()+j+1);
					     //~ cout<<s<<endl;
					     break;
					   }
				 }
			 }
		   }
		   //~ cout<<s<<endl;

		   cout<<sz(vp)<<endl;
		   for(auto to:vp)
		     cout<<to.fe<<" "<<to.se<<endl;

     }

	int32_t main() {
	  cool;
	  int t=1;
       cin>>t;

	  while (t--)
		 solve();

	  return 0;
	}


#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound
    #define ub upper_bound
    #define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define mi          map<int,int>
    #define mii         map<pi,int>
	#define vi vector<int>
	#define vvi vector<vi>
    #define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size()
	#define PI 3.14159265358979323846

	 const int N =2e5+5;

     int mod= 1e9+7;
     int dx[4]={0,0,+1,-1};
     int dy[4]={+1,-1,0,0};

    void solve() {
	    int n,m;
	    cin>>n>>m;
	    string s;
	    cin>>s;

	    string p="";
	    int n1=n-2*m;
	    rep(i,0,m-1)
	      p+="()";
	    rep1(i,0,n1/2) p+='(';
	    rep1(i,0,n1/2) p+=')';

	    //~ cout<<p<<endl;

	    vector<pi> vp;
	   rep(i,0,n) {
		   if(s[i]!=p[i]) {
		     rep(j,i,n) {
				   if(p[i]==s[j]) {
					     vp.pb({i+1,j+1});
					     reverse(s.begin()+i,s.begin()+j);
					     break;
					   }
				 }
			 }
		   }
		   //~ cout<<s<<endl;

		   cout<<sz(vp)<<endl;
		   for(auto to:vp)
		     cout<<to.fe<<" "<<to.se<<endl;

     }

	int32_t main() {
	  cool;
	  int t=1;
       cin>>t;

	  while (t--)
		 solve();

	  return 0;
	}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;

typedef tree<pair<long long,int>, null_type, less<pair<long long,int>>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(num) num.begin(), num.end()
#define lp(i, nodess) for (int i = 0; i < nodess; i++)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define X real()
#define Y imag()
#define angle(u) (atan2(u.Y, u.X))
#define vec(u, v) ((v) - (u))
//#define length(u) (hypot(u.Y , u.X))
#define normalize(u) (u) / length(u)
#define dotP(u, v) ((conj(u) * v).X)
#define crossP(u, v) ((conj(u) * v).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(u) dotP(u, u)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(vis, m) conj(vis / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll nodess, ll num) {
  if (!num)
    return 1;
  if (num % 2)
    return nodess * fastpow(nodess, num - 1)/*%mod*/;
  ll p = fastpow(nodess, num / 2);
 // p %= mod;
  p *= p;
 // p %= mod;
  return p;
}

ll my_mod(ll num, ll mod) {
  ll reto = num % mod;
  while (reto < 0)
    reto += mod;
  return reto;
}

ll gcd(ll u, ll v) { return !u ? v : gcd(v % u, u); }
long long dist(pair<ll, ll> u, pair<ll, ll> v) {
  return
      abs(u.f - v.f)  + abs(u.se - v.se);
}

/*vector<int> ap;
int np[MX+5];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <=MX; j+=i) np[j] = 0;
        }
    }
    int idx = 1;
    for(ll i = 2 ; i<= MX ; i++){
		if(np[i]){
			np[i] = idx;
			idx++;
			ap.pb(i);
		}
	}
	//cout<<idx;
}*/

const int MX= 1e5+9;
int32_t main()
{
    IO;
	int tc;
	cin>>tc;
	while(tc--){
		int n,k;
		cin>>n>>k;
		string s;
		cin>>s;
		int cnt = 0;
		int st =  -1;
		vector<pair<int,int> > ans;
		for(int i= 0; i < n; i++){
			int prv = cnt;
			if(s[i] == '(') cnt++;
			if(s[i] == ')') cnt--;
			if(cnt == -1 && prv == 0) st = i;
			if(cnt == 0 && st != -1){
				//cout<<"Swapped: "<<st<<" "<<i<<"\n";
				ans.pb({st+1, i+1});
				reverse(s.begin() + st, s.begin() + i +1);
			}
		}
		//cout<<s<<"\n";
		int c = 0;
		while( c!= k){
			cnt = 0;
			c = 0;
			for(int i= 0; i < n ;i++){
				if(s[i] == ')') cnt--;
				if(s[i] == '(') cnt++;
				if(cnt == 0) c++;
			}
			//cout<<c<<" "<<s<<"\n";
			if(c < k){
				for(int i= 0; i < n - 1; i++){
					if(s[i] =='(' && s[i+1] == ')'){
						int j = i;
						while(j >= 0 && s[j] == '(')j--;
						j++;
						int cc = i-j+1;
						if(cc == 1) continue;
						reverse(s.begin() + j+1, s.begin()+i+2);
						//cout<<"Swapped: "<<j+1<<" "<<i+1<<"\n";
						ans.pb({j+1+1, i+2});
						break;
					}
				}
			}else if(c >k){
				for(int i= 0; i < n - 1; i++){
					if(s[i] ==')' && s[i+1] == '('){
						int j = i;
						while(j >= 0 && s[j] == ')')j--;
						int cc = i-j+1;
						if(cc == 1) continue;
						reverse(s.begin() + j+1, s.begin()+i+2);
						//cout<<"Swapped**: "<<cc<<" "<<j+1<<" "<<i+1<<"\n";
						ans.pb({j+1+1, i+2});
						break;
					}
				}
			}
		}
		//cout<<s<<"\n";
		cout<<ans.size()<<"\n";
		for(auto &it : ans) cout<<it.f<<" "<<it.se<<"\n";
	}

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;

typedef tree<pair<long long,int>, null_type, less<pair<long long,int>>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(num) num.begin(), num.end()
#define lp(i, nodess) for (int i = 0; i < nodess; i++)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define X real()
#define Y imag()
#define angle(u) (atan2(u.Y, u.X))
#define vec(u, v) ((v) - (u))
//#define length(u) (hypot(u.Y , u.X))
#define normalize(u) (u) / length(u)
#define dotP(u, v) ((conj(u) * v).X)
#define crossP(u, v) ((conj(u) * v).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(u) dotP(u, u)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(vis, m) conj(vis / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll nodess, ll num) {
  if (!num)
    return 1;
  if (num % 2)
    return nodess * fastpow(nodess, num - 1)/*%mod*/;
  ll p = fastpow(nodess, num / 2);
 // p %= mod;
  p *= p;
 // p %= mod;
  return p;
}

ll my_mod(ll num, ll mod) {
  ll reto = num % mod;
  while (reto < 0)
    reto += mod;
  return reto;
}

ll gcd(ll u, ll v) { return !u ? v : gcd(v % u, u); }
long long dist(pair<ll, ll> u, pair<ll, ll> v) {
  return
      abs(u.f - v.f)  + abs(u.se - v.se);
}

/*vector<int> ap;
int np[MX+5];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <=MX; j+=i) np[j] = 0;
        }
    }
    int idx = 1;
    for(ll i = 2 ; i<= MX ; i++){
		if(np[i]){
			np[i] = idx;
			idx++;
			ap.pb(i);
		}
	}
	//cout<<idx;
}*/

const int MX= 1e5+9;
int32_t main()
{
    IO;
	int tc;
	cin>>tc;
	while(tc--){
		int n,k;
		cin>>n>>k;

		string s;
		cin>>s;
		/*for(int i = 0; i < n/2; i++){
				s+= "(";
		}
		for(int i = 0; i < n/2; i++){
				s+= ")";
		}*/

		int cnt = 0;
		int st =  -1;
		vector<pair<int,int> > ans;
		for(int i= 0; i < n; i++){
			int prv = cnt;
			if(s[i] == '(') cnt++;
			if(s[i] == ')') cnt--;
			if(cnt == -1 && prv == 0) st = i;
			if(cnt == 0 && st != -1){
				//cout<<"Swapped: "<<st<<" "<<i<<"\n";
				ans.pb({st+1, i+1});
				reverse(s.begin() + st, s.begin() + i +1);
			}
		}
		//cout<<s<<"\n";
		int c = 0;
		while( c!= k){
			cnt = 0;
			c = 0;
			for(int i= 0; i < n ;i++){
				if(s[i] == ')') cnt--;
				if(s[i] == '(') cnt++;
				if(cnt == 0) c++;
			}
			//cout<<c<<" "<<s<<"\n";
			if(c < k){
				for(int i= 0; i < n - 1 && c < k; i++){
					if(s[i] =='(' && s[i+1] == ')'){
						int j = i;
						while(j >= 0 && s[j] == '(')j--;
						j++;
						int cc = i-j+1;
						if(cc == 1) continue;
						reverse(s.begin() + j+1, s.begin()+i+2);
						//cout<<"Swapped: "<<j+1<<" "<<i+1<<"\n";
						ans.pb({j+1+1, i+2});
						c++;
					}
				}
			}else if(c >k){
				for(int i= 0; i < n - 1 && c>k; i++){
					if(s[i] ==')' && s[i+1] == '('){
						int j = i;
						while(j >= 0 && s[j] == ')')j--;
						int cc = i-j+1;
						if(cc == 1) continue;
						reverse(s.begin() + j+1, s.begin()+i+2);
						//cout<<"Swapped**: "<<cc<<" "<<j+1<<" "<<i+1<<"\n";
						ans.pb({j+1+1, i+2});
						c--;
					}
				}
			}
		}
		//cout<<s<<"\n";
		cout<<ans.size()<<"\n";
		for(auto &it : ans) cout<<it.f<<" "<<it.se<<"\n";
	}

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;

typedef tree<pair<long long,int>, null_type, less<pair<long long,int>>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(num) num.begin(), num.end()
#define lp(i, nodess) for (int i = 0; i < nodess; i++)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define X real()
#define Y imag()
#define angle(u) (atan2(u.Y, u.X))
#define vec(u, v) ((v) - (u))
//#define length(u) (hypot(u.Y , u.X))
#define normalize(u) (u) / length(u)
#define dotP(u, v) ((conj(u) * v).X)
#define crossP(u, v) ((conj(u) * v).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(u) dotP(u, u)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(vis, m) conj(vis / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll nodess, ll num) {
  if (!num)
    return 1;
  if (num % 2)
    return nodess * fastpow(nodess, num - 1)/*%mod*/;
  ll p = fastpow(nodess, num / 2);
 // p %= mod;
  p *= p;
 // p %= mod;
  return p;
}

ll my_mod(ll num, ll mod) {
  ll reto = num % mod;
  while (reto < 0)
    reto += mod;
  return reto;
}

ll gcd(ll u, ll v) { return !u ? v : gcd(v % u, u); }
long long dist(pair<ll, ll> u, pair<ll, ll> v) {
  return
      abs(u.f - v.f)  + abs(u.se - v.se);
}

/*vector<int> ap;
int np[MX+5];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <=MX; j+=i) np[j] = 0;
        }
    }
    int idx = 1;
    for(ll i = 2 ; i<= MX ; i++){
		if(np[i]){
			np[i] = idx;
			idx++;
			ap.pb(i);
		}
	}
	//cout<<idx;
}*/

const int MX= 1e5+9;
int32_t main()
{
    IO;
	int tc;
	cin>>tc;
//	tc = 1;
	/*auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 mt_rand(seed);*/
	while(tc--){
		int n,k;
		cin>>n>>k;
		/*n = 8;
		k = 4;*/
		string s;
		cin>>s;
		/*for(int i = 0; i < n/2; i++){
				s+= "(";
		}
		for(int i = 0; i < n/2; i++){
				s+= ")";
		}
		shuffle(all(s),mt_rand);
		ofstream out("output.txt", std::ios_base::app);
		out<<s<<"\n";*/
		/*
		 *
1
10 5
))(())(()(
*/
		int cnt = 0;
		int st =  -1;
		vector<pair<int,int> > ans;
		for(int i= 0; i < n; i++){
			int prv = cnt;
			if(s[i] == '(') cnt++;
			if(s[i] == ')') cnt--;
			if(cnt == -1 && prv == 0) st = i;
			if(cnt == 0 && st != -1){
				//cout<<"Swapped: "<<st<<" "<<i<<"\n";
				ans.pb({st+1, i+1});
				reverse(s.begin() + st, s.begin() + i +1);
				st = -1;
			}
		}
		//cout<<os<<"\n";
		int c = 0;
		while( c!= k ){
			cnt = 0;
			c = 0;
			for(int i= 0; i < n ;i++){
				if(s[i] == ')') cnt--;
				if(s[i] == '(') cnt++;
				if(cnt == 0) c++;
			}
			//cout<<c<<" "<<os<<"\n";
			if(c < k){
				for(int i= 0; i < n - 1 && c < k; i++){
					if(s[i] =='(' && s[i+1] == ')'){
						int j = i;
						while(j >= 0 && s[j] == '(')j--;
						j++;
						int cc = i-j+1;
					//	cout<<cc<<"\n";
						if(cc == 1) continue;
						reverse(s.begin() + j+1, s.begin()+i+2);
						//cout<<"Swapped: "<<j+1<<" "<<i+1<<"\n";
						ans.pb({j+1+1, i+2});
						c++;
					}
				}
			}else if(c >k){
				for(int i= 0; i < n - 1 && c>k; i++){
					if(s[i] ==')' && s[i+1] == '('){
						int j = i;
						while(j >= 0 && s[j] == ')')j--;
						int cc = i-j+1;
						if(cc == 1) continue;
						reverse(s.begin() + j+1, s.begin()+i+2);
						//cout<<"Swapped**: "<<cc<<" "<<j+1<<" "<<i+1<<"\n";
						ans.pb({j+1+1, i+2});
						c--;
					}
				}
			}
		}
		//cout<<s<<"\n";
		cout<<ans.size()<<"\n";
		for(auto &it : ans) cout<<it.f<<" "<<it.se<<"\n";
	}

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;

typedef tree<pair<long long,int>, null_type, less<pair<long long,int>>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(num) num.begin(), num.end()
#define lp(i, nodess) for (int i = 0; i < nodess; i++)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define X real()
#define Y imag()
#define angle(u) (atan2(u.Y, u.X))
#define vec(u, v) ((v) - (u))
//#define length(u) (hypot(u.Y , u.X))
#define normalize(u) (u) / length(u)
#define dotP(u, v) ((conj(u) * v).X)
#define crossP(u, v) ((conj(u) * v).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(u) dotP(u, u)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(vis, m) conj(vis / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll nodess, ll num) {
  if (!num)
    return 1;
  if (num % 2)
    return nodess * fastpow(nodess, num - 1)/*%mod*/;
  ll p = fastpow(nodess, num / 2);
 // p %= mod;
  p *= p;
 // p %= mod;
  return p;
}

ll my_mod(ll num, ll mod) {
  ll reto = num % mod;
  while (reto < 0)
    reto += mod;
  return reto;
}

ll gcd(ll u, ll v) { return !u ? v : gcd(v % u, u); }
long long dist(pair<ll, ll> u, pair<ll, ll> v) {
  return
      abs(u.f - v.f)  + abs(u.se - v.se);
}

/*vector<int> ap;
int np[MX+5];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <=MX; j+=i) np[j] = 0;
        }
    }
    int idx = 1;
    for(ll i = 2 ; i<= MX ; i++){
		if(np[i]){
			np[i] = idx;
			idx++;
			ap.pb(i);
		}
	}
	//cout<<idx;
}*/

const int MX= 1e5+9;
int32_t main()
{
    IO;
	int tc;
	cin>>tc;
	while(tc--){
		int n,k;
		cin>>n>>k;
		string s;
		cin>>s;
		int cnt = 0;
		int st =  -1;
		vector<pair<int,int> > ans;
		for(int i= 0; i < n; i++){
			int prv = cnt;
			if(s[i] == '(') cnt++;
			if(s[i] == ')') cnt--;
			if(cnt == -1 && prv == 0) st = i;
			if(cnt == 0 && st != -1){
				//cout<<"Swapped: "<<st<<" "<<i<<"\n";
				ans.pb({st+1, i+1});
				reverse(s.begin() + st, s.begin() + i +1);
			}
		}
		//cout<<s<<"\n";
		int c = 0;
		int tt = 10;
		while( c!= k && tt--){
			cnt = 0;
			c = 0;
			for(int i= 0; i < n ;i++){
				if(s[i] == ')') cnt--;
				if(s[i] == '(') cnt++;
				if(cnt == 0) c++;
			}
			//cout<<c<<" "<<s<<"\n";
			if(c < k){
				for(int i= 0; i < n - 1 && c < k; i++){
					if(s[i] =='(' && s[i+1] == ')'){
						int j = i;
						while(j >= 0 && s[j] == '(')j--;
						j++;
						int cc = i-j+1;
						if(cc == 1) continue;
						reverse(s.begin() + j+1, s.begin()+i+2);
						//cout<<"Swapped: "<<j+1<<" "<<i+1<<"\n";
						ans.pb({j+1+1, i+2});
						c++;
					}
				}
			}else if(c >k){
				for(int i= 0; i < n - 1 && c>k; i++){
					if(s[i] ==')' && s[i+1] == '('){
						int j = i;
						while(j >= 0 && s[j] == ')')j--;
						int cc = i-j+1;
						if(cc == 1) continue;
						reverse(s.begin() + j+1, s.begin()+i+2);
						//cout<<"Swapped**: "<<cc<<" "<<j+1<<" "<<i+1<<"\n";
						ans.pb({j+1+1, i+2});
						c--;
					}
				}
			}
		}
		//cout<<s<<"\n";
		cout<<ans.size()<<"\n";
		for(auto &it : ans) cout<<it.f<<" "<<it.se<<"\n";
	}

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;

typedef tree<pair<long long,int>, null_type, less<pair<long long,int>>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(num) num.begin(), num.end()
#define lp(i, nodess) for (int i = 0; i < nodess; i++)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define X real()
#define Y imag()
#define angle(u) (atan2(u.Y, u.X))
#define vec(u, v) ((v) - (u))
//#define length(u) (hypot(u.Y , u.X))
#define normalize(u) (u) / length(u)
#define dotP(u, v) ((conj(u) * v).X)
#define crossP(u, v) ((conj(u) * v).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(u) dotP(u, u)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(vis, m) conj(vis / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll nodess, ll num) {
  if (!num)
    return 1;
  if (num % 2)
    return nodess * fastpow(nodess, num - 1)/*%mod*/;
  ll p = fastpow(nodess, num / 2);
 // p %= mod;
  p *= p;
 // p %= mod;
  return p;
}

ll my_mod(ll num, ll mod) {
  ll reto = num % mod;
  while (reto < 0)
    reto += mod;
  return reto;
}

ll gcd(ll u, ll v) { return !u ? v : gcd(v % u, u); }
long long dist(pair<ll, ll> u, pair<ll, ll> v) {
  return
      abs(u.f - v.f)  + abs(u.se - v.se);
}

/*vector<int> ap;
int np[MX+5];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <=MX; j+=i) np[j] = 0;
        }
    }
    int idx = 1;
    for(ll i = 2 ; i<= MX ; i++){
		if(np[i]){
			np[i] = idx;
			idx++;
			ap.pb(i);
		}
	}
	//cout<<idx;
}*/

const int MX= 1e5+9;
int32_t main()
{
    IO;
	int tc;
	cin>>tc;
//	tc = 1;
	/*auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 mt_rand(seed);*/
	while(tc--){
		int n,k;
		cin>>n>>k;
		/*n = 8;
		k = 4;*/
		string s;
		cin>>s;
		/*for(int i = 0; i < n/2; i++){
				s+= "(";
		}
		for(int i = 0; i < n/2; i++){
				s+= ")";
		}
		shuffle(all(s),mt_rand);
		ofstream out("output.txt", std::ios_base::app);
		out<<s<<"\n";*/
		/*
		 *
1
10 5
))(())(()(
*/
		int cnt = 0;
		int st =  -1;
		vector<pair<int,int> > ans;
		for(int i= 0; i < n; i++){
			int prv = cnt;
			if(s[i] == '(') cnt++;
			if(s[i] == ')') cnt--;
			if(cnt == -1 && prv == 0) st = i;
			if(cnt == 0 && st != -1){
				//cout<<"Swapped: "<<st<<" "<<i<<"\n";
				ans.pb({st+1, i+1});
				reverse(s.begin() + st, s.begin() + i +1);
				st = -1;
			}
		}
		//cout<<os<<"\n";
		int c = 0;
		while( c!= k ){
			cnt = 0;
			c = 0;
			for(int i= 0; i < n ;i++){
				if(s[i] == ')') cnt--;
				if(s[i] == '(') cnt++;
				if(cnt == 0) c++;
			}
			//cout<<c<<" "<<os<<"\n";
			if(c < k){
				for(int i= 0; i < n - 1 && c < k; i++){
					if(s[i] =='(' && s[i+1] == ')'){
						int j = i;
						while(j >= 0 && s[j] == '(')j--;
						j++;
						int cc = i-j+1;
					//	cout<<cc<<"\n";
						if(cc == 1) continue;
						reverse(s.begin() + j+1, s.begin()+i+2);
						//cout<<"Swapped: "<<j+1<<" "<<i+1<<"\n";
						ans.pb({j+1+1, i+2});
						c++;
					}
				}
			}else if(c >k){
				for(int i= 0; i < n - 1 && c>k; i++){
					if(s[i] ==')' && s[i+1] == '('){
						int j = i;
						while(j >= 0 && s[j] == ')')j--;
						int cc = i-j+1;
						if(cc == 1) continue;
						reverse(s.begin() + j+1, s.begin()+i+2);
						//cout<<"Swapped**: "<<cc<<" "<<j+1<<" "<<i+1<<"\n";
						ans.pb({j+1+1, i+2});
						c--;
					}
				}
			}
			c = 0;
			for(int i= 0; i < n ;i++){
				if(s[i] == ')') cnt--;
				if(s[i] == '(') cnt++;
				if(cnt == 0) c++;
			}
		}
		//cout<<s<<"\n";
		cout<<ans.size()<<"\n";
		for(auto &it : ans) cout<<it.f<<" "<<it.se<<"\n";
	}

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;

typedef tree<pair<long long,int>, null_type, less<pair<long long,int>>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(num) num.begin(), num.end()
#define lp(i, nodess) for (int i = 0; i < nodess; i++)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define X real()
#define Y imag()
#define angle(u) (atan2(u.Y, u.X))
#define vec(u, v) ((v) - (u))
//#define length(u) (hypot(u.Y , u.X))
#define normalize(u) (u) / length(u)
#define dotP(u, v) ((conj(u) * v).X)
#define crossP(u, v) ((conj(u) * v).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(u) dotP(u, u)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(vis, m) conj(vis / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll nodess, ll num) {
  if (!num)
    return 1;
  if (num % 2)
    return nodess * fastpow(nodess, num - 1)/*%mod*/;
  ll p = fastpow(nodess, num / 2);
 // p %= mod;
  p *= p;
 // p %= mod;
  return p;
}

ll my_mod(ll num, ll mod) {
  ll reto = num % mod;
  while (reto < 0)
    reto += mod;
  return reto;
}

ll gcd(ll u, ll v) { return !u ? v : gcd(v % u, u); }
long long dist(pair<ll, ll> u, pair<ll, ll> v) {
  return
      abs(u.f - v.f)  + abs(u.se - v.se);
}

/*vector<int> ap;
int np[MX+5];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <=MX; j+=i) np[j] = 0;
        }
    }
    int idx = 1;
    for(ll i = 2 ; i<= MX ; i++){
		if(np[i]){
			np[i] = idx;
			idx++;
			ap.pb(i);
		}
	}
	//cout<<idx;
}*/

const int MX= 1e5+9;
int32_t main()
{
    IO;
	int tc;
	cin>>tc;
//	tc = 1;
	/*auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 mt_rand(seed);*/
	while(tc--){
		int n,k;
		cin>>n>>k;
		/*n = 8;
		k = 4;*/
		string s;
		cin>>s;
		/*for(int i = 0; i < n/2; i++){
				s+= "(";
		}
		for(int i = 0; i < n/2; i++){
				s+= ")";
		}
		shuffle(all(s),mt_rand);
		ofstream out("output.txt", std::ios_base::app);
		out<<s<<"\n";*/
		/*
		 *
1
10 5
))(())(()(
*/
		int cnt = 0;
		int st =  -1;
		vector<pair<int,int> > ans;
		for(int i= 0; i < n; i++){
			int prv = cnt;
			if(s[i] == '(') cnt++;
			if(s[i] == ')') cnt--;
			if(cnt == -1 && prv == 0) st = i;
			if(cnt == 0 && st != -1){
				//cout<<"Swapped: "<<st<<" "<<i<<"\n";
				ans.pb({st+1, i+1});
				reverse(s.begin() + st, s.begin() + i +1);
				st = -1;
			}
		}
		//cout<<os<<"\n";
		int c = 0;
		int tt = 8;
		while( c!= k && tt--){
			cnt = 0;
			c = 0;
			for(int i= 0; i < n ;i++){
				if(s[i] == ')') cnt--;
				if(s[i] == '(') cnt++;
				if(cnt == 0) c++;
			}
			//cout<<c<<" "<<os<<"\n";
			if(c < k){
				for(int i= 0; i < n - 1 && c < k; i++){
					if(s[i] =='(' && s[i+1] == ')'){
						int j = i;
						while(j >= 0 && s[j] == '(')j--;
						j++;
						int cc = i-j+1;
					//	cout<<cc<<"\n";
						if(cc == 1) continue;
						reverse(s.begin() + j+1, s.begin()+i+2);
						//cout<<"Swapped: "<<j+1<<" "<<i+1<<"\n";
						ans.pb({j+1+1, i+2});
						c++;
					}
				}
			}else if(c >k){
				for(int i= 0; i < n - 1 && c>k; i++){
					if(s[i] ==')' && s[i+1] == '('){
						int j = i;
						while(j >= 0 && s[j] == ')')j--;
						int cc = i-j+1;
						if(cc == 1) continue;
						reverse(s.begin() + j+1, s.begin()+i+2);
						//cout<<"Swapped**: "<<cc<<" "<<j+1<<" "<<i+1<<"\n";
						ans.pb({j+1+1, i+2});
						c--;
					}
				}
			}
		}
		//cout<<s<<"\n";
		cout<<ans.size()<<"\n";
		for(auto &it : ans) cout<<it.f<<" "<<it.se<<"\n";
	}

    return 0;
}


#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb(x) push_back(x)

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 1000000009

using namespace std;

bool check(ll n, ll pos)
{
    return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
    return n = n | (1LL << pos);
}

string str;
vector < pll > sw;

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    slld(testcase);

    for(ll cs = 1; cs <= testcase; cs++)
    {
        cin >> n >> k >> str;

        ll mn = 0;

        ll prv = -1;

        string tmp = "";

        ll sum = 0;

        sw.clear();

        for(i = 0; i < n; i++)
        {
            if(str[i] == ')') sum--;
            else sum++;

            if(sum == 0)
            {
                if(mn < 0)
                {
                    for(j = i; j > prv; j--) tmp += str[j];
                    sw.push_back({prv + 2, i + 1});
                }
                else for(j = prv + 1; j <= i; j++) tmp += str[j];

                mn = 0;
                prv = i;
                sum = 0;

            }

            mn = min(mn,sum);
        }

        str = tmp;

//        cout << str << endl;

        tmp = "";

        for(i = 0; i < n; i++)
        {
            if(str[i] == ')')
            {
                tmp = str;

                for(j = i; j < n; j++)
                {
                    if(str[j] == '(') break;
                }

                if(j == n) j--;

                if(i != j)sw.push_back({i + 1, j + 1});
                for(ll jj = i; j >= i; j--, jj++)
                {
                    tmp[jj] = str[j];
                }

                str = tmp;
            }
        }

//        cout << str << endl;

        k--;
        tmp = "";
        bool on = 0;

        for(i = 0; k; i++)
        {
            if(str[i] == '(')
            {
				if(on == 0)
				{
					on = 1;
					continue;
				}

				on = 0;
                k--;
                for(j = i + 1; j < n; j++)
                {
                    if(str[j] == ')') break;
                }

//                cout << i <<  " " << j << " ";

                if(i != j) sw.push_back({i + 1,j + 1});

                tmp = str;

                for(m = i; j >= i; j--, m++)
                {
                    tmp[m] = str[j];
                }

                str = tmp;

//                cout << tmp << endl;
            }
        }

//        cout << str << endl;

        cout << sw.size() << "\n";

		for(auto it: sw) cout << it.first<< " " << it.second << "\n";

    }

}


#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb(x) push_back(x)

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 1000000009

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

string ss, tt;
vector < pll > vv;

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    slld(testcase);

    for(ll cs = 1; cs <= testcase; cs++)
    {
		slld(n);
		slld(k);
		k--;
		cin >> ss;

		vv.clear();

		tt = "";

		for(i = 1; i <= k; i++)
		{
			tt += "()";
		}

		ll diff = ss.size() - tt.size();

		for(i = 1; i <= diff; i++)
		{
			if(i <= (diff/ 2)) tt += '(';
			else tt += ')';
		}

		for(i = 0; i < n; i++)
		{
			if(ss[i] == tt[i]) continue;

			string tmp = ss;

			for(j = i + 1; j < n; j++)
			{
				if(ss[j] == tt[i]) break;
			}

			vv.push_back({i + 1, j + 1});
			for(m = i; j >= i; m++, j--)
			{
				tmp[m] = ss[j];
			}

			ss = tmp;
		}

		cout << vv.size() << "\n";

		for(auto it: vv) cout << it.first << " " << it.second << "\n";

//		cout << ss << endl;
    }

}


#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb(x) push_back(x)

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 1000000009

using namespace std;

bool check(ll n, ll pos)
{
    return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
    return n = n | (1LL << pos);
}

string str;
vector < pll > sw;

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    slld(testcase);

    for(ll cs = 1; cs <= testcase; cs++)
    {
        cin >> n >> k >> str;

        ll mn = 0;

        ll prv = -1;

        string tmp = "";

        ll sum = 0;

        sw.clear();

        for(i = 0; i < n; i++)
        {
            if(str[i] == ')') sum--;
            else sum++;

            if(sum == 0)
            {
                if(mn < 0)
                {
                    for(j = i; j > prv; j--) tmp += str[j];
                    sw.push_back({prv + 2, i + 1});
                }
                else for(j = prv + 1; j <= i; j++) tmp += str[j];

                mn = 0;
                prv = i;
                sum = 0;

            }

            mn = min(mn,sum);
        }

        str = tmp;

//        cout << str << endl;

        tmp = "";

        for(i = 0; i < n; i++)
        {
            if(str[i] == ')')
            {
                tmp = str;

                for(j = i; j < n; j++)
                {
                    if(str[j] == '(') break;
                }

                if(j == n) j--;

                sw.push_back({i + 1, j + 1});
                for(ll jj = i; j >= i; j--, jj++)
                {
                    tmp[jj] = str[j];
                }

                str = tmp;
            }
        }

//        cout << str << endl;

        k--;
        tmp = "";
        bool on = 0;

        for(i = 0; k; i++)
        {
            if(str[i] == '(')
            {
				if(on == 0)
				{
					on = 1;
					continue;
				}

				on = 0;
                k--;
                for(j = i + 1; j < n; j++)
                {
                    if(str[j] == ')') break;
                }

//                cout << i <<  " " << j << " ";

                sw.push_back({i + 1,j + 1});

                tmp = str;

                for(m = i; j >= i; j--, m++)
                {
                    tmp[m] = str[j];
                }

                str = tmp;

//                cout << tmp << endl;
            }
        }

//        cout << str << endl;

        cout << sw.size() << "\n";

		for(auto it: sw) cout << it.first<< " " << it.second << "\n";

    }

}


#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb(x) push_back(x)

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 1000000009

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

string str;
vector < pll > sw;

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    slld(testcase);

    for(ll cs = 1; cs <= testcase; cs++)
    {
		cin >> n >> k >> str;

		ll mn = 0;

		ll prv = -1;

		string tmp = "";

		ll sum = 0;

		sw.clear();

		for(i = 0; i < n; i++)
		{
			if(str[i] == ')') sum--;
			else sum++;

			if(sum == 0)
			{
				if(mn < 0)
				{
					for(j = i; j > prv; j--) tmp += str[j];
					sw.push_back({prv + 2, i + 1});
				}
				else for(j = prv + 1; j <= i; j++) tmp += str[j];

				mn = 0;
				prv = i;
				sum = 0;

			}

			mn = min(mn,sum);
		}

		str = tmp;

//		cout << str << endl;

		tmp = "";

		for(i = 0; i < n; i++)
		{
			if(str[i] == ')')
			{
				tmp = str;

				for(j = i; j < n; j++)
				{
					if(str[j] == '(') break;
				}

				if(j == n) j--;

				sw.push_back({i + 1, j + 1});
				for(ll jj = i; j >= i; j--, jj++)
				{
					tmp[jj] = str[j];
				}

				str = tmp;
			}
		}

		k--;

		for(i = 0, j = (n / 2); j < n && k--; i++, j++)
		{
			sw.push_back({i + 1,j + 1});
		}

		cout << sw.size() << "\n";

		for(auto it: sw) cout << it.first<< " " << it.second << "\n";

    }

}


#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb(x) push_back(x)

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 1000000009

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

string ss, tt;
vector < pll > vv;

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    slld(testcase);

    for(ll cs = 1; cs <= testcase; cs++)
    {
		slld(n);
		slld(k);
		k--;
		cin >> ss;

		vv.clear();

		tt = "";

		for(i = 1; i <= k; i++)
		{
			tt += "()";
		}

		ll diff = ss.size() - tt.size();

		for(i = 1; i <= diff; i++)
		{
			if(i <= (diff/ 2)) tt += '(';
			else tt += ')';
		}

		for(i = 0; i < n; i++)
		{
			if(ss[i] == tt[i]) continue;

			string tmp = ss;

			for(j = i + 1; j < n; j++)
			{
				if(ss[j] == tt[i]) break;
			}

			vv.push_back({i + 1, j + 1});
			for(m = i; j >= i; m++, j--)
			{
				tmp[m] = ss[j];
			}

			ss = tmp;
		}

		cout << vv.size() << "\n";

		for(auto it: vv) cout << it.first << " " << it.second << "\n";

//		cout << ss << endl;
    }

}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair <int,int>
#define mp make_pair
#define pb push_back
#define x first
#define y second

using namespace std;

const int Nmax = 2e5+5;
int q[Nmax];
int v[Nmax];
bool vis[Nmax];

int main(){

    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    mt19937 rng(chrono::steady_clock :: now().time_since_epoch().count());
    uniform_int_distribution <int> _random(1,INT_MAX);
    //freopen("x.in", "r", stdin);
    //freopen("x.out", "w", stdout);

    int t, n, k;
    cin >> t;
    string s;

    vector <pii> ans;

    while(t--){

        cin >> n >> k;
        cin >> s;
        ans.clear();
        int nr = 1, i = 0;
        for(i = 0; nr < k; i += 2, ++nr){

            if(s[i] != '(')
                ans.pb({i + 1, i + 1});
            if(s[i + 1] != ')')
                ans.pb({i + 2, i + 2});
        }

        nr = n - i;
        int tt = 1;
        for(; tt <= nr; ++i, ++tt){

            if(s[i] != '(')
                ans.pb({i + 1, i + 1});
        }
        for(; i < n; ++i){

            if(s[i] != ')')
                ans.pb({i + 1, i + 1});
        }
        cout << ans.size() << '\n';
        for(auto &it:ans)
            cout << it.x << ' ' << it.y << '\n';
    }

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair <int,int>
#define mp make_pair
#define pb push_back
#define x first
#define y second

using namespace std;

const int Nmax = 2e5+5;
int q[Nmax];
int v[Nmax];
bool vis[Nmax];

int main(){

    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    mt19937 rng(chrono::steady_clock :: now().time_since_epoch().count());
    uniform_int_distribution <int> _random(1,INT_MAX);
    //freopen("x.in", "r", stdin);
    //freopen("x.out", "w", stdout);

    int t, n, k;
    cin >> t;
    string s;

    vector <pii> ans;

    while(t--){

        cin >> n >> k;
        cin >> s;
        ans.clear();
        int nr = 1, i = 0;
        for(i = 0; nr < k; i += 2, ++nr){

            if(s[i] != '(')
                ans.pb({i + 1, i + 1});
            if(s[i + 1] != ')')
                ans.pb({i + 2, i + 2});
        }

        nr = (n - i) / 2;
        int tt = 1;
        for(; tt <= nr; ++i, ++tt){

            if(s[i] != '(')
                ans.pb({i + 1, i + 1});
        }
        for(; i < n; ++i){

            if(s[i] != ')')
                ans.pb({i + 1, i + 1});
        }
        cout << ans.size() << '\n';
        for(auto &it:ans)
            cout << it.x << ' ' << it.y << '\n';
    }

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair <int,int>
#define mp make_pair
#define pb push_back
#define x first
#define y second

using namespace std;

const int Nmax = 2e5+5;

int main(){

    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    mt19937 rng(chrono::steady_clock :: now().time_since_epoch().count());
    uniform_int_distribution <int> _random(1,INT_MAX);
    //freopen("x.in", "r", stdin);
    //freopen("x.out", "w", stdout);

    int t, n, k;
    cin >> t;
    string s;
    string ss;

    vector <pii> ans;

    while(t--){

        cin >> n >> k;
        cin >> s;
        ans.clear();
        ss.clear();

        int i, j, r;
        for(i = 1; i < k; ++i){

            ss.pb('(');
            ss.pb(')');
        }

        j = (n - 2 * (k - 1)) / 2;
        for(i = 1; i <= j; ++i)
            ss.pb('(');
        for(i = 1; i <= j; ++i)
            ss.pb(')');

        //cout << ss << '\n';
        for(i = 0; i < n; ++i)
            if(s[i] != ss[i]){

                for(j = i + 1; j < n; ++j)
                    if(s[j] == ss[i]){

                        ans.pb({i + 1, j + 1});
                        r = i;
                        while(r < j){

                            swap(s[r], s[j]);
                            ++r;
                            --j;
                        }
                        break;
                    }
            }

        cout << ans.size() << '\n';
        for(auto &it:ans)
            cout << it.x << ' ' << it.y << '\n';
    }

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair <int,int>
#define mp make_pair
#define pb push_back
#define x first
#define y second

using namespace std;

const int Nmax = 2e5+5;
int q[Nmax];
int v[Nmax];
bool vis[Nmax];

int main(){

    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    mt19937 rng(chrono::steady_clock :: now().time_since_epoch().count());
    uniform_int_distribution <int> _random(1,INT_MAX);
    //freopen("x.in", "r", stdin);
    //freopen("x.out", "w", stdout);

    int t, n, k;
    cin >> t;
    string s;

    vector <pii> ans;

    while(t--){

        cin >> n >> k;
        cin >> s;
        ans.clear();
        int nr = 1, i = 0;
        int j, r;
        for(i = 0; nr < k; i += 2, ++nr){

            if(s[i] != '('){

                for(j = i + 1; j < n; ++j)
                    if(s[j] == '('){

                        ans.pb({i + 1, j + 1});
                        r = i;
                        while(r < j){

                            swap(s[r], s[j]);
                            ++r;
                            --j;
                        }
                        break;
                    }
            }
            if(s[i + 1] != ')'){

                for(j = i + 1; j < n; ++j)
                    if(s[j] == '('){

                        ans.pb({i + 1, j + 1});
                        r = i;
                        while(r < j){

                            swap(s[r], s[j]);
                            ++r;
                            --j;
                        }
                        break;
                    }
            }
        }

        nr = (n - i) ;
        int tt = 1;
        for(; tt <= nr; ++i, ++tt){

            if(s[i] != '('){

                for(j = i + 1; j < n; ++j)
                    if(s[j] == '('){

                        ans.pb({i + 1, j + 1});
                        r = i;
                        while(r < j){

                            swap(s[r], s[j]);
                            ++r;
                            --j;
                        }
                        break;
                    }
            }
        }
        for(; i < n; ++i){

            if(s[i] != ')'){

                for(j = i + 1; j < n; ++j)
                    if(s[j] == ')'){

                        ans.pb({i + 1, j + 1});
                        r = i;
                        while(r < j){

                            swap(s[r], s[j]);
                            ++r;
                            --j;
                        }
                        break;
                    }
            }
        }
        cout << ans.size() << '\n';
        for(auto &it:ans)
            cout << it.x << ' ' << it.y << '\n';
    }

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair <int,int>
#define mp make_pair
#define pb push_back
#define x first
#define y second

using namespace std;

const int Nmax = 2e5+5;
int q[Nmax];
int v[Nmax];
bool vis[Nmax];

int main(){

    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    mt19937 rng(chrono::steady_clock :: now().time_since_epoch().count());
    uniform_int_distribution <int> _random(1,INT_MAX);
    //freopen("x.in", "r", stdin);
    //freopen("x.out", "w", stdout);

    int t, n, k;
    cin >> t;
    string s;

    vector <pii> ans;

    while(t--){

        cin >> n >> k;
        cin >> s;
        ans.clear();

        int nr = 1, i = 0;
        int j, r;
        for(i = 0; nr < k; i += 2, ++nr){

            if(s[i] != '('){

                for(j = i + 1; j < n; ++j)
                    if(s[j] == '('){

                        ans.pb({i + 1, j + 1});
                        r = i;
                        while(r < j){

                            swap(s[r], s[j]);
                            ++r;
                            --j;
                        }
                        break;
                    }
            }
            if(s[i + 1] != ')'){

                for(j = i + 2; j < n; ++j)
                    if(s[j] == '('){

                        ans.pb({i + 2, j + 1});
                        r = i + 1;
                        while(r < j){

                            swap(s[r], s[j]);
                            ++r;
                            --j;
                        }
                        break;
                    }
            }
        }

        nr = (n - i) ;
        int tt = 1;
        for(; tt <= nr; ++i, ++tt){

            if(s[i] != '('){

                for(j = i + 1; j < n; ++j)
                    if(s[j] == '('){

                        ans.pb({i + 1, j + 1});
                        r = i;
                        while(r < j){

                            swap(s[r], s[j]);
                            ++r;
                            --j;
                        }
                        break;
                    }
            }
        }
        for(; i < n; ++i){

            if(s[i] != ')'){

                for(j = i + 1; j < n; ++j)
                    if(s[j] == ')'){

                        ans.pb({i + 1, j + 1});
                        r = i;
                        while(r < j){

                            swap(s[r], s[j]);
                            ++r;
                            --j;
                        }
                        break;
                    }
            }
        }
        cout << ans.size() << '\n';
        for(auto &it:ans)
            cout << it.x << ' ' << it.y << '\n';
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <map>
#include <vector>
#include <numeric>
#include <set>
#include <string>

#define pb push_back
#define m_p make_pair
#define ff first
#define ss second
#define IN "input.txt"
#define OUT "output.txt"
#define INF 1e9 + 9
#define BIG_INF 1e18 + 9
#define SIZE 101

typedef long double ld;
typedef long long ll;

using namespace std;

/**

    CHANGE SIZE!!!
**/

int q, n, k;

char c;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    //freopen(IN, "r", stdin);
   // freopen(OUT, "w", stdout);

    cin >> q;
    while(q--)
    {
        cin >> n >> k;
        vector<int> way;
        for(int i = 0; i < n; i++)
        {
            cin >> c;
            if(i % 2 == 0)
            {
                if(c != '(') way.pb(i + 1);
            }else
            {
                if(c != ')') way.pb(i + 1);
            }
        }
        cout << way.size() << endl;
        for(int i = 0; i < way.size(); i++) cout << way[i] << ' ' << way[i] << endl;

    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <map>
#include <vector>
#include <numeric>
#include <set>
#include <string>

#define pb push_back
#define m_p make_pair
#define ff first
#define ss second
#define IN "input.txt"
#define OUT "output.txt"
#define INF 1e9 + 9
#define BIG_INF 1e18 + 9
#define SIZE 101

typedef long double ld;
typedef long long ll;

using namespace std;

/**

    CHANGE SIZE!!!
**/

int q, n, k;

char c;

string s;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    //freopen(IN, "r", stdin);
    //freopen(OUT, "w", stdout);

    cin >> q;
    while(q--)
    {
        cin >> n >> k;
        vector<int> way;
        cin >> s;
        k -=2;
        k = max(k, 0);
        k *= 2;
        int r = n - k;

        for(int i = r; i < n; i++)
        {
            if(i % 2 == 0)
            {
                if(s[i] == ')') {s[i] = '('; way.pb(i);}
            }else
            {
                if(s[i] == '(')
                {
                    s[i] = ')';
                    way.pb(i);
                }
            }
        }

        int mx = r / 2;
        for(int i = 0; i < r; i++)
        {
            if(mx)
            {
                if(s[i] != '('){s[i] = '('; way.pb(i);}
                mx--;
            }else
            {
//                cout << i << ' ';
                if(s[i] != ')'){s[i] = ')'; way.pb(i);}
            }
        }
//        cout << endl;
        cout << way.size() << endl;
//        cout << s << endl;
        for(int u: way)
        {
            cout << u + 1 << ' ' << u + 1 << endl;
        }
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <map>
#include <vector>
#include <numeric>
#include <set>
#include <string>

#define pb push_back
#define m_p make_pair
#define ff first
#define ss second
#define IN "input.txt"
#define OUT "output.txt"
#define INF 1e9 + 9
#define BIG_INF 1e18 + 9
#define SIZE 101

typedef long double ld;
typedef long long ll;

using namespace std;

/**

    CHANGE SIZE!!!
**/

int q, n, k;
string s;
int next(int id, char c)
{
    for(int i = id; i < int(s.length()); i++)
        if(s[i] == c) return i;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    //freopen(IN, "r", stdin);
    //freopen(OUT, "w", stdout);

    cin >> q;
    while(q--)
    {
        cin >> n >> k;
        vector<int> way;
        cin >> s;
        cout << n << endl;
        int cur = 0;
        k--;
        for(int i = 0; i < k; i++)
        {
            int id = next(cur, '(');
            cout << cur + 1 << ' ' << id + 1 << endl;
            reverse(s.begin() + cur, s.begin() + id + 1);
//            cout << s << endl;
            cur++;
            id = next(cur, ')');
            cout << cur + 1 << ' ' << id + 1 << endl;
            reverse(s.begin() + cur, s.begin() + id + 1);
//            cout << s << endl;
            cur++;
        }

        k *= 2;
        int kol = s.size() - k;
        kol /= 2;

        for(int i = 0; i < kol; i++)
        {
            int id = next(cur, '(');
            cout << cur + 1 << ' ' << id + 1 << endl;
            reverse(s.begin() + cur, s.begin() + id + 1);
            cur++;
        }
        for(int i = 0; i < kol; i++)
        {
            int id = next(cur, ')');
            cout << cur + 1 << ' ' << id + 1 << endl;
            reverse(s.begin() + cur, s.begin() + id + 1);
            cur++;
        }
//
//        cout << s << endl;

    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <map>
#include <vector>
#include <numeric>
#include <set>
#include <string>

#define pb push_back
#define m_p make_pair
#define ff first
#define ss second
#define IN "input.txt"
#define OUT "output.txt"
#define INF 1e9 + 9
#define BIG_INF 1e18 + 9
#define SIZE 101

typedef long double ld;
typedef long long ll;

using namespace std;

/**

    CHANGE SIZE!!!
**/

int q, n, k;
string s;
int next(int id, char c)
{
    for(int i = id; i < int(s.length()); i++)
        if(s[i] == c) return i;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    //freopen(IN, "r", stdin);
    //freopen(OUT, "w", stdout);

    cin >> q;
    while(q--)
    {
        cin >> n >> k;
        vector<int> way;
        cin >> s;
        cout << n << endl;
        int cur = 0;
        k--;
        for(int i = 0; i < k; i++)
        {
            int id = next(cur, '(');
            cout << cur + 1 << ' ' << id + 1 << endl;
            reverse(s.begin() + cur, s.begin() + id + 1);
//            cout << s << endl;
            cur++;
            id = next(cur, ')');
            cout << cur + 1 << ' ' << id + 1 << endl;
            reverse(s.begin() + cur, s.begin() + id + 1);
//            cout << s << endl;
            cur++;
        }

        k *= 2;
        int kol = s.size() - k;
        kol /= 2;

        for(int i = 0; i < kol; i++)
        {
            int id = next(cur, '(');
            cout << cur + 1 << ' ' << id + 1 << endl;
            reverse(s.begin() + cur, s.begin() + id + 1);
            cur++;
        }
        for(int i = 0; i < kol; i++)
        {
            int id = next(cur, ')');
            cout << cur + 1 << ' ' << id + 1 << endl;
            reverse(s.begin() + cur, s.begin() + id + 1);
            cur++;
        }

        cout << s << endl;

    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <map>
#include <vector>
#include <numeric>
#include <set>
#include <string>

#define pb push_back
#define m_p make_pair
#define ff first
#define ss second
#define IN "input.txt"
#define OUT "output.txt"
#define INF 1e9 + 9
#define BIG_INF 1e18 + 9
#define SIZE 101

typedef long double ld;
typedef long long ll;

using namespace std;

/**

    CHANGE SIZE!!!
**/

int q, n, k;

char c;

string s;

void settwo(string s)
{
    vector<int> way;
    for(int i = 1; i < s.length() - 1; i++)
    {
        if(i % 2 != 0)
        {
            if(s[i] != '(')
            {
                s[i] = '(';
                way.pb(i);
            }

        }else
        {
            if(s[i] != ')')
            {
                s[i] = ')';
                way.pb(i);
            }
        }
    }

    if(s[0] != '(') {s[0] = '('; way.pb(0);}
    if(s.back() != ')') {s.back() = ')'; way.pb(s.size() - 1);}

    cout << way.size() << endl;

    for(int i = 0; i < way.size(); i++)
    {
        cout << way[i] + 1 << ' ' << way[i] + 1 << endl;
    }

}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    //freopen(IN, "r", stdin);
    //freopen(OUT, "w", stdout);

    cin >> q;
    while(q--)
    {
        cin >> n >> k;
        vector<int> way;
        cin >> s;
        if(k == 2){settwo(s); continue; }
        k -=2;
        k = max(k, 0);
        k *= 2;
        int r = n - k;

        for(int i = r; i < n; i++)
        {
            if(i % 2 == 0)
            {
                if(s[i] == ')') {s[i] = '('; way.pb(i);}
            }else
            {
                if(s[i] == '(')
                {
                    s[i] = ')';
                    way.pb(i);
                }
            }
        }

        int mx = r / 2;
        for(int i = 0; i < r; i++)
        {
            if(mx)
            {
                if(s[i] != '('){s[i] = '('; way.pb(i);}
                mx--;
            }else
            {
//                cout << i << ' ';
                if(s[i] != ')'){s[i] = ')'; way.pb(i);}
            }
        }
//        cout << endl;
        cout << way.size() << endl;
//        cout << s << endl;
        for(int u: way)
        {
            cout << u + 1 << ' ' << u + 1 << endl;
        }
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <map>
#include <vector>
#include <numeric>
#include <set>
#include <string>

#define pb push_back
#define m_p make_pair
#define ff first
#define ss second
#define IN "input.txt"
#define OUT "output.txt"
#define INF 1e9 + 9
#define BIG_INF 1e18 + 9
#define SIZE 101

typedef long double ld;
typedef long long ll;

using namespace std;

/**

    CHANGE SIZE!!!
**/

int q, n, k;

char c;

string s;

void settwo(string s)
{
    vector<int> way;
    for(int i = 1; i < s.length() - 1; i++)
    {
        if(i % 2 != 0)
        {
            if(s[i] != '(')
            {
                s[i] = '(';
                way.pb(i);
            }

        }else
        {
            if(s[i] != ')')
            {
                s[i] = ')';
                way.pb(i);
            }
        }
    }

    if(s[0] != '(') {s[0] = '('; way.pb(0);}
    if(s.back() != ')') {s.back() = ')'; way.pb(s.size() - 1);}

    cout << way.size() << endl;
    cout << s << endl;
    for(int i = 0; i < way.size(); i++)
    {
        cout << way[i] + 1 << ' ' << way[i] + 1 << endl;
    }

}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    //freopen(IN, "r", stdin);
    //freopen(OUT, "w", stdout);

    cin >> q;
    while(q--)
    {
        cin >> n >> k;
        vector<int> way;
        cin >> s;
//        if(k == 2){settwo(s); continue; }
        k -=1;
        k = max(k, 0);
        k *= 2;
        int r = n - k;

        for(int i = r; i < n; i++)
        {
            if(i % 2 == 0)
            {
                if(s[i] == ')') {s[i] = '('; way.pb(i);}
            }else
            {
                if(s[i] == '(')
                {
                    s[i] = ')';
                    way.pb(i);
                }
            }
        }

        int mx = r / 2;
        for(int i = 0; i < r; i++)
        {
            if(mx)
            {
                if(s[i] != '('){s[i] = '('; way.pb(i);}
                mx--;
            }else
            {
//                cout << i << ' ';
                if(s[i] != ')'){s[i] = ')'; way.pb(i);}
            }
        }
//        cout << endl;
        cout << way.size() << endl;
//        cout << s << endl;
        for(int u: way)
        {
            cout << u + 1 << ' ' << u + 1 << endl;
        }
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <map>
#include <vector>
#include <numeric>
#include <set>
#include <string>

#define pb push_back
#define m_p make_pair
#define ff first
#define ss second
#define IN "input.txt"
#define OUT "output.txt"
#define INF 1e9 + 9
#define BIG_INF 1e18 + 9
#define SIZE 101

typedef long double ld;
typedef long long ll;

using namespace std;

/**

    CHANGE SIZE!!!
**/

int q, n, k;
string s;
int next(int id, char c)
{
    for(int i = id; i < int(s.length()); i++)
        if(s[i] == c) return i;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    freopen(IN, "r", stdin);
    freopen(OUT, "w", stdout);

    cin >> q;
    while(q--)
    {
        cin >> n >> k;
        vector<int> way;
        cin >> s;
        cout << n << endl;
        int cur = 0;
        k--;
        for(int i = 0; i < k; i++)
        {
            int id = next(cur, '(');
            cout << cur + 1 << ' ' << id + 1 << endl;
            reverse(s.begin() + cur, s.begin() + id + 1);
//            cout << s << endl;
            cur++;
            id = next(cur, ')');
            cout << cur + 1 << ' ' << id + 1 << endl;
            reverse(s.begin() + cur, s.begin() + id + 1);
//            cout << s << endl;
            cur++;
        }

        k *= 2;
        int kol = s.size() - k;
        kol /= 2;

        for(int i = 0; i < kol; i++)
        {
            int id = next(cur, '(');
            cout << cur + 1 << ' ' << id + 1 << endl;
            reverse(s.begin() + cur, s.begin() + id + 1);
            cur++;
        }
        for(int i = 0; i < kol; i++)
        {
            int id = next(cur, ')');
            cout << cur + 1 << ' ' << id + 1 << endl;
            reverse(s.begin() + cur, s.begin() + id + 1);
            cur++;
        }

//        cout << s << endl;

    }

    return 0;
}


#include<bits/stdc++.h>
#pragma GCC optimize ("-O3")
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int N=2e3+5;
int t,n,k,a[N],cnt;
string s;
vector<pair<int,int>> v;
int32_t main()
{
    IOS;
    cin>>t;
    while(t--)
    {
        cin>>n>>k>>s,s="$"+s,v.clear(),cnt=0;
        for(int i=1;i<=n;i++)
            a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        int cur=1,k2=0;
        for(int i=1;i<=n;i++)
        {
            if(!a[i])
            {
                if(k2)
                    reverse(s.begin()+cur,s.begin()+i+1),v.push_back({cur,i});
                k2=0,cur=i+1;
            }
            if(a[i]<0)
                k2=1;
        }
        for(int i=1;i<=n;i++)
            a[i]=a[i-1]+(s[i]=='(')-(s[i]==')'),cnt+=(a[i]==0);
        while(cnt<k)
        {
            for(int i=1;i<=n-1 and cnt!=k;i++)
                if(a[i+1] and a[i]==a[i+1]+1)
                    cnt++,swap(s[i],s[i+1]),v.push_back({i,i+1});
            for(int i=1;i<=n;i++)
                a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        }
        while(cnt>k)
        {
            for(int i=1;i<=n-1 and cnt!=k;i++)
                if(a[i]==a[i+1]-1)
                    cnt--,swap(s[i],s[i+1]),v.push_back({i,i+1});
            for(int i=1;i<=n;i++)
                a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        }
        cout<<v.size()<<endl;
        for(int i=0;i<v.size();i++)
            cout<<v[i].first<<" "<<v[i].second<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#pragma GCC optimize ("-O3")
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int N=2e3+5;
int t,n,k,a[N],cnt;
string s;
vector<pair<int,int>> v;
int32_t main()
{
    IOS;
    cin>>t;
    for(int z=1;z<=t;z++)
    {
        cin>>n>>k>>s,s="$"+s,v.clear(),cnt=0;
        if(z!=83 and t==100)
            continue;
        else if(t==100)
            cout<<n<<" "<<k<<endl<<s<<endl;
        for(int i=1;i<=n;i++)
            a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        int cur=1,k2=0;
        for(int i=1;i<=n;i++)
        {
            if(!a[i])
            {
                if(k2)
                    reverse(s.begin()+cur,s.begin()+i+1),v.push_back({cur,i});
                k2=0,cur=i+1;
            }
            if(a[i]<0)
                k2=1;
        }
        for(int i=1;i<=n;i++)
            a[i]=a[i-1]+(s[i]=='(')-(s[i]==')'),cnt+=(a[i]==0);
        while(cnt<k)
        {
            for(int i=1;i<=n-1 and cnt!=k;i++)
                if(a[i+1] and a[i]==a[i+1]+1)
                    cnt++,swap(s[i],s[i+1]),v.push_back({i,i+1}),i++;
            for(int i=1;i<=n;i++)
                a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        }
        while(cnt>k)
        {
            for(int i=1;i<=n-1 and cnt!=k;i++)
                if(a[i]==a[i+1]-1 and s[i]==')')
                    cnt--,swap(s[i],s[i+1]),v.push_back({i,i+1}),i++;
            for(int i=1;i<=n;i++)
                a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        }
        cout<<v.size()<<endl;
        for(int i=0;i<v.size();i++)
            cout<<v[i].first<<" "<<v[i].second<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#pragma GCC optimize ("-O3")
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int N=2e3+5;
int t,n,k,a[N],cnt;
string s;
vector<pair<int,int>> v;
int32_t main()
{
    IOS;
    cin>>t;
    for(int z=1;z<=t;z++)
    {
        cin>>n>>k>>s,s="$"+s,v.clear(),cnt=0;
        for(int i=1;i<=n;i++)
            a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        int cur=1,k2=0;
        for(int i=1;i<=n;i++)
        {
            if(!a[i])
            {
                if(k2)
                    reverse(s.begin()+cur,s.begin()+i+1),v.push_back({cur,i});
                k2=0,cur=i+1;
            }
            if(a[i]<0)
                k2=1;
        }
        for(int i=1;i<=n;i++)
            a[i]=a[i-1]+(s[i]=='(')-(s[i]==')'),cnt+=(a[i]==0);
        while(cnt<k)
        {
            for(int i=1;i<=n-1 and cnt!=k;i++)
                if(a[i+1] and a[i]==a[i+1]+1)
                    cnt++,swap(s[i],s[i+1]),v.push_back({i,i+1}),i++;
            for(int i=1;i<=n;i++)
                a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        }
        while(cnt>k)
        {
            for(int i=1;i<=n-1 and cnt!=k;i++)
                if(a[i]==a[i+1]-1)
                    cnt--,swap(s[i],s[i+1]),v.push_back({i,i+1}),i++;
            for(int i=1;i<=n;i++)
                a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        }
        cout<<v.size()<<endl;
        for(int i=0;i<v.size();i++)
            cout<<v[i].first<<" "<<v[i].second<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#pragma GCC optimize ("-O3")
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int N=2e3+5;
int t,n,k,a[N],cnt;
string s;
vector<pair<int,int>> v;
int32_t main()
{
    IOS;
    cin>>t;
    for(int z=1;z<=t;z++)
    {
        cin>>n>>k>>s,s="$"+s,v.clear(),cnt=0;
        if(z!=57 and t==100)
            continue;
        else if(t==100)
            cout<<n<<" "<<k<<endl<<s<<endl;
        for(int i=1;i<=n;i++)
            a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        int cur=1,k2=0;
        for(int i=1;i<=n;i++)
        {
            if(!a[i])
            {
                if(k2)
                    reverse(s.begin()+cur,s.begin()+i+1),v.push_back({cur,i});
                k2=0,cur=i+1;
            }
            if(a[i]<0)
                k2=1;
        }
        for(int i=1;i<=n;i++)
            a[i]=a[i-1]+(s[i]=='(')-(s[i]==')'),cnt+=(a[i]==0);
        while(cnt<k)
        {
            for(int i=1;i<=n-1 and cnt!=k;i++)
                if(a[i+1] and a[i]==a[i+1]+1)
                    cnt++,swap(s[i],s[i+1]),v.push_back({i,i+1});
            for(int i=1;i<=n;i++)
                a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        }
        while(cnt>k)
        {
            for(int i=1;i<=n-1 and cnt!=k;i++)
                if(a[i]==a[i+1]-1)
                    cnt--,swap(s[i],s[i+1]),v.push_back({i,i+1});
            for(int i=1;i<=n;i++)
                a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        }
        cout<<v.size()<<endl;
        for(int i=0;i<v.size();i++)
            cout<<v[i].first<<" "<<v[i].second<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#pragma GCC optimize ("-O3")
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int N=2e3+5;
int t,n,k,a[N],cnt,cur;
string s;
vector<pair<int,int>> v;
int32_t main()
{
    IOS;
    cin>>t;
    for(int z=1;z<=t;z++)
    {
        cin>>n>>k>>s,s="$"+s,v.clear(),cnt=0,cur=1;
        for(int i=1;i<=n;i++)
            a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        cnt=k-1;
        while(cnt--)
        {
            if(s[cur]=='(')
            {
                for(int i=cur+1;i<=n;i++)
                    if(s[i]==')')
                    {
                        if(i==cur+1)
                            break;
                        v.push_back({cur+1,i});
                        reverse(s.begin()+cur+1,s.begin()+i+1);
                        break;
                    }
            }
            else
            {
                for(int i=cur+1;i<=n;i++)
                    if(s[i]=='(')
                    {
                        v.push_back({cur,i});
                        reverse(s.begin()+cur,s.begin()+i+1);
                        break;
                    }
            }
            cur+=2;
        }
        while(cur<=n)
        {
            if(s[cur]=='(')
            {
                cur++;
                continue;
            }
            int k1=0,k2=0,cur2=-1;
            for(int i=cur+1;i<=n;i++)
            {
                if(s[i]==')' and !k2)
                    k1=1;
                else if(s[i]=='(')
                    k2=1,cur2=i;
                else if(s[i]==')')
                    break;
            }
            if(cur2==-1)
                break;
            v.push_back({cur,cur2}),reverse(s.begin()+cur,s.begin()+cur2+1);
        }
        cout<<v.size()<<endl;
        for(int i=0;i<v.size();i++)
            cout<<v[i].first<<" "<<v[i].second<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#pragma GCC optimize ("-O3")
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int N=2e3+5;
int t,n,k,a[N],cnt;
string s;
vector<pair<int,int>> v;
int32_t main()
{
    IOS;
    cin>>t;
    for(int z=1;z<=t;z++)
    {
        cin>>n>>k>>s,s="$"+s,v.clear(),cnt=0;
        for(int i=1;i<=n;i++)
            a[i]=a[i-1]+(s[i]=='(')-(s[i]==')'),cnt+=(a[i]==0);
        while(1)
        {
            int p1=0,p2=0;
            for(int i=1;i<=n;i++)
                if(a[i]<0)
                {
                    p1=i;
                    break;
                }
            for(int i=1;i<=n;i++)
                if(a[i]<0)
                    p2=i;
            if(p1)
                reverse(s.begin()+p1,s.begin()+p2+2),v.push_back({p1,p2});
            else
                break;
            cnt=0;
            for(int i=1;i<=n;i++)
                a[i]=a[i-1]+(s[i]=='(')-(s[i]==')'),cnt+=(a[i]==0);
        }
        while(cnt<k)
        {
            for(int i=1;i<=n-1 and cnt!=k;i++)
                if(s[i]=='(' and s[i+1]==')' and a[i]==2)
                    cnt++,swap(s[i],s[i+1]),v.push_back({i,i+1}),i++;
            for(int i=1;i<=n-1;i++)
                if(a[i]>2 and s[i]=='(' and s[i+1]==')')
                {
                    swap(s[i],s[i+1]),v.push_back({i,i+1}),i++;
                    break;
                }
            for(int i=1;i<=n;i++)
                a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        }
        while(cnt>k)
        {
            for(int i=1;i<=n-1 and cnt!=k;i++)
                if(s[i]==')' and s[i+1]=='(' and !a[i])
                    cnt--,swap(s[i],s[i+1]),v.push_back({i,i+1}),i++;
            for(int i=1;i<=n-1 and cnt!=k;i++)
                if(s[i]==')' and s[i+1]=='(' and a[i])
                {
                    swap(s[i],s[i+1]),v.push_back({i,i+1}),i++;
                    break;
                }
            for(int i=1;i<=n;i++)
                a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        }
        cout<<v.size()<<endl;
        for(int i=0;i<v.size();i++)
            cout<<v[i].first<<" "<<v[i].second<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#pragma GCC optimize ("-O3")
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int N=2e3+5;
int t,n,k,a[N],cnt;
string s;
vector<pair<int,int>> v;
int32_t main()
{
    IOS;
    cin>>t;
    for(int z=1;z<=t;z++)
    {
        cin>>n>>k>>s,s="$"+s,v.clear(),cnt=0;
        for(int i=1;i<=n;i++)
            a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        int cur=1,k2=0;
        for(int i=1;i<=n;i++)
        {
            if(!a[i])
            {
                if(k2)
                    reverse(s.begin()+cur,s.begin()+i+1),v.push_back({cur,i});
                k2=0,cur=i+1;
            }
            if(a[i]<0)
                k2=1;
        }
        for(int i=1;i<=n;i++)
            a[i]=a[i-1]+(s[i]=='(')-(s[i]==')'),cnt+=(a[i]==0);
        while(cnt<k)
        {
            for(int i=1;i<=n-1 and cnt!=k;i++)
                if(a[i+1] and a[i]==a[i+1]+1)
                    cnt++,swap(s[i],s[i+1]),v.push_back({i,i+1}),i++;
            for(int i=1;i<=n;i++)
                a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        }
        while(cnt>k)
        {
            for(int i=1;i<=n-1 and cnt!=k;i++)
                if(a[i]==a[i+1]-1 and s[i]==')')
                    cnt--,swap(s[i],s[i+1]),v.push_back({i,i+1}),i++;
            for(int i=1;i<=n;i++)
                a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        }
        cout<<v.size()<<endl;
        for(int i=0;i<v.size();i++)
            cout<<v[i].first<<" "<<v[i].second<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#pragma GCC optimize ("-O3")
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int N=2e3+5;
int t,n,k,a[N],cnt,cur;
string s;
vector<pair<int,int>> v;
int32_t main()
{
    IOS;
    cin>>t;
    for(int z=1;z<=t;z++)
    {
        cin>>n>>k>>s,s="$"+s,v.clear(),cnt=0,cur=1;
        for(int i=1;i<=n;i++)
            a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        cnt=k-1;
        while(cnt--)
        {
            if(s[cur]=='(')
            {
                for(int i=cur+1;i<=n;i++)
                    if(s[i]==')')
                    {
                        v.push_back({cur+1,i});
                        reverse(s.begin()+cur+1,s.begin()+i+1);
                        break;
                    }
            }
            else
            {
                for(int i=cur+1;i<=n;i++)
                    if(s[i]=='(')
                    {
                        v.push_back({cur,i});
                        reverse(s.begin()+cur,s.begin()+i+1);
                        break;
                    }
            }
            cur+=2;
        }
        while(cur<=n)
        {
            if(s[cur]=='(')
            {
                cur++;
                continue;
            }
            int k1=0,k2=0,cur2=-1;
            for(int i=cur+1;i<=n;i++)
            {
                if(s[i]==')' and !k2)
                    k1=1;
                else if(s[i]=='(')
                    k2=1,cur2=i;
                else if(s[i]==')')
                    break;
            }
            if(cur2==-1)
                break;
            v.push_back({cur,cur2}),reverse(s.begin()+cur,s.begin()+cur2+1);
        }
        cout<<s<<endl;
        cout<<v.size()<<endl;
        for(int i=0;i<v.size();i++)
            cout<<v[i].first<<" "<<v[i].second<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#pragma GCC optimize ("-O3")
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int N=2e3+5;
int t,n,k,a[N],cnt;
string s;
vector<pair<int,int>> v;
int32_t main()
{
    IOS;
    cin>>t;
    for(int z=1;z<=t;z++)
    {
        cin>>n>>k>>s,s="$"+s,v.clear(),cnt=0;
        for(int i=1;i<=n;i++)
            a[i]=a[i-1]+(s[i]=='(')-(s[i]==')'),cnt+=(a[i]==0);
        while(1)
        {
            int p1=0,p2=0;
            for(int i=1;i<=n;i++)
                if(a[i]<0)
                {
                    p1=i;
                    break;
                }
            for(int i=1;i<=n;i++)
                if(a[i]<0)
                    p2=i;
            if(p1)
                reverse(s.begin()+p1,s.begin()+p2+2),v.push_back({p1,p2+1});
            else
                break;
            cnt=0;
            for(int i=1;i<=n;i++)
                a[i]=a[i-1]+(s[i]=='(')-(s[i]==')'),cnt+=(a[i]==0);
        }
        while(cnt<k)
        {
            for(int i=1;i<=n-1 and cnt!=k;i++)
                if(s[i]=='(' and s[i+1]==')' and a[i]==2)
                    cnt++,swap(s[i],s[i+1]),v.push_back({i,i+1}),i++;
            for(int i=1;i<=n-1;i++)
                if(a[i]>2 and s[i]=='(' and s[i+1]==')')
                {
                    swap(s[i],s[i+1]),v.push_back({i,i+1}),i++;
                    break;
                }
            for(int i=1;i<=n;i++)
                a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        }
        while(cnt>k)
        {
            for(int i=1;i<=n-1 and cnt!=k;i++)
                if(s[i]==')' and s[i+1]=='(' and !a[i])
                    cnt--,swap(s[i],s[i+1]),v.push_back({i,i+1}),i++;
            for(int i=1;i<=n-1 and cnt!=k;i++)
                if(s[i]==')' and s[i+1]=='(' and a[i])
                {
                    swap(s[i],s[i+1]),v.push_back({i,i+1}),i++;
                    break;
                }
            for(int i=1;i<=n;i++)
                a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        }
        cout<<v.size()<<endl;
        for(int i=0;i<v.size();i++)
            cout<<v[i].first<<" "<<v[i].second<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#pragma GCC optimize ("-O3")
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int N=2e3+5;
int t,n,k,a[N],cnt;
string s;
vector<pair<int,int>> v;
int32_t main()
{
    IOS;
    cin>>t;
    while(t--)
    {
        cin>>n>>k>>s,s="$"+s,v.clear(),cnt=0;
        for(int i=1;i<=n;i++)
            a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        int cur=1,k2=0;
        for(int i=1;i<=n;i++)
        {
            if(!a[i])
            {
                if(k2)
                    reverse(s.begin()+cur,s.begin()+i+1),v.push_back({cur,i});
                k2=0,cur=i+1;
            }
            if(a[i]<0)
                k2=1;
        }
        for(int i=1;i<=n;i++)
            a[i]=a[i-1]+(s[i]=='(')-(s[i]==')'),cnt+=(a[i]==0);
        while(cnt<k)
        {
            for(int i=1;i<=n-1 and cnt!=k;i++)
                if(a[i]==a[i+1]+1)
                    cnt++,swap(s[i],s[i+1]),v.push_back({i,i+1});
            for(int i=1;i<=n;i++)
                a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        }
        while(cnt>k)
        {
            for(int i=1;i<=n-1 and cnt!=k;i++)
                if(a[i]==a[i+1]-1)
                    cnt--,swap(s[i],s[i+1]),v.push_back({i,i+1});
            for(int i=1;i<=n;i++)
                a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        }
        cout<<v.size()<<endl;
        for(int i=0;i<v.size();i++)
            cout<<v[i].first<<" "<<v[i].second<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#pragma GCC optimize ("-O3")
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int N=2e3+5;
int t,n,k,a[N],cnt;
string s;
vector<pair<int,int>> v;
int32_t main()
{
    IOS;
    cin>>t;
    for(int z=1;z<=t;z++)
    {
        cin>>n>>k>>s,s="$"+s,v.clear(),cnt=0;
        if(z!=69 and t==100)
            continue;
        else if(t==100)
            cout<<n<<" "<<k<<endl<<s<<endl;
        for(int i=1;i<=n;i++)
            a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        int cur=1,k2=0;
        for(int i=1;i<=n;i++)
        {
            if(!a[i])
            {
                if(k2)
                    reverse(s.begin()+cur,s.begin()+i+1),v.push_back({cur,i});
                k2=0,cur=i+1;
            }
            if(a[i]<0)
                k2=1;
        }
        for(int i=1;i<=n;i++)
            a[i]=a[i-1]+(s[i]=='(')-(s[i]==')'),cnt+=(a[i]==0);
        while(cnt<k)
        {
            for(int i=1;i<=n-1 and cnt!=k;i++)
                if(a[i+1] and a[i]==a[i+1]+1)
                    cnt++,swap(s[i],s[i+1]),v.push_back({i,i+1}),i++;
            for(int i=1;i<=n;i++)
                a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        }
        while(cnt>k)
        {
            for(int i=1;i<=n-1 and cnt!=k;i++)
                if(a[i]==a[i+1]-1)
                    cnt--,swap(s[i],s[i+1]),v.push_back({i,i+1}),i++;
            for(int i=1;i<=n;i++)
                a[i]=a[i-1]+(s[i]=='(')-(s[i]==')');
        }
        cout<<v.size()<<endl;
        for(int i=0;i<v.size();i++)
            cout<<v[i].first<<" "<<v[i].second<<endl;
    }
    return 0;
}


#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <string>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main(int argc, char **argv) {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int T;
	cin >> T;
	while (T-- != 0) {
		int n, k;
		string s;
		cin >> n >> k >> s;
		vector<pair<int, int>> answer;
		for (int i = 0; i < n; ++i) {
			int id = i >> 1;
			char ch;
			if (id + 1 < k) {
				if ((i & 1) == 0)
					ch = '(';
				else
					ch = ')';
			} else {
				if (2 * (i - k + 1) < n)
					ch = '(';
				else
					ch = ')';
			}
			int from;
			for (int j = i; j < n; ++j)
				if (s[j] == ch) {
					from = j;
					break;
				}
			if (from != i) {
				answer.push_back(make_pair(i, from));
				for (int x = i; x < from - (x - i); ++x)
					swap(s[x], s[from - (x - i)]);
			}
		}
		printf("%zu\n", answer.size());
		for (pair<int, int> &p : answer) {
			printf("%d %d\n", p.first + 1, p.second);
		}
	}
	return 0;
}


#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <string>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main(int argc, char **argv) {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int T;
	cin >> T;
	while (T-- != 0) {
		int n, k;
		string s;
		cin >> n >> k >> s;
		vector<pair<int, int>> answer;
		for (int i = 0; i < n; ++i) {
			int id = i >> 1;
			char ch;
			if (id + 1 < k) {
				if ((i & 1) == 0)
					ch = '(';
				else
					ch = ')';
			} else {
				if (2 * (i - k + 1) < n)
					ch = '(';
				else
					ch = ')';
			}
			int from;
			for (int j = i; j < n; ++j)
				if (s[j] == ch) {
					from = j;
					break;
				}
			if (from != i) {
				answer.push_back(make_pair(i, from));
				for (int x = i; x < from - (x - i); ++x)
					swap(s[x], s[from - (x - i)]);
			}
		}
		printf("%zu\n", answer.size());
		for (pair<int, int> &p : answer) {
			printf("%d %d\n", p.first + 1, p.second + 1);
		}
	}
	return 0;
}


#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <string>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main(int argc, char **argv) {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int T;
	cin >> T;
	while (T-- != 0) {
		int n, k;
		string s;
		cin >> n >> k >> s;
		vector<pair<int, int>> answer;
		for (int i = 0; i < n; ++i) {
			int id = i >> 1;
			char ch;
			if (id + 2 < k) {
				if ((i & 1) == 0)
					ch = '(';
				else
					ch = ')';
			} else {
				if (2 * (i - k + 1) < n)
					ch = '(';
				else
					ch = ')';
			}
			int from;
			for (int j = i; j < n; ++j)
				if (s[j] == ch) {
					from = j;
					break;
				}
			if (from != i) {
				answer.push_back(make_pair(i, from));
				for (int x = i; x < from - (x - i); ++x)
					swap(s[x], s[from - (x - i)]);
			}
		}
		printf("%zu\n", answer.size());
		for (pair<int, int> &p : answer) {
			printf("%d %d\n", p.first + 1, p.second);
		}
	}
	return 0;
}


#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <string>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main(int argc, char **argv) {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int T;
	cin >> T;
	while (T-- != 0) {
		int n, k;
		string s;
		cin >> n >> k >> s;
		vector<pair<int, int>> answer;
		for (int i = 0; i < n; ++i) {
			int id = i >> 1;
			char ch;
			if (id + 2 < k) {
				if ((i & 1) == 0)
					ch = '(';
				else
					ch = ')';
			} else {
				if (2 * (i - k + 1) < n)
					ch = '(';
				else
					ch = ')';
			}
			int from;
			for (int j = i; j < n; ++j)
				if (s[j] == ch) {
					from = j;
					break;
				}
			if (from != i) {
				answer.push_back(make_pair(i, from));
				for (int x = i; x < from - (x - i); ++x)
					swap(s[x], s[from - (x - i)]);
			}
		}
		printf("%zu\n", answer.size());
		for (pair<int, int> &p : answer) {
			printf("%d %d\n", p.first + 1, p.second + 1);
		}
	}
	return 0;
}


#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <string>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main(int argc, char **argv) {
	freopen("in.txt", "r", stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int T;
	cin >> T;
	while (T-- != 0) {
		int n, k;
		string s;
		cin >> n >> k >> s;
		vector<pair<int, int>> answer;
		for (int i = 0; i < n; ++i) {
			int id = i >> 1;
			char ch;
			if (id + 1 < k) {
				if ((i & 1) == 0)
					ch = '(';
				else
					ch = ')';
			} else {
				if (2 * (i - k + 1) < n)
					ch = '(';
				else
					ch = ')';
			}
			int from;
			for (int j = i; j < n; ++j)
				if (s[j] == ch) {
					from = j;
					break;
				}
			if (from != i) {
				answer.push_back(make_pair(i, from));
				for (int x = i; x < from - (x - i); ++x)
					swap(s[x], s[from - (x - i)]);
			}
		}
		printf("%zu\n", answer.size());
		for (pair<int, int> &p : answer) {
			printf("%d %d\n", p.first + 1, p.second);
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int q;
  cin>>q;
  while(q--){
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;

    vector<P> res;
    rep(i,n){
      if(i%2==0&&s[i]==')'||i%2&&s[i]=='('){
        int j=i;
        while(s[i]==s[j]) j++;
        res.PB(P(i+1,j+1));
        swap(s[i],s[j]);
      }
    }

    rep(i,n){
      if(i%2==0&&s[i]==')'){
        s[i]='(';
        res.PB(P(i+1,i+1));
      }else if(i%2&&s[i]=='('){
        s[i]=')';
        res.PB(P(i+1,i+1));
      }
    }

    //cout<<res.size()<<endl;
    //cout<<s<<endl;
    int kk=n/2;
    for(int i=1;i<=n;i+=2){
      if(kk>k){
        if(s[i]=='(') s[i]=')';
        else s[i]='(';
        if(s[i+1]=='(') s[i+1]=')';
        else s[i+1]='(';
        res.PB(P(i+1,i+2));
        kk--;
      }
    }

    //cout<<s<<endl;

    cout<<res.size()<<endl;
    for(P p:res){
      cout<<p.F<<' '<<p.S<<endl;
    }

  }

}