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.*;
import java.math.*;
import java.math.BigInteger; 
//import javafx.util.*; 
public final class B
{    
	static StringBuilder ans=new StringBuilder();
	static FastReader in=new FastReader();
	static ArrayList<ArrayList<Integer>> g,CARS,intersection;	
	static long mod=1000000007;
	static int D1[],D2[],par[];
	static boolean set[];
	static long INF=Long.MAX_VALUE;
	static int dp[][];
	public static void main(String args[])throws IOException
	{  		
		int T=i();
		outer:while(T-->0)
		{
			int N=i();
			char A[]=in.next().toCharArray();
			char B[]=in.next().toCharArray();
			char A_flip[]=new char[N];
			int f[]=new int[N];
			for(int i=0; i<N; i++)
			{
				int x=A[i]-'0';
				f[i]=x;
				if(i>0)f[i]+=f[i-1];
				x=(x+1)%2;
				if(x==1)A_flip[i]='1';
				else A_flip[i]='0';
			}
//			print(A); print(A_flip);
//			print(f); 
			boolean flag=true;
			for(int i=N-1; i>=0; i--)
			{
				if(flag)
				{
					if(A[i]!=B[i])
					{
						if(f[i]*2!=i+1)
						{
							System.out.println("NO");
							continue outer;
						}
						flag=false;
					}
				}
				else
				{
					if(A_flip[i]!=B[i])
					{
						if(f[i]*2!=i+1)
						{
							System.out.println("NO");
							continue outer;
						}
						flag=true;
					}
				}
			}
			System.out.println("YES");
			
		}
	}
	static boolean f(int A[],int B[])
	{
		for(int i=0; i<A.length; i++)if(A[i]!=B[i])return false;
		return true;
	}
	static int[] merge(int A[],int B[],int N)
	{
		int C[]=new int[N*2];
		int i=0,j=0,index=0;
		while(i<N && j<N)
		{
			if(A[i]<B[i])C[index++]=A[i++];
			else C[index++]=B[j++];
		}
		while(i<N)C[index++]=A[i++];
		while(j<N)C[index++]=B[j++];
		return C;
	}
	static boolean valid(int A[])
	{
		for(int i=1; i<=A.length; i++)
		{
			if(A[i-1]!=i)return false;
		}
		return true;
	}
	static void f(int A[],int i,int j)
	{
		while(i<j)
		{
			//swap i & j
			int t=A[i];
			A[i]=A[j];
			A[j]=t;
			i++;
			j--;
		}
		//print(A);
	}
	static boolean valid(long a,long b,long c)
	{
		if(a<=c && b>=c)return true;
		return false;
	}
	static boolean ispalin(char X[],int l,int r)
	{
		while(l<r)
		{
			if(X[l]!=X[r])return false;
			l++; r--;
		}
		return true;
	}

	static long min(long a,long b,long c)
	{
		return Math.min(a, Math.min(c, b));
	}
	static void dfs(int n)
	{
		set[n]=true;
		for(int c:g.get(n))
		{
			if(!set[c])dfs(c);
		}
	}
	static void print(int a)
	{
		System.out.println("! "+a);
	}
	static int ask(int a,int b)
	{
		System.out.println("? "+a+" "+b);
		return i();
	}
	static int find(int a)
	{
		if(par[a]<0)return a;
		return par[a]=find(par[a]);
	}
	static void union(int a,int b)
	{
		a=find(a);
		b=find(b);
		if(a!=b)
		{
			par[a]+=par[b]; //transfers the size
			par[b]=a;       //changes the parent
		}
	}
	static ArrayList<Integer> IND(int B[],HashMap<Integer,Integer> mp)
	{
		ArrayList<Integer> A=new ArrayList<>();
		for(int i:B)
		{
			if(mp.containsKey(i))
			{
				A.add(i);
				int f=mp.get(i)-1;
				if(f==0)
					mp.remove(i);
				else mp.put(i, f);		
			}
		}
		return A;
	}
	static HashMap<Integer,Integer> hash(int A[],int index)
	{
		HashMap<Integer,Integer> mp=new HashMap<Integer,Integer>();
		for(int i=index; i<A.length; i++)
		{
			int f=mp.getOrDefault(A[i], 0)+1;
			mp.put(A[i], f);
		}
		return mp;
	}
	static void swap(char A[],int a,int b)
	{
		char ch=A[a];
		A[a]=A[b];
		A[b]=ch;
	}

