There is a binary string a of length n. In one operation, you can select any prefix of a with an equal number of 0 and 1 symbols. Then all symbols in the prefix are inverted: each 0 becomes 1 and each 1 becomes 0.

For example, suppose a=0111010000. 

  * In the first operation, we can select the prefix of length 8 since it has four 0's and four 1's: [01110100]00→ [10001011]00. 
  * In the second operation, we can select the prefix of length 2 since it has one 0 and one 1: [10]00101100→ [01]00101100. 
  * It is illegal to select the prefix of length 4 for the third operation, because it has three 0's and one 1. 



Can you transform the string a into the string b using some finite number of operations (possibly, none)?

Input

The first line contains a single integer t (1≤ t≤ 10^4) — the number of test cases.

The first line of each test case contains a single integer n (1≤ n≤ 3⋅ 10^5) — the length of the strings a and b.

The following two lines contain strings a and b of length n, consisting of symbols 0 and 1.

The sum of n across all test cases does not exceed 3⋅ 10^5.

Output

For each test case, output "YES" if it is possible to transform a into b, or "NO" if it is impossible. You can print each letter in any case (upper or lower).

Example

Input


5
10
0111010000
0100101100
4
0000
0000
3
001
000
12
010101010101
100110011010
6
000111
110100


Output


YES
YES
NO
YES
NO

Note

The first test case is shown in the statement.

In the second test case, we transform a into b by using zero operations.

In the third test case, there is no legal operation, so it is impossible to transform a into b.

In the fourth test case, here is one such transformation: 

  * Select the length 2 prefix to get 100101010101. 
  * Select the length 12 prefix to get 011010101010. 
  * Select the length 8 prefix to get 100101011010. 
  * Select the length 4 prefix to get 011001011010. 
  * Select the length 6 prefix to get 100110011010. 



In the fifth test case, the only legal operation is to transform a into 111000. From there, the only legal operation is to return to the string we started with, so we cannot transform a into b.


import java.io.*;
import java.util.*;

public class HashMaps {
	
	public static void main(String[] args){
    	FastReader();
		int t = ni();
		while(t>0)
		{
			
			solve();
			
			--t;
		}
		write.flush();
		write.close();
	}
	
    static void solve()
	{
    	int n=ni();
    	String a=nx();
    	String b=nx();

    	int z=0;
    	int o=0;
    	Map<Integer,Boolean> mp=new HashMap<>();
    	for(int i=0;i<n;++i)
    	{
    		if(a.charAt(i)=='0')
    		{
    			++z;
    		}
    		else
    		{
    			++o;
    		}
    		if(z==o)
    		{
    			mp.put(i, true);
    		}
    		else
    		{
    			mp.put(i, false);
    		}
    	}
    	
    	boolean change=false;
    	int p=0;
    	int last=n-1;
    	while(p!=-1) 
    	{
    		p=brk(a, b, change,last);
    		if(p==-1)
    		{
    			break;
    		}
    		boolean fi=mp.get(p);
    		if(!fi)
    		{
    			break;
    		}
    		change=!change;
    		last=p;
    	}
    	if(p==-1)
    	{
    		out("YES");
    	}
    	else
    	{
    		out("NO");
    	}
    			
	}
    
    //NECESSARY FUNCTIONS
    static int brk(String a,String b,boolean change,int last)
    {
    	int p=-1;
        if(!change)
        {
        	for(int i=last;i>=0;--i)
            {
            	if(a.charAt(i)!=b.charAt(i))
            	{
            		p=i;
            		break;
            	}
            }
        }
        else
        {
        	for(int i=last;i>=0;--i)
            {
            	if(a.charAt(i)==b.charAt(i))
            	{
            		p=i;
            		break;
            	}
            }
        }
        return p;
    }
    
  
    
    
	
											//CONSTANTS//
    static final int MOD = (int) 1e9 + 7;
	
											//INPUT//
    
	static BufferedReader br; 
    static StringTokenizer st;
    
