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.*;  
public class Main 
{
/*
    HashMap<> map=new HashMap<>();
    TreeMap<> map=new TreeMap<>();
    map.put(p,map.getOrDefault(p,0)+1);
    for(Map.Entry<> mx:map.entrySet()){
          int v=mx.getValue(),k=mx.getKey();
    }for (int i = 1; i <= 1000; i++)
    fac[i] = fac[i - 1] * i % mod;
    ArrayList<Pair<Character,Integer>> l=new ArrayList<>();
    ArrayList<> l=new ArrayList<>();
    HashSet<> has=new HashSet<>();
    PriorityQueue<Integer> pq=new PriorityQueue<>(new Comparator<Integer>(){
                public int compare(Integer a,Integer b){
                      return Integer.compare(b,a);
                }
                });
    Arrays.sort(ar,new Comparator<int[]>() {
    public int compare(int[] a, int[] b) {
        return Double.compare(a[0], b[0]);
    }
    });*/ 
    PrintWriter out;
    FastReader sc;
    long mod=(long)(1e9+7);
    long maxlong=Long.MAX_VALUE;
    long minlong=Long.MIN_VALUE;
    /******************************************************************************************
     *****************************************************************************************/
    public void sol(){
          int n=ni();
          String a=rl1(),b=rl1();
          if(a.equals(b)){
                yes();
                return;
          }StringBuilder sb1=new StringBuilder(a),sb2=new StringBuilder(b);
          int ans=0;
          StringBuilder str=new StringBuilder();
          for(int i=0;i<n;i++){
                if(sb1.charAt(i)==sb2.charAt(i))continue;
                else{
                      int p=-1;
                      for(int j=i+1;j<n;j++){
                            if(sb1.charAt(i)==sb1.charAt(j)){
                                  p=j;break;
                            }
                      }if(p!=-1){
                            char ch=sb2.charAt(i);
                            sb2.setCharAt(i,sb1.charAt(i));
                            sb1.setCharAt(p,ch);
                            ans++;
                            str.append(p+1+" "+(i+1)+"\n");
                            continue;
                      }p=-1;
                      for(int j=i+1;j<n;j++){
                            if(sb2.charAt(i)==sb2.charAt(j)){
                                  p=j;break;
                            }
                      }if(p!=-1){
                            char ch=sb1.charAt(i);
                            sb1.setCharAt(i,sb2.charAt(i));
                            sb2.setCharAt(p,ch);
                            ans++; 
                            str.append(i+1+" "+(p+1)+"\n");
                            continue;
                      }p=-1;
                      for(int j=i+1;j<n;j++){
                            if(sb1.charAt(i)==sb2.charAt(j)){
                                  p=j;break;
                            }
                      }if(p!=-1){
                            char ch=sb1.charAt(p);
                            sb1.setCharAt(p,sb2.charAt(p));
                            sb2.setCharAt(p,ch);
                            ans++;
                            str.append(p+1+" "+(p+1)+"\n");
                            ch=sb2.charAt(i);
                            sb2.setCharAt(i,sb1.charAt(i));
                            sb1.setCharAt(p,ch);
                            ans++;
                            str.append(p+1+" "+(i+1)+"\n");
                            continue;
                      }p=-1;
                      for(int j=i+1;j<n;j++){
                            if(sb2.charAt(i)==sb1.charAt(j)){
                                  p=j;break;
                            }
                      }if(p!=-1){
                            char ch=sb1.charAt(p);
                            sb1.setCharAt(p,sb2.charAt(p));
                            sb2.setCharAt(p,ch);
                            ans++;
                            str.append(p+1+" "+(p+1)+"\n");
                            ch=sb1.charAt(i);
                            sb1.setCharAt(i,sb2.charAt(i));
                            sb2.setCharAt(p,ch);
                            ans++; 
                            str.append(i+1+" "+(p+1)+"\n");
                      }
                }
          }if(sb1.toString().equals(sb2.toString())){
                yes();
                pl(ans);
                pr(str);
          }
          else no();
    }
    public static void main(String[] args) 
	{ 
	      Main g=new Main();
		g.out=new PrintWriter(System.out);
		g.sc=new FastReader();
		int t=1;
		t=g.ni();
		while(t-->0)
		g.sol();
		g.out.flush();
	}
	