	static long lower_Bound(long A[],int low,int high, long x) 
	{ 
		if (low > high) 
			if (x >= A[high]) 
				return A[high]; 

		int mid = (low + high) / 2; 

		if (A[mid] == x) 
			return A[mid]; 

		if (mid > 0 && A[mid - 1] <= x && x < A[mid]) 
			return A[mid - 1]; 

		if (x < A[mid]) 
			return lower_Bound( A, low, mid - 1, x); 

		return lower_Bound(A, mid + 1, high, x); 
	} 
	static void sort(long[] a) //check for long
	{
		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);
	}
	static void setGraph(int N)
	{
		g=new ArrayList<ArrayList<Integer>>();
		intersection=new ArrayList<ArrayList<Integer>>();
		CARS=new ArrayList<ArrayList<Integer>>();
		for(int i=0; i<=N; i++)
		{
			CARS.add(new ArrayList<Integer>());
			intersection.add(new ArrayList<Integer>());
			g.add(new ArrayList<Integer>());

		}
	}

	static  long pow(long a,long b)
	{
		long mod=1000000007;
		long pow=1;
		long x=a;
		while(b!=0)
		{
			if((b&1)!=0)pow=(pow*x)%mod;
			x=(x*x)%mod;
			b/=2;
		}
		return pow;
	}
	static long toggleBits(long x)//one's complement || Toggle bits
	{
		int n=(int)(Math.floor(Math.log(x)/Math.log(2)))+1;

		return ((1<<n)-1)^x;
	}
	static int countBits(long a)
	{
		return (int)(Math.log(a)/Math.log(2)+1);
	}
	static 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);
	}
	static boolean isPrime(long 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; 
	}
	static long GCD(long a,long b) 
	{
		if(b==0)
		{
			return a;
		}
		else return GCD(b,a%b );
	}

	//Debugging Functions Starts

	static void print(char A[])
	{
		for(char c:A)System.out.print(c+" ");
		System.out.println();
	}
	static void print(boolean A[])
	{
		for(boolean c:A)System.out.print(c+" ");
		System.out.println();
	}
	static void print(int A[])
	{
		for(int a:A)System.out.print(a+" ");
		System.out.println();	
	}
	static void print(long A[])
	{
		for(long i:A)System.out.print(i+ " ");
		System.out.println();

	}
	static void print(ArrayList<Integer> A)
	{
		for(int a:A)System.out.print(a+" ");
		System.out.println();
	}

	//Debugging Functions END
	//----------------------
	//IO FUNCTIONS STARTS
	static HashMap<Integer,Integer> Hash(int A[])
	{
		HashMap<Integer,Integer> mp=new HashMap<>();
		for(int a:A)
		{
			int f=mp.getOrDefault(a,0)+1;
			mp.put(a, f);
		}
		return mp;
	}
	static int i()
	{
		return in.nextInt();
	}

	static long l()
	{
		return in.nextLong();
	}

	static int[] input(int N){
		int A[]=new int[N];
		for(int i=0; i<N; i++)
		{
			A[i]=in.nextInt();
		}
		return A;
	}

	static long[] inputLong(int N)     {
		long A[]=new long[N];
		for(int i=0; i<A.length; i++)A[i]=in.nextLong();
		return A;
	}

	//IO FUNCTIONS END

}
class pir{
	int a, b;
	pir(int a, int b)
	{
		this.a=a;
		this.b=b;
	}
}

//Code For FastReader
//Code For FastReader
//Code For FastReader
//Code For FastReader
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;
	}

}