    public static void FastReader() 
    { 
        br = new BufferedReader(new
                 InputStreamReader(System.in)); 
    } 
    
    //STRING INPUT
    static String nx()           
    { 
        while (st == null || !st.hasMoreElements()) 
        { 
            try
            { 
                st = new StringTokenizer(br.readLine()); 
            } 
            catch (IOException  e) 
            { 
                e.printStackTrace(); 
            } 
        } 
        return st.nextToken(); 
    } 
    
    //STRING(WITH SPACES) INPUT
    static String nln()    		
    { 
        String str = ""; 
        try
        { 
            str = br.readLine(); 
        } 
        catch (IOException e) 
        { 
            e.printStackTrace(); 
        } 
        return str; 
    } 
    
    //INTEGER INPUT
    static int ni()             
    { 
        return Integer.parseInt(nx()); 
    } 
    
    //LONG INPUT
    static long nl() 			
    { 
        return Long.parseLong(nx()); 
    } 
    
    //DOUBLE INPUT
    static double nd()			 
    { 
        return Double.parseDouble(nx()); 
    } 

    //ARRAY INPUT
    static int[] ina(int n) 	
    {
		int[] temp = new int[n];
		
		for (int i = 0; i < n; i++) 
		{
			temp[i] = ni();
		}
		
		return temp;
	}
    
    //LONG ARRAY INPUT
    static long[] inal(int n) 	
    {
		long[] temp = new long[n];
		
		for (int i = 0; i < n; i++) 
		{
			temp[i] = ni();
		}
		
		return temp;
	}
    
    										//OUTPUT//
    
    static PrintWriter write= new PrintWriter(System.out);
    
    //OUTPUT NEXTLINE
    static void out()	
    { 
        write.println();
    }
    
    //ARRAY OUTPUT WITH NEXTLINE
    static void out(int[] ar) 	
    { 
        for(int e: ar)
        {
        	write.print(e+" ");
        }
        write.println();
    } 
    
    //LONG ARRAY OUTPUT WITH NEXTLINE
    static void out(long[] ar) 	
    { 
        for(long e: ar)
        {
        	write.print(e+" ");
        }
        write.println();
    }
    
    //OBJECT OUTPUT WITH NEXTLINE
    static void out(Object obj)	
    { 
        write.println(obj);
    }
    
    //ARRAY OUTPUT WITHOUT NEXTLINE
    static void ou(int[] ar)	
    { 
        for(int e: ar)
        {
        	write.print(e+" ");
        }
    }
    
    //LONG ARRAY OUTPUT WITH NEXTLINE
    static void ou(long[] ar) 	
    { 
        for(long e: ar)
        {
        	write.print(e+" ");
        }
    }
    
    //OBJECT INPUT WITHOUT NEXTLINE
    static void ou(Object obj)	
    { 
        write.print(obj);
    }
    
    										//SEARCHING ALGORITHMS//
    
    //BINARY SEARCH
    static int bs(int arr[], int x) 
    { 
        int l = 0, r = arr.length - 1; 
        while (l <= r) { 
            int m = l + (r - l) / 2; 
            if (arr[m] == x) 
                return m; 
            if (arr[m] < x) 
                l = m + 1; 
            else
                r = m - 1; 
        } 
        return -1; 
    }
    
    static int bs(long arr[], int x) 
    { 
        int l = 0, r = arr.length - 1; 
        while (l <= r) { 
            int m = l + (r - l) / 2;  
            if (arr[m] == x) 
                return m; 
            if (arr[m] < x) 
                l = m + 1; 
            else
                r = m - 1; 
        } 
        return -1; 
    }
    
    										//SORTING ALGORITHMS//
    