	/****************************************************************************************
     *****************************************************************************************/
	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 nextInt() 
		{ 
			return Integer.parseInt(next()); 
		} 
 
		long nextLong() 
		{ 
			return Long.parseLong(next()); 
		} 
 
		double nextDouble() 
		{ 
			return Double.parseDouble(next()); 
		} 
 
		String nextLine() 
		{ 
			String str = ""; 
			try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} 
			return str; 
		} 
	} public int ni(){
	      return sc.nextInt();
	}public long nl(){
	      return sc.nextLong();
	}public double nd(){
	      return sc.nextDouble();
	}public char[] rl(){
	      return sc.nextLine().toCharArray();
	}public String rl1(){
	      return sc.nextLine();
	}
	public void pl(Object s){
	      out.println(s);
	}public void ex(){
	      out.println();
	}
	public void pr(Object s){
	      out.print(s);
	}public String next(){
	      return sc.next();
	}public long abs(long x){
	      return Math.abs(x);
	}
	public int abs(int x){
	      return Math.abs(x);
	}
	public double abs(double x){
	      return Math.abs(x);
	}
      public long pow(long x,long y){
            return (long)Math.pow(x,y);
      }
      public int pow(int x,int y){
            return (int)Math.pow(x,y);
      }
      public double pow(double x,double y){
            return Math.pow(x,y);
      }public long min(long x,long y){
            return (long)Math.min(x,y);
      }
      public int min(int x,int y){
            return (int)Math.min(x,y);
      }
      public double min(double x,double y){
            return Math.min(x,y);
      }public long gcd(long a, long b) {
		if (a == 0)
			return b;
		return gcd(b % a, a);
	}public long lcm(long a, long b) {
            return (a / gcd(a, b)) * b;
      }
       void sort1(int[] a) {
		ArrayList<Integer> l = new ArrayList<>();
		for (int i : a) {
			l.add(i);
		}
		Collections.sort(l,Collections.reverseOrder());
		for (int i = 0; i < a.length; i++) {
			a[i] = l.get(i);
		}
	}
	 void sort(int[] a) {
		ArrayList<Integer> l = new ArrayList<>();
		for (int i : a) {
			l.add(i);
		}
		Collections.sort(l);
		for (int i = 0; i < a.length; i++) {
			a[i] = l.get(i);
		}
	}void sort(long[] a) {
		ArrayList<Long> l = new ArrayList<>();
		for (long i : a) {
			l.add(i);
		}
		Collections.sort(l);
		for (int i = 0; i < a.length; i++) {
			a[i] = l.get(i);
		}
	}void sort1(long[] a) {
		ArrayList<Long> l = new ArrayList<>();
		for (long i : a) {
			l.add(i);
		}
		Collections.sort(l,Collections.reverseOrder());
		for (int i = 0; i < a.length; i++) {
			a[i] = l.get(i);
		}
	}
	void sort(double[] a) {
		ArrayList<Double> l = new ArrayList<>();
		for (double i : a) {
			l.add(i);
		}
		Collections.sort(l);
		for (int i = 0; i < a.length; i++) {
			a[i] = l.get(i);
		}
	}int  swap(int a,int b){
	      return a;
	}long  swap(long a,long b){
	      return a;
	}double  swap(double a,double b){
	      return a;
	}
	boolean isPowerOfTwo (int x) 
      { 
            return x!=0 && ((x&(x-1)) == 0);     
      }boolean isPowerOfTwo (long x) 
      { 
            return x!=0 && ((x&(x-1)) == 0);     
      }public long max(long x,long y){
            return (long)Math.max(x,y);
      }
      public int max(int x,int y){
            return (int)Math.max(x,y);
      }
      public double max(double x,double y){
            return Math.max(x,y);
      }long sqrt(long x){
            return (long)Math.sqrt(x);
      }int sqrt(int x){
            return (int)Math.sqrt(x);
      }void input(int[] ar,int n){
            for(int i=0;i<n;i++)ar[i]=ni();
      }void input(long[] ar,int n){
            for(int i=0;i<n;i++)ar[i]=nl();
      }void fill(int[] ar,int k){
            Arrays.fill(ar,k);
      }void yes(){
            pl("YES");
      }void no(){
            pl("NO");
      }
    int[] sieve(int n) 
    { 
        boolean prime[] = new boolean[n+1]; 
        int[] k=new int[n+1];
        for(int i=0;i<=n;i++) {
            prime[i] = true; 
            k[i]=i;
        }
          
        for(int p = 2; p <=n; p++) 
        { 
            if(prime[p] == true) 
            { 
               // sieve[p]=p;
                for(int i = p*2; i <= n; i += p) {
                    prime[i] = false; 
                  //  sieve[i]=p;
                    while(k[i]%(p*p)==0){
                          k[i]/=(p*p);
                    }
                }
            } 
        }return k;
    }
    int strSmall(int[] arr, int target)  
    {  
        int start = 0, end = arr.length-1;  
        int ans = -1;  
        while (start <= end) {  
            int mid = (start + end) / 2;   
            if (arr[mid] >= target) {  
                end = mid - 1;  
            }   
            else {  
                ans = mid;  
                start = mid + 1;  
            }  
        }  
        return ans;  
    } int strSmall(ArrayList<Integer> arr, int target)  
    {  
        int start = 0, end = arr.size()-1;  
        int ans = -1;  
        while (start <= end) {  
            int mid = (start + end) / 2;   
            if (arr.get(mid) > target) {  
                start = mid + 1; 
                ans=start;
            }   
            else {
                end = mid - 1;  
            }  
        }  
        return ans;  
    }long mMultiplication(long a,long b) 
    { 
        long res = 0;    
        a %= mod; 
  
        while (b > 0)  
        {  
            if ((b & 1) > 0)  
            { 
                res = (res + a) % mod; 
            }  
            a = (2 * a) % mod; 
  
            b >>= 1;  
        } 
        return res; 
    }long nCr(int n, int r,
                             long p)
    {
 
          if (n<r) 
              return 0;
        if (r == 0)
            return 1;
            long[] fac = new long[n + 1];
        fac[0] = 1;
 
        for (int i = 1; i <= n; i++)
            fac[i] = fac[i - 1] * i % p;
        return (fac[n] * modInverse(fac[r], p)
                % p * modInverse(fac[n - r], p)
                % p)
            % p;
    }long power(long x, long y, long p)
    {
        long res = 1;
        x = x % p;
 
        while (y > 0) {
            if (y % 2 == 1)
                res = (res * x) % p;
            y = y >> 1; 
            x = (x * x) % p;
        }
 
        return res;
    }long modInverse(long n, long p)
    {
        return power(n, p - 2, p);
    }
      public static class Pair implements Comparable<Pair> {
		int x;
		int y;
 
		public Pair(int x, int y) {
			this.x = x;
			this.y = y;
		}
 
		public String toString() {
			return x + "," + y;
		}
 
		public boolean equals(Object o) {
			if (o instanceof Pair) {
				Pair p = (Pair) o;
				return p.x == x && p.y == y;
			}
			return false;
		}
 
		public int hashCode() {
			return new Double(x).hashCode() * 31 + new Double(y).hashCode();
		}
 
		public int compareTo(Pair other) {
			if (this.x == other.x) {
				return Long.compare(this.y, other.y);
			}
			return Long.compare(this.x, other.x);
		}
      }
	 
} 