This problem is different from the easy version. In this version Ujan makes at most 2n swaps. In addition, k ≤ 1000, n ≤ 50 and it is necessary to print swaps themselves. You can hack this problem if you solve it. But you can hack the previous problem only if you solve both problems.

After struggling and failing many times, Ujan decided to try to clean up his house again. He decided to get his strings in order first.

Ujan has two distinct strings s and t of length n consisting of only of lowercase English characters. He wants to make them equal. Since Ujan is lazy, he will perform the following operation at most 2n times: he takes two positions i and j (1 ≤ i,j ≤ n, the values i and j can be equal or different), and swaps the characters s_i and t_j.

Ujan's goal is to make the strings s and t equal. He does not need to minimize the number of performed operations: any sequence of operations of length 2n or shorter is suitable.

Input

The first line contains a single integer k (1 ≤ k ≤ 1000), the number of test cases.

For each of the test cases, the first line contains a single integer n (2 ≤ n ≤ 50), the length of the strings s and t. 

Each of the next two lines contains the strings s and t, each having length exactly n. The strings consist only of lowercase English letters. It is guaranteed that strings are different.

Output

For each test case, output "Yes" if Ujan can make the two strings equal with at most 2n operations and "No" otherwise. You can print each letter in any case (upper or lower).

In the case of "Yes" print m (1 ≤ m ≤ 2n) on the next line, where m is the number of swap operations to make the strings equal. Then print m lines, each line should contain two integers i, j (1 ≤ i, j ≤ n) meaning that Ujan swaps s_i and t_j during the corresponding operation. You do not need to minimize the number of operations. Any sequence of length not more than 2n is suitable.

Example

Input


4
5
souse
houhe
3
cat
dog
2
aa
az
3
abc
bca


Output


Yes
1
1 4
No
No
Yes
3
1 2
3 1
2 3