    //MERGE SORT
    static void sort(int arr[], int l, int m, int r)
    {
        int n1 = m - l + 1;
        int n2 = r - m;
        int L[] = new int[n1];
        int R[] = new int[n2];
        for (int i = 0; i < n1; ++i)
            L[i] = arr[l + i];
        for (int j = 0; j < n2; ++j)
            R[j] = arr[m + 1 + j];
        int i = 0, j = 0;
        int k = l;
        while (i < n1 && j < n2) {
            if (L[i] <= R[j]) {
                arr[k] = L[i];
                i++;
            }
            else {
                arr[k] = R[j];
                j++;
            }
            k++;
        }
        while (i < n1) {
            arr[k] = L[i];
            i++;
            k++;
        }
        while (j < n2) {
            arr[k] = R[j];
            j++;
            k++;
        }
    }
 
    static void merge(int arr[], int l, int r)
    {
        if (l < r) {
            int m =l+ (r-l)/2;
            merge(arr, l, m);
            merge(arr, m + 1, r);
            sort(arr, l, m, r);
        }
    }
    
    //BUBBLE SORT
    static void bubble(int arr[]) 
    { 
        int n = arr.length; 
        for (int i = 0; i < n-1; i++)
        {
            for (int j = 0; j < n-i-1; j++)
            {
                if (arr[j] > arr[j+1]) 
                {
                    int temp = arr[j]; 
                    arr[j] = arr[j+1]; 
                    arr[j+1] = temp; 
                } 
            }
        }
    }
    
    										//OTHER FUNCTIONS//
    
    //FUNCTION TO COUNT NO. OF DIGITS
    static int countDigit(long n)
    {
        int count = 0;
        while (n != 0) {
            n = n / 10;
            ++count;
        }
        return count;
    }
    
    //FUNCTION TO CALCULATE SUM OF DIGITS
    static int sumOfDigits(int n) 
    {     
        int sum = 0;   
        while (n != 0) 
        { 
            sum = sum + n % 10; 
            n = n/10; 
        } 
        return sum; 
    }
    
    //FUNCTION TO FIND SUM OF ARRAY ELEMENTS
    static long arraySum(int[] arr , int start , int end)
    {
        long sum = 0 ;
        for(int i = start ; i <= end  ; ++i)
        {
        	sum = sum + arr[i] ;
        }
        return sum  ;
    }
    
    //FUNCTION TO CALCULATE FACTORIAL
    static int fact(int n) 
    { 
        if (n == 0) 
          return 1; 
        return n*fact(n-1); 
    }
    
    //FUNCTION TO CHECK POWER OF TWO
    static boolean isPowerOfTwo(int n)
    {
        if(n==0)
        return false;
        return (int)(Math.ceil((Math.log(n) / Math.log(2)))) == 
           (int)(Math.floor(((Math.log(n) / Math.log(2)))));
    }
    
    //FUNCTION TO REVERSE A STRING
    static String reverse(String str)
    {
    	StringBuilder input = new StringBuilder();
        input.append(str);
        input.reverse();
        return input.toString();
    }
    
    //FUNCTION TO CALCULATE GCD
    public static int gcd(int a, int b)
    {
        if (a == 0)
            return b;
        return gcd(b%a, a);
    }
    
    public static long gcd(long a, long b)
    {
        if (a == 0)
            return b;
        return gcd(b%a, a);
    }
    
    //FUNCTION TO CALCULATE LCM
    static int lcm(int a, int b) 
    { 
        return (a / gcd(a, b)) * b; 
    }
    
    static long lcm(long a, long b) 
    { 
        return (a / gcd(a, b)) * b; 
    }
    
    //FUNCTION TO CHECK PRIME OR NOT
    static boolean isPrime(int n) 
    { 
        if (n <= 1) 
            return false; 
        if (n <= 3) 
            return true; 
        if (n % 2 == 0 || n % 3 == 0) 
            return false; 
        for (int i = 5; i * i <= n; i = i + 6) 
            if (n % i == 0 || n % (i + 2) == 0) 
                return false; 
        return true; 
    }
    
    //FUNCTION TO CALCULATE NCR    
    static long nCr(int n, int r) 
    { 
        return fact(n) / (fact(r) * 
                      fact(n - r)); 
    }

}