import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigInteger;
public class Solution
{
    static class Pair{
        int parent;
        int rank;
        Pair(int parent,int rank)
        {
            this.rank=rank;
            this.parent=parent;
        }
    }
    static int find(Pair pr[],int i)
    {
        if(i==pr[i].parent)
            return i;
        else
        {
            pr[i].parent=find(pr,pr[i].parent);
            return pr[i].parent;
        }
    }
    static void join(Pair[] pr,int i,int j)
    {
        i=find(pr,i);
        j=find(pr,j);
        if(i==j)
            return;
        if(pr[i].rank>=pr[j].rank)
        {
            pr[j].parent=i;
            pr[i].rank+=pr[j].rank;
        }
        else
        {
            pr[i].parent = j;
            pr[j].rank+=pr[i].rank;
        }
    }
    static void swap(char ar[],int i,int j)
    {
        char f = ar[i];
        ar[i]=ar[j];
        ar[j]=f;
    }
    static TreeSet<Integer> hs;
    static HashSet<Integer> graph[] ;
	public static void main (String[] args)
	{
          FastReader s1 = new FastReader();
          StringBuilder sb  = new StringBuilder();
          int t=s1.I();
          while(t--!=0)
          {
              int n =s1.I();
              char S[] = s1.next().toCharArray();
              char T[] = s1.next().toCharArray();
          ArrayList<Integer> ar = new ArrayList<>();
          for(int i=0;i<n;i++)
          {
              if(S[i]!=T[i])
              {
                  ar.add(i);
              }
          }
          if(ar.size()==0)
          {
              sb.append("Yes\n");
              sb.append("0\n");
          }
          else
          {
              int count=0;
              int in[] = new int[ar.size()];
              boolean m = false;
              StringBuilder an = new StringBuilder();
              for(int i=0;i<ar.size();i++)
              {
                  int index = ar.get(i);
                  boolean flag=false;
                  if(S[index]==T[index])
                      continue;
                  for(int j=i+1;j<ar.size();j++)
                  {
                      if(T[ar.get(j)]==T[index])
                      {
                          T[ar.get(j)]=S[index];
                          S[index]=T[index];
                          count++;
                          an.append((index+1)+" "+(ar.get(j)+1)+"\n");
                          flag=true;
                          break;
                      }
                  }
                  if(!flag)
                  {
                      for(int j=i+1;j<ar.size();j++)
                      {
                          int newindex=ar.get(j);
                          if(T[index]==S[newindex])
                          {
                              char temp = S[newindex];
                              S[newindex]=T[newindex];
                              T[newindex]=S[index];
                              S[index]=T[index];
                              count+=2;
                              an.append((newindex+1)+" "+(newindex+1)+"\n");
                              an.append((index+1)+" "+(newindex+1)+"\n");
                              flag=true;
                              break;
                          }
                      }
                  }
                  if(!flag)
                  {
                      m=true;
                      break;
                  }
              }
              if(m)
              {
                  sb.append("No\n");
              }
              else
              {
                  sb.append("Yes\n");
                  sb.append(count+"\n").append(an);
              }
          }
        }
            System.out.println(sb);
        }
        static void dfs(int index)
        {
            hs.remove(index);
            int demo=0;
            while(true)
            {
                Integer temp = hs.higher(demo);
                if(temp==null)
                    break;
                if(!graph[index].contains(temp))
                {
            //        System.out.println(index+" "+temp);
                    dfs(temp);
                }
                demo=temp;
            }
        }
        static int log2(int n)
        {
            double val = Math.log(n)/Math.log(2);
            return (int)val;
        }
        static int binary(int left,int right,int ar[],int no)
        {
             int mid=(left+right)/2;
             if(Math.abs(right-left)<=1)
             {
                 if(no>=ar[right])
                 {
                     return right+1;
                 }
                 else if(no<ar[left])
                 {
                     return left;
                 }
                 else
                 {
                      return left+1;
                 }
             }
             if(ar[mid]>no)
             {
                 right=mid-1;
                 return binary(left, right, ar, no);
             }
             else{
                 left=mid;
                 return binary(left, right, ar, no);
                         }
        }
	static class FastReader{
        BufferedReader br; 
        StringTokenizer st; 
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int I() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long L() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double D() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
    static int gcd(int a,int b)
		{
		    if(a%b==0)
		    return b;
		    return gcd(b,a%b);
		}
	static float power(float x, int y) 
    { 
        float temp; 
        if( y == 0) 
            return 1; 
        temp = power(x, y/2);  
          
        if (y%2 == 0) 
            return temp*temp; 
        else
        { 
            if(y > 0) 
                return x * temp * temp; 
            else
                return (temp * temp) / x; 
        } 
    } 
//        static long pow(long x,long y)
//        {
//            int m=1000000007;
//            x=x%m;
//            if(y==1)
//                return x;
//            long ans=1;
//            long val=pow(x,y/2)%m;
//            ans=(val*val)%m;
//            if(y%2!=0)
//            {
//                ans=(val*x)%m;
//            }
//            return ans%m;
//        }
      static long pow(long x, long y) 
    { 
        int p = 1000000007;
        long res = 1;      
        x = x % p;  
        while (y > 0) 
        { 
            if((y & 1)==1) 
                res = (res * x) % p;
            y = y >> 1;  
            x = (x * x) % p;  
        } 
        return res; 
    } 
    static ArrayList<Integer> sieveOfEratosthenes(int n) 
    { 
        ArrayList<Integer> arr=new ArrayList<Integer>();
        boolean prime[] = new boolean[n+1]; 
        for(int i=2;i<n;i++) 
            prime[i] = true; 
          
        for(int p = 2; p*p <=n; p++) 
        { 
            if(prime[p] == true) 
            { 
                arr.add(p);
                for(int i = p*p; i <= n; i += p) 
                    prime[i] = false; 
            } 
        } 
        return arr;
    } 
}