#include <iostream>
#include <string>
using namespace std;

int min_el(int array[], int n);

int main()
{
	int t; // кол-во тестов
	cin >> t;

	for (int i = 0; i < t; i++)
	{
		int n; // количество столбцов на поле тетриса
		cin >> n;

		int* a = new int[n]; // высота каждого столбца

		for (int j = 0; j < n; j++)
		{
			cin >> a[j]; // вводим высоту столбца
		}

		// T E T R I S

		string answer = "NO";

		for (int c = 0; c < n; c++)
		{
			// прибавили один столбик
			if (a[c] <= n - 1)
				a[c] = a[c] + 2;
			// минимальное заполнение в рядке
			int min = min_el(a, n);
			if (min != 0) // у каждого столбика есть этот минимум, отличный от нуля
			{
				for (int d = 0; d < n; d++)
					a[d] = a[d] - min; // минус строчки в тетрисе
			}

			// проверка на завершение игры (все столбики равны меж собою)
			bool flag = true;
			int e = a[0];
			for (int g = 0; g < n; g++)
				if (a[g] != e) // какой-то столбик пидор
				{
					flag = false;
					break;
				}
			if (flag)
			{
				answer = "YES";
				break;
			}
		}
		cout << answer << endl;
		delete[] a;
	}

	return 0;
}

int min_el(int array[], int n)
{
	int a = array[0];
	for (int i = 1; i < n; i++)
		if (array[i] < a)
			a = array[i];
	return a;
}


#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long MOD = 998244353;

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

	int n;
	cin >> n;
	rep(i, n) {
		int t;
		cin >> t;
		vector<int> a(t);

		int maxNum = 0;
		rep(j, t) {
			cin >> a[j];
			maxNum = max(maxNum, a[j]);
		}

		bool flag = false;
		rep(i, t) {
			if (maxNum - a[i] % 2 != 0) {
				flag = true;
				break;
			}
		}

		if (flag) cout << "YES" << "\n";
		else cout << "NO" << "\n";
	}

	return 0;
}


#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long MOD = 998244353;

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

	int n;
	cin >> n;
	rep(i, n) {
		int t;
		cin >> t;
		vector<int> a(t);

		int maxNum = 0;
		rep(j, t) {
			cin >> a[j];
			maxNum = max(maxNum, a[j]);
		}

		bool flag = false;
		rep(i, t) {
			if ((maxNum - a[i]) % 2 != 0) {
				flag = true;
				break;
			}
		}

		if (flag) cout << "NO" << "\n";
		else cout << "YES" << "\n";
	}

	return 0;
}


#include <iostream>
using namespace std;

int main()
{
    int t;
    cin >> t;

    for (int i = 0; i < t; i++)
    {
        bool chet = false;
        bool nech = false;
        int n;
        cin >> n;
        for (int j = 0; j < n; j++)
        {
            int tmp;
            cin >> tmp;
            if (tmp % 2 == 0)
            {
                chet = true;
            }
            else
                nech = true;
        }
        if (chet != nech) cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
}


#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

int main()
{
    int t;
    cin >> t;
    while(t--) {
        int n;
        cin >> n;
        vector<int> a(n);
        for(int i = 0; i < n; i++) {
            cin >> a[i];
        }
        sort(a.begin(),a.end());
        reverse(a.begin(),a.end());
        int m = a[0];
        bool fl = true;
        for(int j = 1; j < n; j++) {
            if(abs(m-a[j])%2) {
                fl = false;
            }
        }
        if(fl) {
            cout << "YES\n";
        }
        else {
            cout << "NO\n";
        }
    }

    return 0;
}


#include<iostream>
#include <vector>

using namespace std;

int main(){
    int a;
    cin >> a;
    for(int i=0;i<a;i++){
        int b;
        cin >> b;
        vector<int> vec(b);
        for(int n =0;n<b;n++){
            cin >> vec[n];
        }
        int max=0;
        for(int n =0;n<b;n++){
            if(max<vec[n])max=vec[n];
        }
        int min=10000;
        for(int n =0;n<b;n++){
            if(min>vec[n])min=vec[n];
        }

        int count =max-min;

        if(count%2==0)cout << "YES"<< endl;
        else cout << "NO"<< endl;

    }

}


#include<bits/stdc++.h>
using namespace std;

int main(){
    int a;
    cin >> a;
    for(int i=0;i<a;i++){
        int b;
        cin >> b;
        vector<int> vec(b);
        for(int n =0;n<b;n++){
            cin >> vec[n];
        }
        int max = *std::max_element(vec.begin(), vec.end());
        int count =0;
        for(int n =0;n<b;n++){
             count= count+ max-vec[n];
        }
        if(count%2==0)cout << "YES"<< endl;
        if(count%2!=0)cout << "NO"<< endl;

    }

}


#include<iostream>
#include <vector>

using namespace std;

int main(){
    int a;
    cin >> a;
    for(int i=0;i<a;i++){
        int b;
        cin >> b;
        vector<int> vec(b);
        for(int n =0;n<b;n++){
            cin >> vec[n];
        }
        int max=vec[0];
        for(int n =0;n<b;n++){
            if(max<vec[n])max=vec[n];
        }

        for(int n =0;n<b;n++){
            int count = max-vec[n];
            if(count%2!=0){
                cout << "NO" << endl;
                break;
            }

        }
        cout << "YES" << endl;

    }

}


#include<iostream>
#include <vector>

using namespace std;

int main(){
    int a;
    cin >> a;
    for(int i=0;i<a;i++){
        int b;
        cin >> b;
        vector<int> vec(b);
        for(int n =0;n<b;n++){
            cin >> vec[n];
        }
        int max = *std::max_element(vec.begin(), vec.end());
        int count =0;
        for(int n =0;n<b;n++){
             count= count+ max-vec[n];
        }
        if(count%2==0)cout << "YES"<< endl;
        if(count%2!=0)cout << "NO"<< endl;

    }

}


#include<iostream>
#include <vector>

using namespace std;

int main(){
    int a;
    cin >> a;
    for(int i=0;i<a;i++){
        int b;
        cin >> b;
        vector<int> vec(b);
        for(int n =0;n<b;n++){
            cin >> vec[n];
        }
        int max=0;
        for(int n =0;n<b;n++){
            if(max<vec[n])max=vec[n];
        }
        int min=0;
        for(int n =0;n<b;n++){
            if(min>vec[n])max=vec[n];
        }

        int count =0;
        for(int n =0;n<b;n++){
             count= count+ max-vec[n];
        }
        if(count%2==0)cout << "YES"<< endl;
        else cout << "NO"<< endl;

    }

}


#include<iostream>
#include <vector>

using namespace std;

int main(){
    int a;
    cin >> a;
    for(int i=0;i<a;i++){
        int b;
        cin >> b;
        vector<int> vec(b);
        for(int n =0;n<b;n++){
            cin >> vec[n];
        }
        int max=0;
        for(int n =0;n<b;n++){
            if(max<vec[n])max=vec[n];
        }
        int min=0;
        for(int n =0;n<b;n++){
            if(min>vec[n])min=vec[n];
        }

        int count =max-min;
       // for(int n =0;n<b;n++){
       //      count= count+ max-vec[n];
       // }
        if(count%2==0)cout << "YES"<< endl;
        else cout << "NO"<< endl;

    }

}


#include<iostream>
#include <vector>

using namespace std;

int main(){
    int a;
    cin >> a;
    for(int i=0;i<a;i++){
        int b;
        cin >> b;
        vector<int> vec(b);
        for(int n =0;n<b;n++){
            cin >> vec[n];
        }
        int max=vec[0];
        for(int n =0;n<b;n++){
            if(max<vec[n])max=vec[n];
        }
        int kekka = 1;
        for(int n =0;n<b;n++){
            int count = max-vec[n];
            if(count%2!=0){
               kekka=0;
            }

        }
        if(kekka==1) cout << "YES" << endl;
        if(kekka==0) cout << "NO" << endl;

    }

}


#include<iostream>
#include <vector>

using namespace std;

int main(){
    int a;
    cin >> a;
    for(int i=0;i<a;i++){
        int b;
        cin >> b;
        vector<int> vec(b);
        for(int n =0;n<b;n++){
            cin >> vec[n];
        }
        int kekka=1;
        for(int n=0;n<b;n++){
            for(int x=0;x<b;x++){
                int count=abs(vec[n]-vec[x]);
                if(count!=0 && count%2!=0){kekka=0;}
            }
        }
        if(kekka==1) cout << "YES" << endl;
        if(kekka==0) cout << "NO" << endl;
    }

}


#include<iostream>
#include <vector>

using namespace std;

int main(){
    int a;
    cin >> a;
    for(int i=0;i<a;i++){
        int b;
        cin >> b;
        vector<int> vec(b);
        for(int n =0;n<b;n++){
            cin >> vec[n];
        }
        int max=0;
        for(int n =0;n<b;n++){
            if(max<vec[n])max=vec[n];
        }
        int min=0;
        for(int n =0;n<b;n++){
            if(min>vec[n])max=vec[n];
        }

        int count =max-min;
       // for(int n =0;n<b;n++){
        //     count= count+ max-vec[n];
        //}
        if(count%2==0)cout << "YES"<< endl;
        if(count%2!=0)cout << "NO"<< endl;

    }

}


#include<iostream>
#include <vector>

using namespace std;

int main(){
    int a;
    cin >> a;
    for(int i=0;i<a;i++){
        int b;
        cin >> b;
        vector<int> vec(b);
        for(int n =0;n<b;n++){
            cin >> vec[n];
        }
        int max=0;
        for(int n =0;n<b;n++){
            if(max<vec[n])max=vec[n];
        }

        int count =0;
        for(int n =0;n<b;n++){
             count= count+ max-vec[n];
        }
        if(count%2==0)cout << "YES"<< endl;
        if(count%2!=0)cout << "NO"<< endl;

    }

}


#include <iostream>

using namespace std;

int main()
{
    short t;
    int n;
    short a[101];
    bool bad_case;

    std::cin >> t;

    while (t > 0)
    {
        bad_case = false;
        std::cin >> n;
        for (int i = 0; i < n; i++)
        {
            std::cin >> a[i];
        }
        for (int i = 0; i < n - 1; i++)
        {
            if ((a[i] - a[i+1]) % 2)
            {
               bad_case = true;
               break;
            }
        }
        std::cout << (bad_case ? "NO" : "YES");
        t--;
    }
}


#include <iostream>

using namespace std;

int main()
{
    short t;
    int n;
    short a[101];
    bool bad_case;

    std::cin >> t;

    while (t > 0)
    {
        bad_case = false;
        std::cin >> n;
        for (int i = 0; i < n; i++)
        {
            std::cin >> a[i];
        }
        for (int i = 0; i < n - 1; i++)
        {
            if ((a[i] - a[i+1]) % 2)
            {
               bad_case = true;
               break;
            }
        }
        std::cout << (bad_case ? "NO" : "YES") << std::endl;
        t--;
    }
}


#include <stdio.h>
#include <iostream>
using namespace std;
#include <algorithm>
int main()
{int q,j;
cin>>q;
for(j=0;j<q;j++)
   {int a ,*p,b=0,c=0,i;
   cin>>a;
   p=(int*)calloc(a,sizeof(int));
   for(i=0;i<a;i++)
   {cin>>*(p+i);}
    b=*(std::max_element(p,p+a-1));
    for(i=0;i<a;i++)
    {if((b-*(p+i))%2!=0)
    {c=1;
    break;}}
    if(c==0)
  {cout<<"YES";}
  if(c==1)
  {cout<<"NO";}
cout<<endl;

   }
    return 0;
}


#include<iostream>
using namespace std;

int main() {
	unsigned int t;
	unsigned int n;
	unsigned int a, *check;

	cin >> t;
	check = new unsigned int[t];

	for (unsigned int i = 0; i < t; i++) {
		cin >> n;
			unsigned b;
			check[i] = 1;
			for (unsigned j = 0; j < n; j++) {
				cin >> a;
				if (n == 1) break;
				if (j == 0) b = a;
				else {
					if ((a - b) % 2 != 0) {
						check[i] = 0;
					}
				}

			}
	}
	for (unsigned int i = 0; i < t; i++)
		if (check[i] == 1) cout << "YES" << endl;
		else cout << "NO" << endl;
	delete(check);
}


#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <list>
#include <set>
#include <deque>
#include <queue>
#include <algorithm>

using namespace std;

int main()
{
	int t;
	cin >> t;

	for (int i = 0; i < t; i++) {

		int n;
		vector<int> a;

		cin >> n;
		a.resize(n);
		for (int j = 0; j < n; j++)
			cin >> a[j];

		if (n == 1) {
			cout << "YES" << endl;
			continue;
		}

		bool answered = false;
		for (int j = 1; j < n; j++)
		{
			if (a[0] % 2 == 0) {
				if (a[j] % 2 == 1) {
					cout << "NO" << endl;
					answered = true;
					break;
				}
			}
			else {
				if (a[j] % 2 == 0) {
					cout << "NO" << endl;
					answered = true;
					break;
				}
			}
		}
		if (!answered)
			cout << "YES" << endl;

	}

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

/*int BinarySearch(vector <int>v3,int n, int x){
      int low=0;
      int high=(n-1);
      while(low<=high){
         int mid=(low+high)/2;
          if(x==v3[mid]) return mid;
          if(x<v3[mid]) high=mid-1;
          if(x>v3[mid]) low=mid+1;
      }
    return -1;
}*/
/*long long int Power10(int q){
    long long int o,t=1;
    for(o=0;o<q;o++)
        {t*=10;}
    return t;
}*/
/*int digit(char ch){
    return(ch - '0');
}*/

int main(){
    long long int x,n,h,m,i,j,w,l,a,b,k,count=0,count2=0,count1=0,a1,a2;
    long long int min=1000;
    string s;
    vector<long long int> v;
    vector<long long int> v2;
    cin>>a2;
    while(a2--){
    cin>>n;
    for(i=0;i<n;i++){
        cin>>x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    for(i=0;i<n-1;i++){
        if((v[n-1]-v[i])%2==0){count++;}
        else{count=0;
            break;
        }
    }
    if(count!=0){cout<<"YES"<<endl;}
    if(count==0){cout<<"NO"<<endl;}
    v.clear();}
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

/*int BinarySearch(vector <int>v3,int n, int x){
      int low=0;
      int high=(n-1);
      while(low<=high){
         int mid=(low+high)/2;
          if(x==v3[mid]) return mid;
          if(x<v3[mid]) high=mid-1;
          if(x>v3[mid]) low=mid+1;
      }
    return -1;
}*/
/*long long int Power10(int q){
    long long int o,t=1;
    for(o=0;o<q;o++)
        {t*=10;}
    return t;
}*/
/*int digit(char ch){
    return(ch - '0');
}*/

int main(){
    long long int x,n,h,m,i,j,w,l,a,b,k,count=0,count2=0,count1=0,a1,a2;
    long long int min=1000;
    string s;
    vector<long long int> v;
    vector<long long int> v2;
    cin>>a2;
    while(a2--){
    cin>>n;
    for(i=0;i<n;i++){
        cin>>x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    for(i=0;i<=n-1;i++){
        if((v[n-1]-v[i])%2==0){count++;}
        else{count=0;
        break;
        }
    }
    if(count!=0){cout<<"YES"<<endl;}
    if(count==0){cout<<"NO"<<endl;}
    v.clear();}
    return 0;
}


#include <iostream>
#include <stdio.h>
using namespace std;
int t,n,a[105],max1;
int main()
{
	cin>>t;
	for(int i=1;i<=t;i++)
	{
		cin>>n;
		for(int j=1;j<=n;j++)
		{
			cin>>a[j];
			max1=max(max1,a[j]);
		}
		for(int j=1;j<=n;j++)
		{
			if((max1-a[j])%2!=0)
			{
				max1=0;
				break;
			}
		}
		if(max1==0) cout<<"NO"<<endl;
		else cout<<"YES"<<endl;
		max1=0;
	}
	return 0;
}


#include <iostream>
#include <stdio.h>
using namespace std;
int t,n,a[105],max1;
int main()
{
	cin>>t;
	for(int i=1;i<=t;i++)
	{
		cin>>n;
		for(int i=1;i<=n;i++)
		{
			cin>>a[i];
			max1=max(max1,a[i]);
		}
		for(int i=1;i<=n;i++)
		{
			if((max1-a[i])%2!=0)
			{
				max1=0;
				break;
			}
		}
		if(max1==0) cout<<"NO"<<endl;
		else cout<<"YES"<<endl;
		max1=0;
	}
	return 0;
}


#include <iostream>
#include <stdio.h>
using namespace std;
int t,n,a[105];
int main()
{
	cin>>t;
	for(int i=1;i<=t;i++)
	{
		int max1=0;
		cin>>n;
		for(int i=1;i<=n;i++)
		{
			cin>>a[i];
			max1=max(max1,a[i]);
		}
		for(int i=1;i<=n;i++)
		{
			if((max1-a[i])%2!=0)
			{
				max1=0;
				break;
			}
		}
		if(max1==0) cout<<"NO"<<endl;
		else cout<<"YES"<<endl;
	}
	return 0;
}


#include <iostream>
#include <stdio.h>
using namespace std;
int t,n,a[105],max1;
int main()
{
	cin>>t;
	for(int i=1;i<=t;i++)
	{
		cin>>n;
		for(int j=1;j<=n;j++)
		{
			cin>>a[j];
			if(max1<a[j]) max1=a[j];
		}
		for(int j=1;j<=n;j++)
		{
			if((max1-a[j])%2!=0)
			{
				max1=0;
				break;
			}
		}
		if(max1==0) cout<<"NO"<<endl;
		else cout<<"YES"<<endl;
		max1=0;
	}
	return 0;
}


#include<iostream>
#include<vector>
typedef long int ll;
using namespace std;
int main()
{
	vector<ll> vec;
	vector<ll> vaaa;
	ll t, temp_size, min_expect = 99999999999, temp_num;
	cin >> t;
	bool flag_zero, flag_jishu;
	for (ll i = 0; i < t; ++i)
	{
		min_expect = 99999999;
		flag_zero = 0;	//初始无0
		flag_jishu = 0; //初始无奇数
		vec = vaaa;
		cin >> temp_size;
		for (ll j = 0; j < temp_size; ++j)
		{
			cin >> temp_num;
			if (temp_num == 0)
			{
				flag_zero = 1;
			}
			else
			{
				if (temp_num % 2 != 0)
					flag_jishu = 1;
				min_expect = temp_num < min_expect ? temp_num : min_expect;
				vec.push_back(temp_num);
			}
		}
		if (flag_zero && flag_jishu)
			cout << "NO" << endl;
		else if (flag_zero && !flag_jishu)
			cout << "YES" << endl;
		else
		{
			bool flag_fuck = 0;
			for (ll k = 0; k < vec.size(); k++)
			{
				vec[k] -= min_expect;
				if (vec[k] % 2 != 0)
				{
					flag_fuck = 1;
					break;
				}
			}
			if (flag_fuck)
				cout << "NO" << endl;
			else
				cout << "YES" << endl;
		}
	}
	return 0;
}


#include<iostream>
#include<vector>
typedef long int ll;
using namespace std;
int main()
{
	vector<ll> vec;
	vector<ll> vaaa;
	ll t, temp_size, min_expect = 99999999999, temp_num;
	cin >> t;
	bool flag_zero, flag_jishu;
	for (ll i = 0; i < t; ++i)
	{
		min_expect = 99999999;
		flag_zero = 0;	//初始无0
		flag_jishu = 0; //初始无奇数
		vec = vaaa;
		cin >> temp_size;
		for (ll j = 0; j < temp_size; ++j)
		{
			cin >> temp_num;
			if (temp_num == 0)
			{
				flag_zero = 1;
			}
			else
			{
				if (temp_num % 2 != 0)
					flag_jishu = 1;
				min_expect = temp_num < min_expect ? temp_num : min_expect;
				vec.push_back(temp_num);
			}
		}
		if (flag_zero && flag_jishu)
			cout << "NO" << endl;
		else if (flag_zero && !flag_jishu)
			cout << "YES" << endl;
		else
		{
			bool flag_fuck = 0;
			for (ll k = 0; k < vec.size(); k++)
			{
				vec[k] -= min_expect;
				if (vec[k] % 2 != 0)
				{
					flag_fuck = 1;
					break;
				}
			}
			if (flag_fuck)
				cout << "NO" << endl;
			else
				cout << "YES" << endl;
		}
	}
return 0;
}


/*#include<iostream>
#include<cstdio>
#include<string.h>
using namespace std;
int main(){
	int i,t;
	scanf("%d",&t);
	while(t--){
		int n,ji,ou;
		scanf("%d",&n);
		int a[100]={0};
		for(i=ji=ou=0;i<n;i++){
			scanf("%d",a+i);
			if(a[i]%2)
				ji++;
			else
				ou++;
		}
		if(ji && ou)
			printf("NO\n");
		else
			printf("YES\n");
	}
	return 0;
}*/
#include<iostream>
#include<cstdio>
#include<string.h>
#include<algorithm>
using namespace std;
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		int n,an[110];
		scanf("%d",&n);
		//cout<<"n="<<n<<endl;
		for(int i=0;i<n;i++)
            scanf("%d",&an[i]);
        sort(an,an+n);
        bool b=1;
        for(int i=n-1;i>=1;i--){
            if(an[i]-an[i-1]%2==1){
                b=0;
                break;
            }
        }
        if(b==1)
            printf("YES\n");
        else
            printf("NO\n");
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<string.h>
#include<algorithm>
using namespace std;
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		int n,s1=0,s2=0;
		scanf("%d",&n);
		int a[100]={0};
		for(int i=0;i<n;i++){
			scanf("%d",a+i);
			if(a[i]%2)
				s1++;
			else
				s2++;
		}
		if(s1&&s2)
			printf("NO\n");
		else
			printf("YES\n");
	}
	return 0;
}


#include <iostream>
#include <utility>
#include <set>
#include <vector>
#include<algorithm>
using namespace std;

int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n;
		cin >> n;

		if (n == 1)
		{
			int x;
			cin >> x;
			cout << "YES";
		}

		else
		{
			vector<int> a(n);

			bool flag = true;

			cin >> a[0];

			for (int i = 1; i < n; ++i)
			{
				cin >> a[i];

				if ((a[i] % 2) != (a[i - 1] % 2))
				{
					flag = false;
				}
			}

			if (flag) {
				cout << "YES";
			}
			else {
				cout << "NO";
			}
		}
		cout << '\n';
	}

}


#include <iostream>
#include <utility>
#include <set>
#include <vector>
#include<algorithm>
using namespace std;

int main()
{
	int t;
	cin >> t;
	while(t--)
	{
		int n;
		cin >> n;
		if (n == 1)
		{
			cout << "YES";
		}
		else
		{

			vector<int> a(n);

			bool flag = true;

			cin >> a[0];

				for (int i = 1; i < n; ++i)
				{
					cin >> a[i];

					if ((a[i] % 2) != (a[i - 1] % 2))
					{
						flag = false;
					}
				}

				if (flag) {
					cout << "YES";
				}
				else {
					cout << "NO";
				}
		}
		cout << '\n';
	}

}


#include <iostream>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int T;
	cin >> T;

	for (int t = 0; t < T; t++) {
		int X;
		cin >> X;
		if (X == 1) {
			cin >> X;
			cout << "YES\n";
			continue;
		}
		bool yes = true;
		int a = -1;
		for (int x = 0; x < X; x++) {
			int tmp;
			cin >> tmp;
			if (a == -1) {
				a = tmp % 2;
			}
			else {
				if (a != tmp % 2) {
					yes = false;
				}
			}
		}
		if(yes)
			cout << "YES\n";
		else
			cout << "NO\n";
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include<string>
#include<climits>
#define ll long long int
using namespace std;

int main() {
	ll t;
	cin>>t;
	while(t--)
	{
	    int n;
	    cin>>n;
	    int a[101]={0};
        int temp;
        bool in=0;
	    for(int i=0;i<n;i++){
	        cin>>temp;
	        a[temp]++;
	        if(a[temp]==3){
	            cout<<"NO"<<endl;
	            in =1;
	            break;
	        }

	    }
	    if(!in){
	        cout<<"YES"<<endl;
	    }
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include<string>
#include<climits>
#define ll long long int
using namespace std;

int main() {
	ll t;
	cin>>t;
	while(t--)
	{
	    int n;
	    cin>>n;
	    int a[101]={0};
        int temp;
        bool in=0;
	    for(int i=0;i<n;i++){
	        cin>>temp;
	        a[temp]++;
	        if(a[temp]==3){
	            if(i!=2)
	                cout<<"NO"<<endl;
	            else{
	                int r;
	                for(int j=3;j<n;j++){
	                    cin>>r;
	                    if(r!=temp){
	                        cout<<"NO"<<endl;
	                        in=1;
	                        break;
	                    }

	                }
	                if(!in)
	                    cout<<"YES"<<endl;
	            }
	            in =1;
	            break;
	        }

	    }
	    if(!in){
	        cout<<"YES"<<endl;
	    }
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include<string>
#include<climits>
#define ll long long int
using namespace std;

int main() {
	ll t;
	cin>>t;
	while(t--)
	{
	    int n;
	    cin>>n;
        int temp;
        cin>>temp;
        //cout<<temp<<endl;
        bool l=0;
        int in=temp%2;
        int a[100];
        for(int i=1;i<n;i++){
            cin>>a[i];
        }
	    for(int i=1;i<n;i++){
	        //cout<<"in"<<endl;

	        if((a[i]%2)!=in){
	            cout<<"NO"<<endl;
	            l=1;
	            break;
	        }
	    }
	    if(!l){
	        cout<<"YES"<<endl;
	    }
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <numeric>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#include <xfunctional>
#define ll long long
#define mod 1000000007
using namespace std;
int dir[4][2] = { { 0,1 },{ 0,-1 },{ -1,0 },{ 1,0 } };
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf = 0x3f3f3f3f;
const double pi = 3.14159265358979;
int main()
{
	int n;
	cin >> n;
	while (n--)
	{
		int t;
		cin >> t;
		vector<int> a(t);
		for (int i = 0; i < t; i++)
			cin >> a[i];
		if (t == 1)
		{
			cout << "YES" << endl;
			continue;
		}
		for (int i = 1; i < t; i++)
		{
			if (abs(a[i] - a[i - 1]) % 2)
			{
				cout << "NO" << endl;
				break;
			}
			if (i == t - 1)
				cout << "YES" << endl;
		}
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <numeric>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#include <xfunctional>
#define ll long long
#define mod 1000000007
using namespace std;
int dir[4][2] = { { 0,1 },{ 0,-1 },{ -1,0 },{ 1,0 } };
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf = 0x3f3f3f3f;
const double pi = 3.14159265358979;
int main()
{
	int n;
	cin >> n;
	while (n--)
	{
		int t;
		cin >> t;
		vector<int> a(t);
		for (int i = 0; i < t; i++)
			cin >> a[i];
		if (t == 1)
		{
			cout << "YES" << endl;
			continue;
		}
		int flag = 0;
		if (a[0] % 2)
			flag = 1;
		if (flag == 1)
		{
			for (int i = 1; i < t; i++)
			{
				if (a[i] % 2 == 0)
				{
					cout << "NO" << endl;
					break;
				}
				if (i == t - 1)
					cout << "YES" << endl;
			}
		}
		else
		{
			for (int i = 1; i < t; i++)
			{
				if (a[i] % 2 == 1)
				{
					cout << "NO" << endl;
					break;
				}
				if (i == t - 1)
					cout << "YES" << endl;
			}
		}
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <numeric>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#include <xfunctional>
#define ll long long
#define mod 1000000007
using namespace std;
int dir[4][2] = { { 0,1 },{ 0,-1 },{ -1,0 },{ 1,0 } };
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf = 0x3f3f3f3f;
const double pi = 3.14159265358979;
int main()
{
	int n;
	cin >> n;
	while (n--)
	{
		int t;
		cin >> t;
		if (t == 1)
		{
			cout << "YES" << endl;
			continue;
		}
		vector<int> a(t);
		for (int i = 0; i < t; i++)
			cin >> a[i];
		for (int i = 1; i < t; i++)
		{
			if ((a[i] - a[i - 1]) % 2)
			{
				cout << "NO" << endl;
				break;
			}
			if (i == t - 1)
				cout << "YES" << endl;
		}
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <numeric>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#include <xfunctional>
#define ll long long
#define mod 1000000007
using namespace std;
int dir[4][2] = { { 0,1 },{ 0,-1 },{ -1,0 },{ 1,0 } };
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf = 0x3f3f3f3f;
const double pi = 3.14159265358979;
int main()
{
	int n;
	cin >> n;
	while (n--)
	{
		int t;
		cin >> t;
		if (t == 1)
		{
			cout << "YES" << endl;
			continue;
		}
		vector<int> a(t);
		for (int i = 0; i < t; i++)
			cin >> a[i];
		for (int i = 1; i < t; i++)
		{
			if (abs(a[i] - a[i - 1]) % 2)
			{
				cout << "NO" << endl;
				break;
			}
			if (i == t - 1)
				cout << "YES" << endl;
		}
	}
	return 0;
}


#include <iostream>
#include <cmath>
#include <set>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;

tuple<bool, int, int> f(const vector<int> &a, double x, int d)
{
    auto n = a.size();
    vector<double> p(n + 1), m(n + 1);
    for (size_t i = 1; i < n + 1; ++i) {
        p[i] = p[i - 1] + a[i - 1] - x;
        m[i] = min(m[i - 1], p[i]);
    }
    for (int r = d; r < n + 1; ++r)
    {
        if (m[r - d] <= p[r]) {
            return {
                true,
                distance(m.begin(), min_element(m.begin(), m.begin() + r - d + 1)),
                r};
        }
    }
    return {false,0,0};
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, el, t; //, l = -1, r = 1e5 + 1;
    cin >> t;
    for (int i = 0; i < t; ++i) {
        cin >> n;
        int r = 0;
        for (int j = 0; j < n; ++j)
        {
            cin >> el;
            r += el % 2;
        }
        cout << (r % n ? "NO\n" : "YES\n");
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>

using namespace std;

int main(){
	int t;
	cin >> t;
	for (int i = 0; i < t; ++i) {
		int n;
		cin >> n;
		int a = 0;
		cin >> a;
		bool Parity = a % 2;
		bool isOk = true;
		for (int j = 1; j < n; ++j) {
			int b = 0;
			cin >> a;
			if (a % 2 != Parity) isOk &= false;
		}
		if (isOk) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}


#include<iostream>
#include<string>
#include<unordered_set>
#include<vector>
#include<queue>
#include<set>
#include<cmath>
#include<iomanip>
#include<string>
#include<string.h>
#include<map>
#define INF 0x3f3f3f3f;
const int maxn = 1e9 + 5;
using namespace std;
int t ,n,a[200];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(false);
	cin >> t;
	while (t--) {
		cin >> n;
		bool f = 0;
		int minn = INF;
		for (int i = 1;i <= n;i++) {
			cin >> a[i];
			minn = min(minn, a[i]);
		}
		for (int i = 1;i <= n;i++) {
			a[i] -= minn;
			if (a[i] % 2) {
				f = 1;
				puts("NO");
				break;
			}
		}
		if(!f) puts("YES");
	}
	return 0;
}


#include<iostream>
#include<string>
#include<unordered_set>
#include<vector>
#include<queue>
#include<set>
#include<cmath>
#include<iomanip>
#include<string>
#include<string.h>
#include<map>
#define INF 0x3f3f3f3f;
const int maxn = 1e9 + 5;
using namespace std;
int t ,n,a[200];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(false);
	cin >> t;
	while (2*t--) {
		cin >> n;
		bool f = 0;
		int minn = INF;
		for (int i = 1;i <= n;i++) {
			cin >> a[i];
			minn = min(minn, a[i]);
		}
		for (int i = 1;i <= n;i++) {
			a[i] -= minn;
			if (a[i] % 2) {
				f = 1;
				puts("NO");
			}
		}
		if(!f) puts("YES");
	}
	return 0;
}


#include<iostream>
#include<string>
#include<unordered_set>
#include<vector>
#include<queue>
#include<set>
#include<cmath>
#include<iomanip>
#include<string>
#include<string.h>
#include<map>
#define INF 0x3f3f3f3f;
const int maxn = 1e9 + 5;
using namespace std;
int t ,n,a[200];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(false);
	cin >> t;
	while (t--) {
		cin >> n;
		bool f = 0;
		int minn = INF;
		for (int i = 1;i <= n;i++) {
			cin >> a[i];
			minn = min(minn, a[i]);
		}
		for (int i = 1;i <= n;i++) {
			a[i] -= minn;
			if (a[i] % 2) {
				f = 1;
				puts("NO");
			}
		}
		if(!f) puts("YES");
	}
	return 0;
}


#include"pch.h"
#include<iostream>
#include<string>
#include<unordered_set>
#include<vector>
#include<queue>
#include<set>
#include<cmath>
#include<iomanip>
#include<string>
#include<string.h>
#include<map>
#define INF 0x3f3f3f3f;
const int maxn = 1e9 + 5;
using namespace std;
int t ,n,a[200];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(false);
	cin >> t;
	while (2*t--) {
		cin >> n;
		bool f = 0;
		int minn = INF;
		for (int i = 1;i <= n;i++) {
			cin >> a[i];
			minn = min(minn, a[i]);
		}
		for (int i = 1;i <= n;i++) {
			a[i] -= minn;
			if (a[i] % 2) {
				f = 1;
				puts("NO");
			}
		}
		if(!f) puts("YES");
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <fstream>
#include <set>
#include <vector>
#include <string>
#include <map>
using namespace std;
int main() {
    int t;
    cin >> t;
    for (int i = 0; i < t; ++i) {
        int n;
        cin >> n;
        int x;
        cin >> x;
        int ans = x % 2;
        int chek = 1;
        if (n == 1) {
            cout << "YES" << endl;
            chek = 0;
        }
        for (int j = 0; j < n - 1; ++j) {
            int y;
            cin >> y;
            if (y % 2 != ans) {
                cout << "NO" << endl;
                chek = 0;
            }
        }
        if (chek == 1) {
            cout << "YES" << endl;
        }
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <fstream>
#include <set>
#include <vector>
#include <string>
#include <map>
using namespace std;
int main() {
	int t;
	cin >> t;
	for (int i = 0; i < t; ++i) {
		int n;
		cin >> n;
		int x;
		cin >> x;
		int ans = x % 2;
		int chek = 1;
		if (n == 1) {
			cout << "YES" << endl;
			chek = 0;
		}
		for (int j = 0; j < n - 1; ++j) {
			int y;
			cin >> y;
			if (y % 2 != ans && chek == 1) {
				cout << "NO" << endl;
				chek = 0;
			}
		}
		if (chek == 1) {
			cout << "YES" << endl;
		}
	}
	return 0;
}


#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#pragma warning(disable : 4996)

#define all(v)             v.begin(),v.end()
#define sz(v)            ((int)((v).size()))
#define psh(x)                  push_back(x)
#define sc(x)                 scanf("%d",&x)
#define sc2(x,y)         scanf("%d%d",&x,&y)
#define scl(x)              scanf("%lld",&x)
#define scl2(x,y)              scanf("%lld%lld",&x,&y)
#define lop(i,n)        for(register int i=0;i<n;i++)
#define loop(i,f,l)     for(register int i=f;i<l;i++)
#define R_(s)         freopen(s, "r", stdin)
#define W_(s)        freopen(s, "w", stdout)
#define R_W R_("input.txt"),W_("output.txt")
#define PI                        acos(-1.0)
#define INF                       1000000000
#define DFS_GRAY  -1
#define DFS_WHITE  0
#define DFS_BLACK  1

#define IO 				std::ios_base::sync_with_stdio(0);cin.tie(NULL)

#define scc(x)           scanf("%c",&x)
#define mem(v, d)		memset(v, d, sizeof(v))
#define oo				2000000100
#define OO				4000000000000000100
typedef unsigned int uint;
typedef unsigned long long ull;

typedef string            ss;
typedef long long         ll;
typedef pair <int, int>   ii;
typedef pair<ss, int>     si;
typedef pair<int, ss>     is;
typedef pair<char, int>  chi;
typedef pair<ss, ss>     pss;
typedef vector<ii>       vii;
typedef vector<int>       vi;
typedef vector<vi>       vvi;
typedef vector<ss>        vs;
typedef vector<ll>       vll;
typedef vector<vll>     vvll;

//-----------------------------------------------------

const ll MOD = 1e9 + 7;

int dx[] = { 0,0,1,-1 };
int dy[] = { 1,-1,0,0 };

ll GCD(ll num, ll ones) { return !ones ? num : GCD(ones, num % ones); }
ll lcm(ll a, ll b) { return (a / GCD(a, b)) * b; }
double Len(int x, int y, int X, int Y) { return sqrt((X - x) * (X - x) + (Y - y) * (Y - y)); }
ll fastP(ll b, ll p)
{
    if (p == 0) return 1;
    else if (p == 1) return b;
    ll a = fastP(b, p / 2) % MOD;
    if (p % 2) return (((a * a) % MOD) * b) % MOD;
    else return (a * a) % MOD;
}
//----------------- ------   -------

const int N = 200005;
const double EPS = 1e-9;
int t, n,x;
int main()
{
/*
#ifndef ONLINE_JUDGE
    freopen("i.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
*/
  cin >> t;
    while (t--)
    {
        cin >> n;
        int cnt = 0;
        lop(i, n)
            cin >> x, cnt += x & 1;
        cnt == n || !cnt ? cout << "YES" : cout << "NO";
        cout << endl;
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int t;
	cin >> t;

	for (int i = 0; i < t; ++i) {
		int n;
		cin >> n;
		vector <int> a(n);
		for (int i = 0; i < n; ++i)
			cin >> a[i];
		int k = 0;
		for (int i = 0; i < n; ++i) {
			if (a[i] % 2 == 1)
				++k;

		}
		if (k == n || k == 0)
			cout << "YES" << endl;
		else cout << "NO"<<endl;

	}

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int t;
	cin >> t;

	for (int i = 0; i < t; ++i) {
		int n;
		cin >> n;
		vector <int> a(n);
		for (int i = 0; i < n; ++i)
			cin >> a[i];
		int k = 0;
		for (int i = 0; i < n; ++i) {
			if (a[i] % 2 == 1)
				++k;

		}
		if (k == n || k == 0)
			cout << "YES" << endl;
		else cout << "NO";

	}

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int t;
	cin >> t;

	for (int i = 0; i < t; ++i) {
		int n;
		cin >> n;
		vector <int> a(n);
		for (int i = 0; i < n; ++i)
			cin >> a[i];
		int k = 0,l;
		for (int i = 0; i < n; ++i) {
			if (a[i] % 2 == 1)
				++k;

		}
		if (k == n || k == 0)
			cout << "YES" << endl;
		else cout << "NO";

	}

	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define max2 1001
int n,a[max2];
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int ok=0;
        memset(a,0,sizeof(a));
        cin>>n;
        for(int i=1;i<=n;i++) cin>>a[i];
        for(int i=1;i<=n;i++)
           {
               ok=0;
            for(int j=i;j<=n;j++)
            if((a[i]-a[j])%2!=0) {
                ok=1;cout<<"NO"<<endl;break;
            }
            if(ok) break;
        }
        if(!ok) cout<<"YES"<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define max2 1001
int n,a[max2];
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int ok=0;
        memset(a,0,sizeof(a));
        cin>>n;
        for(int i=1;i<=n;i++) cin>>a[i];
        for(int i=1;i<=n;i++)
           {
               ok=0;
            for(int j=i;j<=n;j++)
            if((a[i]-a[j])%2!=0) {
                ok=1;cout<<"NO"<<endl;break;
            }
            if(ok) break;
        }
        if(!ok) cout<<"YES"<<endl;
    }
    return 0;
}


#include <iostream>
using namespace std;

int input[101] = { 0, };

int main()
{
	int testCase, n;
	cin >> testCase;

	for (int i = 0; i < testCase; i++)
	{
		cin >> n;
		bool isNo = false;
		int preNum = -1;
		for (int j = 0; j < n; j++)
		{
			int temp;
			cin >> temp;

			if (preNum != -1 && preNum % 2 != temp % 2)
			{
				isNo = true;
			}
			preNum = temp;
		}
		if (isNo)cout << "NO" << endl;
		else cout << "YES" << endl;
	}
}


#include <iostream>
using namespace std;

int input[101] = { 0, };

int main()
{
	int testCase, n;
	cin >> testCase;

	for (int i = 0; i < testCase; i++)
	{
		cin >> n;
		bool isNo = false;
		for (int j = 0; j < n; j++)
		{
			int temp;
			cin >> temp;
			if ((n - temp) % 2 == 1)
			{
				isNo = true;
			}
		}
		if (isNo)cout << "NO" << endl;
		else cout << "YES" << endl;
	}
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <vector>
#include <sstream>
#include <iomanip>

using ll = long long int;
using ull = unsigned long long int;
#define Pi 3.14159

using namespace std;

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);
    int t; std::cin >> t;
    while (t--)
    {
        int n; std::cin >> n;
        bool ch = false;
        int* arr = new int[n];
        for (int i = 0; i < n; i++)
        {
            std::cin >> arr[i];
        }
        for (int i = 0; i < n - 1; i++)
        {
            if (arr[i] % 2 == 0 && arr[i + 1] % 2 == 1)
            {
                std::cout << "NO\n";
                ch = true;
                break;
            }
        }
         if (!ch)
        {
            std::cout << "YES\n";
        }
        delete[] arr;
    }

    return 0;
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <vector>
#include <sstream>
#include <iomanip>

using ll = long long int;
using ull = unsigned long long int;
#define Pi 3.14159

using namespace std;

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);
    int t; std::cin >> t;
    while (t--)
    {
        int n; std::cin >> n;
        bool ch = false;
        int* arr = new int[n];
        for (int i = 0; i < n; i++)
        {
            std::cin >> arr[i];
        }
        for (int i = 0; i < n - 1; i++)
        {
            if ((arr[i] % 2 == 0 && arr[i + 1] % 2 == 1) || arr[i] % 2 == 1 && arr[i + 1] % 2 == 0)
            {
                std::cout << "NO\n";
                ch = true;
                break;
            }
        }
         if (!ch)
        {
            std::cout << "YES\n";
        }
        delete[] arr;
    }

    return 0;
}


#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<set>
using namespace std;
int main()
{
	int t,n;
	cin >> t;
	while (t--)
	{
		int max = 0;
		string wrd = "true";
		cin >> n;
		vector<int>vec(n);
		for (int i = 0; i < vec.size(); i++)
		{
			cin >> vec[i];
			if (vec[i]>max)
				max = vec[i];
		}
		for (int o = 0; o < vec.size(); o++)
		{
			if ((max - vec[o]) % 2 != 0)
			{
				cout << "NO" << endl;
				wrd = "false";
				break;
			}
		}
		if (wrd == "true")
			cout << "YES" << endl;

	}
	return 0;

}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
using namespace std;
int t,n,i,x;
int a[3];
int main()
{
	cin >> t;
	while (t--) {
		cin >> n;
		a[1] = 0;
		a[2] = 0;
		for (i = 1; i <= n; i++) {
			cin >> x;
			if (x % 2 == 0) {
				a[1]++;
			}
			else {
				a[2]++;
			}
		}
		if ((a[1] == 0 && a[2] != 0) || (a[2] == 0 && a[1] != 0)) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
}


#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int a[1000000],t,n;
int main()
{
	cin>>t;
	for(int k=1;k<=t;k++)
	{
		cin>>n;
		int flag=1;
		for(int i=1;i<=n;i++)
		{
			cin>>a[i];
			a[i]%=2;
			if(a[i]!=a[i-1]&&i>1) flag=0;
		}
		if(flag==1) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int a[1000000],t,n;
int main()
{
	cin>>t;
	for(int k=1;k<=t;k++)
	{
		cin>>n;
		if(n==1)
		{
			cout<<"YES"<<endl;
			continue;
		}
		for(int i=1;i<=n;i++)
		{
			cin>>a[i];
		}
		int flag=1;
		for(int i=1;i<=n;i++)
		{
			for(int j=i+1;j<=n;j++)
			{
				if(abs(a[i]-a[j])%2==1)
				{
					flag=0;
				}
			}
		}
		if(flag) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}


#include <iostream>

using namespace std;

int main()
{
	bool res[100], isEven;
	int t, n, s, counter;
	cin >> t;
	for (int j = 0; j < t; ++j)
	{
		cin >> n;
		cin >> s;
		if (s % 2)
			isEven = false;
		else
			isEven = true;
		counter = 1;
		for (int i = 1; i < n; ++i)
		{
			cin >> s;
			if (isEven && !(s % 2))
				++counter;
			if (!isEven && (s % 2))
				++counter;
		}
		if (counter == n)
			res[j] = true;
		else
			res[j] = false;
	}
	for (int i = 0; i < t; ++i)
		res[i] ? cout << "YES" << endl : cout << "NO" << endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	bool res[100];
	int t, n, s, max, min;
	vector<int> v;
	cin >> t;
	for (int j = 0; j < t; ++j)
	{
		cin >> n;
		for (int i = 0; i < n; ++i)
		{
			cin >> s;
			v.push_back(s);
		}
		max = *max_element(v.begin(), v.end());
		min = *min_element(v.begin(), v.end());
		if ((max - min) % 2)
			res[j] = false;
		else
			res[j] = true;
		v.clear();
	}
	for (int i = 0; i < t; ++i)
		res[i] ? cout << "YES" << endl : cout << "NO" << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
using namespace std;
int main() {
	int t, n, i, max, *a;
	cin >> t;
	for (int q = 0; q < t; q++) {
	    f=1;
		cin >> n;
		a = new int(n);
		for (i = 0; i < n; i++) {
			cin >> a[i];
		}
		max = -1;
		for (i = 0; i < n; i++) {
			if (a[i] > max) { max = a[i]; }
		}
		for (i = 0; i < n; i++) {
			if ((max - a[i]) % 2 == 1) { f = 0; break; }
		}
		if (i==n) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <unordered_map>
using namespace std;
/*
struct Graph {
	int check;
	int weight;
	vector <Graph*> next;
	Graph(int);
};
Graph::Graph(int _weight) {
	weight = _weight;
	check = 0;
}

int min_graph(Graph& graph) {
	int min = graph.weight;
	graph.check = 1;
	for (int i = 0; i < graph.next.size(); i++) {
		if (graph.next[i]->check == 0) {
			int min1 = min_graph(*graph.next[i]);
			if (min > min1) {
				min = min_graph(*graph.next[i]);
			}
		}
	}
	return min;
}
*/
void m(int *mas, int n) {
	for (int w = 0; w < n; w++) {
		mas[w]--;
	}
}
int pr(int *mas, int n) {
	int t, max=-1;
	for (int i = 0; i < n; i++) {
		if (mas[i] > max) {
			max = mas[i];
		}
	}
	while (max > 0) {
		t = -1;
		for (int i = 0; i < n; i++) {
			if (mas[i] == max) {
				if ((i - t + 1) % 2 == 0) { t = i; }
				else {
					return 0;
				}
			}
		}
		if ((n - t) % 2 == 0) {
			return 0;
		}
		m(mas, n);
		max = -1;
		for (int i = 0; i < n; i++) {
			if (mas[i] > max) {
				max = mas[i];
			}
		}
	}
	return 1;
}
int main() {
	int t, n, *a;
	cin >> t;
	for (int q = 0; q < t; q++) {
		cin >> n;
		a = new int(n);
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		if (pr(a, n)) {
			cout << "YES";
		}
		else cout << "NO";
	}
//system("pause");
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <unordered_map>
using namespace std;

int main() {
	int t, n, *a, f;
	cin >> t;
	for (int q = 0; q < t; q++) {
	    f=1;
		cin >> n;
		a = new int(n);
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		int max = -1;
		for (int i = 0; i < n; i++) {
			if (a[i] > max) { max = a[i]; }
		}
		for (int i = 0; i < n; i++) {
			if ((max - a[i]) % 2 == 1) { f = 0; break; }
		}
		if (f) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
using namespace std;
int main() {
	int t, n, i, max, a[100];
	cin >> t;
	for (int q = 0; q < t; q++) {
		cin >> n;
		for (i = 0; i < n; i++) {
			cin >> a[i];
		}
		max = -1;
		for (i = 0; i < n; i++) {
			if (a[i] > max) { max = a[i]; }
		}
		for (i = 0; i < n; i++) {
			if ((max - a[i]) % 2 == 1) { break; }
		}
		if (i == n) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <unordered_map>
using namespace std;
/*
struct Graph {
	int check;
	int weight;
	vector <Graph*> next;
	Graph(int);
};
Graph::Graph(int _weight) {
	weight = _weight;
	check = 0;
}

int min_graph(Graph& graph) {
	int min = graph.weight;
	graph.check = 1;
	for (int i = 0; i < graph.next.size(); i++) {
		if (graph.next[i]->check == 0) {
			int min1 = min_graph(*graph.next[i]);
			if (min > min1) {
				min = min_graph(*graph.next[i]);
			}
		}
	}
	return min;
}
*/
void m(int *mas, int n) {
	for (int w = 0; w < n; w++) {
		mas[w]--;
	}
}
int pr(int *mas, int n) {
	int t, max=-1;
	for (int i = 0; i < n; i++) {
		if (mas[i] > max) {
			max = mas[i];
		}
	}
	while (max > 0) {
		t = -1;
		for (int i = 0; i < n; i++) {
			if (mas[i] == max) {
				if ((i - t + 1) % 2 == 0) { t = i; }
				else {
					return 0;
				}
			}
		}
		if ((n - t) % 2 == 0) {
			return 0;
		}
		m(mas, n);
		max = -1;
		for (int i = 0; i < n; i++) {
			if (mas[i] > max) {
				max = mas[i];
			}
		}
	}
	return 1;
}
int main() {
	int t, n, *a;
	cin >> t;
	for (int q = 0; q < t; q++) {
		cin >> n;
		a = new int(n);
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		if (pr(a, n)) {
			cout << "YES" << endl;
		}
		else cout << "NO" << endl;
	}
//system("pause");
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
using namespace std;
int main() {
	int t, n, i, max, *a;
	cin >> t;
	for (int q = 0; q < t; q++) {
		cin >> n;
		a = new int(n);
		for (i = 0; i < n; i++) {
			cin >> a[i];
		}
		max = -1;
		for (i = 0; i < n; i++) {
			if (a[i] > max) { max = a[i]; }
		}
		for (i = 0; i < n; i++) {
			if ((max - a[i]) % 2 == 1) { break; }
		}
		if (i == n) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <unordered_map>
using namespace std;

int main() {
	int t, n, *a, f=1;
	cin >> t;
	for (int q = 0; q < t; q++) {
		cin >> n;
		a = new int(n);
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		int max = -1;
		for (int i = 0; i < n; i++) {
			if (a[i] > max) { max = a[i]; }
		}
		for (int i = 0; i < n; i++) {
			if ((max - a[i]) % 2 == 1) { f = 0; break; }
		}
		if (f) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <unordered_map>
using namespace std;
int main() {
	int t, n, *a, f;
	cin >> t;
	for (int q = 0; q < t; q++) {
	    f=1;
		cin >> n;
		a = new int(n);
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		int max = -1;
		for (int i = 0; i < n; i++) {
			if (a[i] > max) { max = a[i]; }
		}
		for (int i = 0; i < n; i++) {
			if ((max - a[i]) % 2 == 1) { f = 0; break; }
		}
		if (f) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}


#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

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

	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		bool even = false;
		bool odd = false;
		while (n--) {
			int a;
			cin >> a;
			if (a % 2 == 1) odd = true;
			else even = true;
		}
		if (even != odd) cout << "YES\n";
		else cout << "NO\n";
	}
}


#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

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

	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		int amin = 101;
		int amax = -1;
		while (n--) {
			int a;
			cin >> a;
			amin = min(a, amin);
			amax = max(a, amax);
		}
		if ((amax - amin) % 2 == 1) cout << "NO\n";
		else cout << "YES\n";
	}
}


#include <iostream>
//#include "debughead.h"

using namespace std;

int main() {

    int t, n, a, b;
    bool f;
    cin >> t;

    for (int i = 0; i < t; i++) {
        cin >> n;

        f = false;
        for (int j = 0; j < n; j++) {
            cin >> a;

            if (j == 0) {
                b = a;
            }

            else {
                if (a % 2 != b % 2) {
                    f = true;
                }
            }
        }

        if (f) {
            cout << "NO" << '\n';
        }

        else {
            cout << "YES" << '\n';
        }
    }

    return 0;
}


#include <iostream>
#include "debughead.h"

using namespace std;

int main() {

    int t, n, a, b;
    bool f;
    cin >> t;

    for (int i = 0; i < t; i++) {
        cin >> n;

        f = false;
        for (int j = 0; j < n; j++) {
            cin >> a;

            if (j == 0) {
                b = a;
            }

            else {
                if (a % 2 != b % 2) {
                    f = true;
                }
            }
        }

        if (f) {
            cout << "NO" << '\n';
        }

        else {
            cout << "YES" << '\n';
        }
    }

    return 0;
}


#include <iostream>
#include <cstdlib>
using namespace std;

int main()
{
   int t,n,*a,temp,c=0;
   cin>>t;
   for(int i=0;i<t;i++)
   {   c=0;
       cin>>n;
       a=(int*)malloc(sizeof(int)*n);
       for(int i=0;i<n;i++)
       {
           cin>>a[i];
       }
       for(int i=0;i<n-1;i++)
       {
           for(int j=i+1;j<n;j++)
           {
               if(a[i]>a[j]){temp=a[i];a[i]=a[j];a[j]=temp;}
           }
       }
       for(int i=0;i<n-1;i++)
       {
           if((a[i+1]==a[i])||(a[i+1]-a[i]==2)){c=0;}
           else{c=1;break;}
       }
       if(c==0){cout<<"YES"<<endl;}
       else{cout<<"NO"<<endl;}
   }
    return 0;
}


#include <iostream>
#include <cstdlib>
using namespace std;

int main()
{
   int t,n,*a,temp,c=0;
   cin>>t;
   for(int i=0;i<t;i++)
   {   c=0;
       cin>>n;
       a=(int*)malloc(sizeof(int)*n);
       for(int i=0;i<n;i++)
       {
           cin>>a[i];
       }
       for(int i=0;i<n-1;i++)
       {
           for(int j=i+1;j<n;j++)
           {
               if(a[i]>a[j]){temp=a[i];a[i]=a[j];a[j]=temp;}
           }
       }
       for(int i=0;i<n-1;i++)
       {
           if((a[i+1]==a[i])||((a[i+1]-a[i])%2==0)){c=0;}
           else{c=1;break;}
       }
       if(c==0){cout<<"YES"<<endl;}
       else{cout<<"NO"<<endl;}
   }
    return 0;
}


#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--){
	    int n;
	    cin>>n;
	    int* arr=new int[n];
	    for(int i=0;i<n;i++){
	        cin>>arr[i];
	    }
	    int count[2]={};
	    for(int i=0;i<n;i++){
	        count[arr[i]%2]++;
	    }
	    if(count[0]&& count[1]){
	        cout<<"NO"<<endl;
	    }
	    else{
	        cout<<"YES"<<endl;
	    }
	}
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	int t;
	cin>>t; // number of test cases
	for(int i=0;i<t;i++){
		int n; // number of coloums in tetris field
		int a[n];
		for(int j=0;j<n;j++){
			cin>>a[j]; // initial height of coloums
		}
		int k=0;
			while(a[k]>0 && k<n){
				a[k]=a[k]+2;
				k++;
			}

		for(int i=0;i<n;i++){
			if(a[i]>0){
				continue;
				cout<<"YES"<<endl;
			}
			else{
				cout<<"NO"<<endl;
				break;
			}
		}

	}
	return 0;
}


// In the name of God

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <conio.h>

using namespace std ;

typedef long long   LL ;
typedef long double LD ;

const int maxN=1000001 ;

#define X first
#define Y second

string s1 , s2 ;

bool F ( int i )
{
    int x,y ;
    x= int(s1[i])-48 ;
    y=int(s1[i+1])-48 ;

    int p = (x+y)%2 ;
    int q = (x||y) ;

    if ( p== int(s2[i])-48  &&  q== int(s2[i+1])-48 )
    {
        s1[i]=char(p+48);
        s1[i+1]=char(q+48) ;
        return true ;
    }
    else if ( q== int(s2[i])-48  &&  p== int(s2[i+1])-48 )
    {
        s1[i]=char(q+48);
        s1[i+1]=char(p+48) ;
        return true ;
    }
    else
        return false ;
}

int main ()
{
    cin >> s1 ;
    cin >> s2 ;

    if ( s1.length()!=s2.length() )
    {
        cout << "NO" ;
        return 0 ;
    }

    for ( int i=0 ; i< s1.length()-1 ; i++ )
    {
        if ( s1==s2 )
        {
            cout << "YES" ;
            return 0 ;
        }
        F(i) ;
    }

     if ( s1==s2 )
        {
            cout << "YES" ;
            return 0 ;
        }

    cout << "NO" ;

  //  getch() ;
    return 0 ;
}


// In the name of God

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
#include <deque>
//#include <conio.h>

using namespace std ;

int main ()
{
    string a,b ;
    getline(cin,a) ;
    getline(cin,b) ;

    if ( a.length()!=b.length() )
    {
        cout << "NO" ;
        return 0 ;
    }
    int oa=0 , ob=0 ;
    for ( int i=0 ; i< a.length() ; i++ )
    {
        if ( a[i]=='1' )
            oa++ ;
        if ( b[i]=='1' )
            ob++ ;
    }

    if ( oa>0 && ob>0 )
        cout << "YES" ;
    else
        cout << "NO" ;

    return 0 ;
}


// In the name of God

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <conio.h>

using namespace std ;

typedef long long   LL ;
typedef long double LD ;

const int maxN=1000001 ;

#define X first
#define Y second

string s1 , s2 ;

bool F ( int i )
{
    int x,y ;
    x= int(s1[i])-48 ;
    y=int(s1[i+1])-48 ;

    int p = (x+y)%2 ;
    int q = (x||y) ;

    if ( p== int(s2[i])-48  &&  q== int(s2[i+1])-48 )
    {
        s1[i]=char(p+48);
        s1[i+1]=char(q+48) ;
        return true ;
    }
    else if ( q== int(s2[i])-48  &&  p== int(s2[i+1])-48 )
    {
        s1[i]=char(q+48);
        s1[i+1]=char(p+48) ;
        return true ;
    }
    else
        return false ;
}

int main ()
{
    cin >> s1 ;
    cin >> s2 ;

    string str=s1 ;

    if ( s1.length()!=s2.length() )
    {
        cout << "NO" ;
        return 0 ;
    }

    for ( int i=0 ; i< s1.length()-1 ; i+=2 )
    {
        if ( s1==s2 )
        {
            cout << "YES" ;
            return 0 ;
        }

        if ( s1!=s2 &&  ( s1[i]!=s2[i] || s1[i+1]!=s2[i+1])  )
            F(i) ;
    }

    if ( s1==s2 )
    {
            cout << "YES" ;
            return 0 ;
    }

    s1=str ;

    for ( int i=0 ; i< s1.length()-1 ; i++ )
    {
        if ( s1==s2 )
        {
            cout << "YES" ;
            return 0 ;
        }

        if ( s1!=s2 &&  ( s1[i]!=s2[i] || s1[i+1]!=s2[i+1])  )
            F(i) ;
    }

     if ( s1==s2 )
    {
            cout << "YES" ;
            return 0 ;
    }

    cout << "NO" ;

   // getch() ;
    return 0 ;
}


// In the name of God

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
#include <deque>
//#include <conio.h>

using namespace std ;

int main ()
{
    string a,b ;
    getline(cin,a) ;
    getline(cin,b) ;

    if ( a.length()!=b.length() )
    {
        cout << "NO" ;
        return 0 ;
    }
    int oa=0 , ob=0 ;
    for ( int i=0 ; i< a.length() ; i++ )
    {
        if ( a[i]=='1' )
            oa++ ;
        if ( b[i]=='1' )
            ob++ ;
    }

    if ( a==b )
        cout << "YES" ;
    else if ( oa>0 && ob>0  )
        cout << "YES" ;
    else
        cout << "NO" ;

    return 0 ;
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<stdio.h>
using namespace std;
string a,b;
int i,x,y,p,q,A[1000005],B[1000005];

main()
{cin>>a;
 cin>>b;
 if(a.size()!=b.size()){cout<<"NO"<<endl;return 0;}
 if(a.size()==1)
     if(a!=b){cout<<"NO"<<endl;return 0;}else
             {cout<<"YES"<<endl;return 0;}
 for(i=0;i<a.size();i++)A[i]=a[i]-'0',B[i]=b[i]-'0';
 x=int(a[0]-'0');
 y=int(a[1]-'0');
 p=(x | y);
 q=(x ^ y);
 if(B[0]!=p && B[0]!=q){cout<<"NO"<<endl;return 0;}

 for(i=1;i<a.size();i++){
    x=int(a[i-1]-'0');
    y=int(a[i]-'0');
    p=(x | y);
    q=(x ^ y);
    if(B[i-1]==p && B[i]!=q){cout<<"NO"<<endl;return 0;}
    if(B[i-1]==q && B[i]!=p){cout<<"NO"<<endl;return 0;}

 }
 cout<<"YES"<<endl;return 0;
}


#include<iostream>
#include<stdio.h>
#include<algorithm>
#define MAX(a,b) (a>b?a:b)
using namespace std;
string a,b;
int x,y,i;

main()
{cin>>a;
 cin>>b;
 if(a.size()!=b.size()){cout<<"NO"<<endl;return 0;}
 for(i=0;i<a.size();i++)
    if(a[i]=='1')x++;
 for(i=0;i<b.size();i++)
    if(b[i]=='1')y++;
 if(x==0 && y==0 || x>0 && y>0)cout<<"YES"<<endl;else
 cout<<"NO"<<endl;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<string.h>
#include<cmath>
using namespace std;
string a,b;
long long x,y;
long long noof1(string t)
{
long long n=0;
for(long long i=0;i<t.length();i++)
	{
	if(t[i]=='1')
		n++;
	}
	return n;
}

int main()
{
	cin>>a>>b;
	x=noof1(a); y=noof1(b);
	if(a.length()!=b.length()) {cout<<"NO"; return 0;}
	if(a.length()==1)
	{
		if(a[0]==b[0]) {cout<<"YES"; return 0;}
		if(a[0]!=b[0]) {cout<<"NO"; return 0;}
	}

	if(x<y)           {cout<<"NO"; return 0;}
	if(x>=y&&y!=0)    {cout<<"YES"; return 0;}
	if(x==y&&x==0)    {cout<<"YES"; return 0;}
	if(x>y&&y==0)     {cout<<"NO"; return 0;}
	cout<<"YES";
	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<string.h>
#include<cmath>
using namespace std;
string a,b;
long long x,y;
long long noof1(string t)
{
long long n=0;
for(long long i=0;i<t.length();i++)
	{
	if(t[i]=='1')
		n++;
	}
	return n;
}

int main()
{
	cin>>a>>b;
	x=noof1(a); y=noof1(b);
	if(a.length()!=b.length()) {cout<<"NO"; return 0;}
	if(x==0&&y!==0) {cout<<"NO"; return 0;}
	if(x>=y&&x!=0)    {cout<<"YES"; return 0;}
	cout<<"NO";
	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<string.h>
#include<cmath>
using namespace std;
string a,b;
long long x,y;
long long noof1(string t)
{
long long n=0;
for(long long i=0;i<t.length();i++)
	{
	if(t[i]=='1')
		n++;
	}
	return n;
}

int main()
{
	cin>>a>>b;
	x=noof1(a); y=noof1(b);
	if(a.length()!=b.length()) {cout<<"NO"; return 0;}
	if(a.length()==1)
	{
		if(a[0]==b[0]) {cout<<"YES"; return 0;}
		if(a[0]!=b[0]) {cout<<"NO"; return 0;}
	}

	if(x==0||y==0&&x!=y)           {cout<<"NO"; return 0;}
	cout<<"YES";
	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<string.h>
#include<cmath>
using namespace std;
string a,b;
long long x,y;
long long noof1(string t)
{
long long n=0;
for(long long i=0;i<t.length();i++)
	{
	if(t[i]=='1')
		n++;
	}
	return n;
}

int main()
{
	cin>>a>>b;
	x=noof1(a); y=noof1(b);
	if(a.length()!=b.length()) {cout<<"NO"; return 0;}
	if(x<y)   {cout<<"NO"; return 0;}
	if(x>=y&&x!=0)    {cout<<"YES"; return 0;}
	if(x==y&&x==0)    {cout<<"YES"; return 0;}
	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<string.h>
#include<cmath>
using namespace std;
string a,b;
long long x,y;
long long noof1(string t)
{
long long n=0;
for(long long i=0;i<t.length();i++)
	{
	if(t[i]=='1')
		n++;
	}
	return n;
}

int main()
{
	cin>>a>>b;
	x=noof1(a); y=noof1(b);
	if(a.length()!=b.length()) {cout<<"NO"; return 0;}
	if(x==0&&y!=0)   {cout<<"NO"; return 0;}
	if(x>=y&&x!=0)    {cout<<"YES"; return 0;}
	cout<<"NO";
	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<string.h>
#include<cmath>
using namespace std;
string a,b;
long long x,y;
long long noof1(string t)
{
long long n=0;
for(long long i=0;i<t.length();i++)
	{
	if(t[i]=='1')
		n++;
	}
	return n;
}

int main()
{
	cin>>a>>b;
	x=noof1(a); y=noof1(b);
	if(a.length()!=b.length()) {cout<<"NO"; return 0;}
	if(x<y)   {cout<<"NO"; return 0;}
	if(x>=y&&x!=0&&y!=0)    {cout<<"YES"; return 0;}
	if(x==y&&x==0)    {cout<<"YES"; return 0;}
	if(x>y&&y==0)    {cout<<"NO"; return 0;}
	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<string.h>
#include<cmath>
using namespace std;
string a,b;
long long x,y;
long long noof1(string t)
{
long long n=0;
for(long long i=0;i<t.length();i++)
	{
	if(t[i]=='1')
		n++;
	}
	return n;
}

int main()
{
	cin>>a>>b;
	x=noof1(a); y=noof1(b);
	if(a.length()!=b.length()) {cout<<"NO"; return 0;}
	if((x!=0&&y==0)||(x==0&&y!=0)) {cout<<"NO"; return 0;}
	if(x>=y&&x!=0)    {cout<<"YES"; return 0;}
	cout<<"NO";
	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<string.h>
#include<cmath>
using namespace std;
string a,b;
long long x,y;
long long noof1(string t)
{
long long n=0;
for(long long i=0;i<t.length();i++)
	{
	if(t[i]=='1')
		n++;
	}
	return n;
}

int main()
{
	cin>>a>>b;
	x=noof1(a); y=noof1(b);
	if(a.length()!=b.length()) {cout<<"NO"; return 0;}
	if(a.length()==1)
	{
		if(x!=y) {cout<<"NO";return 0;}
		if(a[0]==b[0]) {cout<<"YES"; return 0;}
		if(a[0]!=b[0]) {cout<<"NO"; return 0;}
	}

	if(x<y)   {cout<<"NO"; return 0;}
	if(x>=y&&y!=0)    {cout<<"YES"; return 0;}
	if(x==y&&x==0)    {cout<<"YES"; return 0;}
	if(x>y&&y==0)    {cout<<"NO"; return 0;}
	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<string.h>
#include<cmath>
using namespace std;
string a,b;
long long x,y;
long long noof1(string t)
{
long long n=0;
for(long long i=0;i<t.length();i++)
	{
	if(t[i]=='1')
		n++;
	}
	return n;
}

int main()
{
	cin>>a>>b;
	x=noof1(a); y=noof1(b);
	if(a.length()!=b.length()) {cout<<"NO"; return 0;}
	if(a.length()==1)
	{
		if(a[0]==b[0]) {cout<<"YES"; return 0;}
		if(a[0]!=b[0]) {cout<<"NO"; return 0;}
	}

	if((x==0||y==0)&&x!=y)           {cout<<"NO"; return 0;}
	cout<<"YES";
	return 0;
}


#include<stdio.h>
#include <string.h>
int trans(char a3,char a4,char b3,char b4)
{
    int q,m;
    int a=a3-'0';
    int a1=a4-'0';
    int b=b3-'0';
    int b1=b4-'0';
    if(a==0||a1==0)
        q=1;
    else q=0;
    if(a+a1)
        m=1;
    else
        m=0;
        printf("%d %d\n",a,a1);
        printf("%d %d\n",b,b1);
    if(a==b&&a1==b1||a==b1&&a1==b)
        return 1;
    else
        return 0;
}
int main()
{
    char a[106];
    char b[106];
    scanf ("%s",a);
    scanf ("%s",b);
    int i;
    int l=strlen(a);
    int L=strlen(b);
    int flag=1;
    for(i=0;i<l;i++)
    {
        if(a[i]!=b[i])
        {
            if(i<l-1)
            flag=trans(a[i],a[i+1],b[i],b[i+1]);
            if(flag==0)
                flag=trans(a[i],a[i-1],b[i],b[i-1]);
        }
        if(!flag)
            break;
    }
    if(flag)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


#include<stdio.h>
#include <string.h>
int trans(char a3,char a4,char b3,char b4)
{
    int q,m;
    int a=a3-'0';
    int a1=a4-'0';
    int b=b3-'0';
    int b1=b4-'0';
    if(a+a1==1)
        q=1;
    else q=0;
    if(a+a1)
        m=1;
    else
        m=0;
        //printf("%d %d\n",m,q);
        //printf("%d %d\n",b,b1);
    if(q==b&&m==b1||m==b1&&q==b)
        return 1;
    else
        return 0;
}
int main()
{
    char a[106];
    char b[106];
    scanf ("%s",a);
    scanf ("%s",b);
    int i;
    int l=strlen(a);
    int L=strlen(b);
    if(l!=L)
    {
        printf("NO\n");
        return 0;
    }
    int flag=1;
    for(i=0;i<l;i++)
    {
        if(a[i]!=b[i])
        {
            if(i<l-1)
            flag=trans(a[i],a[i+1],b[i],b[i+1]);
            if(flag==0)
                flag=trans(a[i],a[i-1],b[i],b[i-1]);
        }
        if(!flag)
            break;
    }
    if(flag)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


#include<stdio.h>
#include <string.h>
int trans(char a3,char a4,char b3,char b4)
{
    int q,m;
    int a=a3-'0';
    int a1=a4-'0';
    int b=b3-'0';
    int b1=b4-'0';
    if(a==0||a1==0)
        q=1;
    else q=0;
    if(a+a1)
        m=1;
    else
        m=0;
        printf("%d %d\n",a,a1);
        printf("%d %d\n",b,b1);
    if(a==b&&a1==b1||a==b1&&a1==b)
        return 1;
    else
        return 0;
}
int main()
{
    char a[106];
    char b[106];
    scanf ("%s",a);
    scanf ("%s",b);
    int i;
    int l=strlen(a);
    int L=strlen(b);
    int flag=1;
    for(i=0;i<l;i++)
    {
        if(a[i]!=b[i])
        {
            if(i<l-1)
            flag=trans(a[i],a[i+1],b[i],b[i+1]);
            if(flag==0)
                flag=trans(a[i],a[i-1],b[i],b[i-1]);
        }
        if(!flag)
            break;
    }
    if(flag)
    printf("YES\n'");
    else
        printf("NO\n");
    return 0;
}


#include<stdio.h>
#include <string.h>
int trans(char a3,char a4,char b3,char b4)
{
    //printf("a3=%c a4=%c\n",a3,a4);
    //printf("b3=%c b4=%d\n",b3,b4);
    int q,m;
    int a=a3-'0';
    int a1=a4-'0';
    int b=b3-'0';
    int b1=b4-'0';
    //printf("b=%d b1=%d\n",b,b1);
    if(a+a1==1)
        q=1;
    else q=0;
    if(a+a1)
        m=1;
    else
        m=0;
        //printf("m=%d q=%d\n",m,q);
        //printf("%d %d\n",b,b1);
    if(q==b&&m==b1||m==b1&&q==b)
        return 1;
    else
        return 0;
}
int main()
{
    char a[106];
    char b[106];
    scanf ("%s",a);
    scanf ("%s",b);
    int i;
    int l=strlen(a);
    int L=strlen(b);
    if(l!=L)
    {
        printf("NO\n");
        return 0;
    }
    int flag=1;
    for(i=0;i<l;i++)
    {
        if(a[i]!=b[i])
        {
            if(i<l-1)
            flag=trans(a[i],a[i+1],b[i],b[i+1]);
            if(flag==0)
                flag=trans(a[i],a[i-1],b[i],b[i-1]);
        }
        if(!flag)
            break;
    }
    if(flag)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


#include<stdio.h>
#include<string.h>
#defind maxn = 1000001;

char a[maxn], b[maxn];

int main(void)
{
	bool chk1 = false, chk2 = false;
	gets(a);
	gets(b);
	int len1 = strlen(a), len2 = strlen(b), i;
	if (len1 != len2)
		printf("NO");
	else
	{
		for (i=0;i<len1&&a[i]=='0';i++);
		if (i<len1)
			chk1 = true;
		for (i=0;i<len1&&b[i]=='0';i++);
		if (i < len1)
			chk2 = true;
		printf(!chk1 && chk2 || chk1 && !chk2 ? "NO" : "YES");
	}
	return 0;
}


#include<stdio.h>
#include <string.h>
int trans(char a3,char a4,char b3,char b4)
{
    int q,m;
    int a=a3-'0';
    int a1=a4-'0';
    int b=b3-'0';
    int b1=b4-'0';
    if(a==0||a1==0)
        q=1;
    else q=0;
    if(a+a1)
        m=1;
    else
        m=0;
        //printf("%d %d\n",a,a1);
        //printf("%d %d\n",b,b1);
    if(q==b&&m==b1||m==b1&&q==b)
        return 1;
    else
        return 0;
}
int main()
{
    char a[106];
    char b[106];
    scanf ("%s",a);
    scanf ("%s",b);
    int i;
    int l=strlen(a);
    int L=strlen(b);
    if(l!=L)
    {
        printf("NO\n");
        return 0;
    }
    int flag=1;
    for(i=0;i<l;i++)
    {
        if(a[i]!=b[i])
        {
            if(i<l-1)
            flag=trans(a[i],a[i+1],b[i],b[i+1]);
            if(flag==0)
                flag=trans(a[i],a[i-1],b[i],b[i-1]);
        }
        if(!flag)
            break;
    }
    if(flag)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


#include<stdio.h>
#include <string.h>
int trans(char a3,char a4,char b3,char b4)
{
    int q,m;
    int a=a3-'0';
    int a1=a4-'0';
    int b=b3-'0';
    int b1=b4-'0';
    if(a==0||a1==0)
        q=1;
    else q=0;
    if(a+a1)
        m=1;
    else
        m=0;
        printf("%d %d\n",a,a1);
        printf("%d %d\n",b,b1);
    if(a==b&&a1==b1||a==b1&&a1==b)
        return 1;
    else
        return 0;
}
int main()
{
    char a[106];
    char b[106];
    scanf ("%s",a);
    scanf ("%s",b);
    int i;
    int l=strlen(a);
    int L=strlen(b);
    if(l!=L)
    {
        printf("NO\n");
        return 0;
    }
    int flag=1;
    for(i=0;i<l;i++)
    {
        if(a[i]!=b[i])
        {
            if(i<l-1)
            flag=trans(a[i],a[i+1],b[i],b[i+1]);
            if(flag==0)
                flag=trans(a[i],a[i-1],b[i],b[i-1]);
        }
        if(!flag)
            break;
    }
    if(flag)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


#include<stdio.h>
$include<string.h>
#define maxn 1000001

int main(void)
{
    bool chk1 = false, chk2 = false;
    gets(a);
    gets(b);
    dint len1 = strlen(a), len2 = strlen(b), i;
    if (len1 != len2)
        printf("NO");
    else
    {
        for (i = 0 ; i < len1 && a[i] == '0' ; i++)
            ;
        if (i < len1)
            chk1 = true;
        for (i = 0 ; i < len1 && b[i] == '0' ; i++)
            ;
        if (i < len1)
            chk2 = true;
        printf(!chk1 && chk2 || chk1 && !chk2 ? "NO" : "YES");
    }
    return 0;
}


#include<stdio.h>
#include <string.h>
int trans(char a3,char a4,char b3,char b4)
{
    //printf("a3=%c a4=%c\n",a3,a4);
    //printf("b3=%c b4=%c\n",b3,b4);
    int q,m;
    int a=a3-'0';
    int a1=a4-'0';
    if(a1<0)
        a1=0;
    int b=b3-'0';
    int b1=b4-'0';
    if(b1<0)
        b1=0;
    //printf("b=%d b1=%d\n",b,b1);
    if(a+a1==1)
        q=1;
    else q=0;
    if(a+a1)
        m=1;
    else
        m=0;
        //printf("m=%d q=%d\n",m,q);
        //printf("%d %d\n",b,b1);
    if(q==b&&m==b1||m==b1&&q==b)
        return 1;
    else
        return 0;
}
int main()
{
    char a[106];
    char b[106];
    scanf ("%s",a);
    scanf ("%s",b);
    int i;
    int l=strlen(a);
    int L=strlen(b);
    if(l!=L)
    {
        printf("NO\n");
        return 0;
    }
    int flag=1;
    for(i=0;i<l;i++)
    {
        if(a[i]!=b[i])
        {
            if(i<l-1)
            flag=trans(a[i],a[i+1],b[i],b[i+1]);
            if(flag==0)
                flag=trans(a[i],a[i-1],b[i],b[i-1]);
        }
        if(!flag)
            break;
    }
    if(flag)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


#include<stdio.h>
#include <string.h>
int trans(char a3,char a4,char b3,char b4)
{
    int q,m;
    int a=a3-'0';
    int a1=a4-'0';
    int b=b3-'0';
    int b1=b4-'0';
    if(a==0||a1==0)
        q=1;
    else q=0;
    if(a+a1)
        m=1;
    else
        m=0;
        //printf("%d %d\n",a,a1);
        //printf("%d %d\n",b,b1);
    if(a==b&&a1==b1||a==b1&&a1==b)
        return 1;
    else
        return 0;
}
int main()
{
    char a[106];
    char b[106];
    scanf ("%s",a);
    scanf ("%s",b);
    int i;
    int l=strlen(a);
    int L=strlen(b);
    if(l!=L)
    {
        printf("NO\n");
        return 0;
    }
    int flag=1;
    for(i=0;i<l;i++)
    {
        if(a[i]!=b[i])
        {
            if(i<l-1)
            flag=trans(a[i],a[i+1],b[i],b[i+1]);
            if(flag==0)
                flag=trans(a[i],a[i-1],b[i],b[i-1]);
        }
        if(!flag)
            break;
    }
    if(flag)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


/*62ms,1900KB*/

#include<cstdio>
#include<cstring>
const int maxn = 1000001;

char a[maxn], b[maxn];

int main(void)
{
    bool chk1 = false, chk2 = false;
    gets(a);
    gets(b);
    int len1 = strlen(a), len2 = strlen(b), i;
    if (len1 != len2)
        printf("NO");
    else
    {
        for (i = 0 ; i < len1 && a[i] == '0' ; i++)
            ;
        if (i < len1)
            chk1 = true;
        for (i = 0 ; i < len1 && b[i] == '0' ; i++)
            ;
        if (i < len1)
            chk2 = true;
        printf(!chk1 && chk2 || chk1 && !chk2 ? "NO" : "YES");
    }
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>

#include <list>
#include <vector>
#include <queue>
#include <stack>

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    string a,b;

    cin >> a >> b;

    bool flag = true;

    if(a.size() != b.size())
    {
        flag = false;
    }
    else
    {
        int tam = a.size(), numA, numB;

        for(int i=0; i<tam; i++)
        {
            if(a[i] == '0' && a[i+1] == '0' && (b[i] == '1' || b[i+1] == '1'))
            {
                flag = false;
            }
            else if(a[i] == '1' && a[i+1] == '0' && (b[i] != a[i] || b[i+1] != a[i+1]))
            {
                flag = false;
            }
        }
    }

    if(flag) printf("YES\n");
    else printf("NO\n");

    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>

#include <list>
#include <vector>
#include <queue>
#include <stack>

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    string a,b;

    cin >> a >> b;

    bool flag = true;

    if(a.size() != b.size())
    {
        flag = false;
    }
    else
    {
        int tam = a.size(), numA, numB;

        numA = numB = 0;

        for(int i=0; i<tam; i++)
        {
            if(a[i] == '1') numA++;
            if(b[i] == '1') numB++;
        }

        if(numB > numA || (numA > numB && numB == 0) || (tam == 1 && a[0] != b[0])) flag = false;
    }

    if(flag) printf("YES\n");
    else printf("NO\n");

    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>

#include <list>
#include <vector>
#include <queue>
#include <stack>

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    string a,b;

    cin >> a >> b;

    bool flag = true;

    if(a.size() != b.size())
    {
        flag = false;
    }
    else
    {
        int tam = a.size(), numA, numB;

        numA = numB = 0;

        for(int i=0; i<tam; i++)
        {
            if(a[i] == '1') numA++;
            if(b[i] == '1') numB++;
        }

        if((numA && !numB) || (!numA && numB) || (tam == 1 && a[0] != b[0])) flag = false;
    }

    if(flag) printf("YES\n");
    else printf("NO\n");

    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>

#include <list>
#include <vector>
#include <queue>
#include <stack>

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    string a,b;

    cin >> a >> b;

    bool flag = true;

    if(a.size() != b.size())
    {
        flag = false;
    }

    if(flag) printf("YES\n");
    else printf("NO\n");

    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>

#include <list>
#include <vector>
#include <queue>
#include <stack>

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    string a,b;

    cin >> a >> b;

    bool flag = true;

    if(a.size() != b.size())
    {
        flag = false;
    }
    else
    {
        int tam = a.size(), numA, numB;

        numA = numB = 0;

        for(int i=0; i<tam; i++)
        {
            if(a[i] == '1') numA++;
            if(b[i] == '1') numB++;
        }

        if(numB > numA) flag = false;
    }

    if(flag) printf("YES\n");
    else printf("NO\n");

    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>

#include <list>
#include <vector>
#include <queue>
#include <stack>

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    string a,b;

    cin >> a >> b;

    bool flag = true;

    if(a.size() != b.size())
    {
        flag = false;
    }
    else
    {
        int tam = a.size(), numA, numB;

        numA = numB = 0;

        for(int i=0; i<tam; i++)
        {
            if(a[i] == '1') numA++;
            if(b[i] == '1') numB++;
        }

        if((numA && !numB) || (tam == 1 && a[0] != b[0])) flag = false;
    }

    if(flag) printf("YES\n");
    else printf("NO\n");

    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>

#include <list>
#include <vector>
#include <queue>
#include <stack>

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n;

    scanf("%d",&n);

    long long int vet[n], x, y, maior=0, out=0;
    int i;

    for(i=0; i<n; i++)
    {
        cin >> vet[i];
    }

    x = 0;

    for(i=0; i<n; i++)
    {
        x = x^vet[i];
    }

    y=0;

    if(maior < x) out = maior = x;

    for(i=n-1; i>=0; i--)
    {
        y = y^vet[i];
        x = x^vet[i];

        if(maior < x+y)
        {
            maior = x+y;
            out = max(x,y);
        }
    }

    cout << out << endl;

    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>

#include <list>
#include <vector>
#include <queue>
#include <stack>

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    string a,b;

    cin >> a >> b;

    bool flag = true;

    if(a.size() != b.size())
    {
        flag = false;
    }
    else
    {
        int tam = a.size(), numA, numB;

        numA = numB = 0;

        for(int i=0; i<tam; i++)
        {
            if(a[i] == '1') numA++;
            if(b[i] == '1') numB++;
        }

        if(numB > numA || (numA > numB && numB == 0) || (tam == 1)) flag = false;
    }

    if(flag) printf("YES\n");
    else printf("NO\n");

    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>

#include <list>
#include <vector>
#include <queue>
#include <stack>

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    string a,b;

    cin >> a >> b;

    bool flag = true;

    if(a.size() != b.size())
    {
        flag = false;
    }
    else
    {
        int tam = a.size(), numA, numB;

        numA = numB = 0;

        for(int i=0; i<tam; i++)
        {
            if(a[i] == '1') numA++;
            if(b[i] == '1') numB++;
        }

        if(numB > numA || (tam == 1 && a[0] != b[0])) flag = false;
    }

    if(flag) printf("YES\n");
    else printf("NO\n");

    return 0;
}


#include<iostream>

using namespace std;

int main()
{
    string s1,s2;
    cin>>s1>>s2;
    if(s1.compare("1") == 0)
    {
//        if(s2.compare("1") == 0)
//            cout<<"YES";
//        else
            cout<<"NO";
    }
    else if(s1.compare("0") == 0)
    {
        if(s2.compare("0") == 0)
            cout<<"YES";
        else
            cout<<"NO";
    }

    else if(s2.compare("1") == 0)
    {
        if(s1.compare("1") == 0)
            cout<<"YES";
        else
            cout<<"NO";
    }
    else if(s2.compare("0") == 0)
    {
        if(s1.compare("0") == 0)
            cout<<"YES";
        else
            cout<<"NO";
    }

    else if(s2.size() % 2 != 0)
            cout<<"NO";

    else
    {
        bool b1 = false,b2 = false,b3 = false,b4 = false,b5 = false,b6 = false;
        for(int i=0;i<s1.size()-1;i++)
        {
            if(!b1 && s1[i] == '1' && s1[i+1] == '1')
                b1 = true;
            else if(!b2 && s1[i] == '0' && s1[i+1] == '0')
                b2  = true;
            else
                b3 = true;
        }

        for(int i=0;i<s2.size()-1;i++)
        {
            if(!b4 && s2[i] == '1' && s2[i+1] == '1')
                b4 = true;
            else if(!b5 && s2[i] == '0' && s2[i+1] == '0')
                b5  = true;
            else
                b6 = true;
        }

        bool status = true;
        if(b4 == true && b3 == false)
            status = false;
        if(b5 == true && b2 == false)
            status = false;
        if(b6 == true && b1 == false)
            status = false;
        if(status)
            cout<<"YES";
        else
            cout<<"NO";

    }
}


#include<iostream>

using namespace std;

int main()
{
    string s1,s2;
    cin>>s1>>s2;
    if(s1.compare("1") == 0)
    {
        if(s2.compare("1") == 0)
            cout<<"YES";
        else
            cout<<"NO";
    }
    else if(s1.compare("0") == 0)
    {
        if(s2.compare("0") == 0)
            cout<<"YES";
        else
            cout<<"NO";
    }

    else if(s2.compare("1") == 0)
    {
        if(s1.compare("1") == 0)
            cout<<"YES";
        else
            cout<<"NO";
    }
    else if(s2.compare("0") == 0)
    {
        if(s1.compare("0") == 0)
            cout<<"YES";
        else
            cout<<"NO";
    }

    else
    {
        bool b1 = false,b2 = false,b3 = false,b4 = false,b5 = false,b6 = false;
        for(int i=0;i<s1.size()-1;i++)
        {
            if(!b1 && s1[i] == '1' && s1[i+1] == '1')
                b1 = true;
            else if(!b2 && s1[i] == '0' && s1[i+1] == '0')
                b2  = true;
            else
                b3 = true;
        }

        for(int i=0;i<s2.size()-1;i++)
        {
            if(!b4 && s2[i] == '1' && s2[i+1] == '1')
                b4 = true;
            else if(!b5 && s2[i] == '0' && s2[i+1] == '0')
                b5  = true;
            else
                b6 = true;
        }

        bool status = true;
        if(b4 == true && b3 == false)
            status = false;
        if(b5 == true && b2 == false)
            status = false;
        if(b6 == true && b1 == false)
            status = false;
        if(status)
            cout<<"YES";
        else
            cout<<"NO";

    }
}


#include<iostream>

using namespace std;

int main()
{
    string s1,s2;
    cin>>s1>>s2;
    if(s1.compare("1") == 0)
    {
        if(s2.compare("1") == 0)
            cout<<"YES";
        else
            cout<<"NO";
    }
    else if(s1.compare("0") == 0)
    {
        if(s2.compare("0") == 0)
            cout<<"YES";
        else
            cout<<"NO";
    }

    else if(s2.compare("1") == 0)
    {
        if(s1.compare("1") == 0)
            cout<<"YES";
        else
            cout<<"NO";
    }
    else if(s2.compare("0") == 0)
    {
        if(s1.compare("0") == 0)
            cout<<"YES";
        else
            cout<<"NO";
    }

    else if(s2.size() % 2 != 0)
            cout<<"NO";

    else
    {
        bool b1 = false,b2 = false,b3 = false,b4 = false,b5 = false,b6 = false;
        for(int i=0;i<s1.size()-1;i++)
        {
            if(!b1 && s1[i] == '1' && s1[i+1] == '1')
                b1 = true;
            else if(!b2 && s1[i] == '0' && s1[i+1] == '0')
                b2  = true;
            else
                b3 = true;
        }

        for(int i=0;i<s2.size()-1;i++)
        {
            if(!b4 && s2[i] == '1' && s2[i+1] == '1')
                b4 = true;
            else if(!b5 && s2[i] == '0' && s2[i+1] == '0')
                b5  = true;
            else
                b6 = true;
        }

        bool status = true;
        if(b4 == true && b3 == false)
            status = false;
        if(b5 == true && b2 == false)
            status = false;
        if(b6 == true && b1 == false)
            status = false;
        if(status)
            cout<<"YES";
        else
            cout<<"NO";

    }
}


#include<iostream>

using namespace std;

int main()
{
    string s1,s2;
    cin>>s1>>s2;
    if(s1.compare("1") == 0)
    {
        if(s2.compare("1") == 0)
            cout<<"YES";
        else
            cout<<"NO";
    }
    else
    {
        bool b1 = false,b2 = false,b3 = false,b4 = false,b5 = false,b6 = false;
        for(int i=0;i<s1.size()-1;i++)
        {
            if(!b1 && s1[i] == '1' && s1[i+1] == '1')
                b1 = true;
            else if(!b2 && s1[i] == '0' && s1[i+1] == '0')
                b2  = true;
            else
                b3 = true;
        }

        for(int i=0;i<s2.size()-1;i++)
        {
            if(!b4 && s2[i] == '1' && s2[i+1] == '1')
                b4 = true;
            else if(!b5 && s2[i] == '0' && s2[i+1] == '0')
                b5  = true;
            else
                b6 = true;
        }

        bool status = true;
        if(b4 == true && b3 == false)
            status = false;
        if(b5 == true && b2 == false)
            status = false;
        if(b6 == true && b1 == false)
            status = false;
        if(status)
            cout<<"YES";
        else
            cout<<"NO";

    }
}


#include<iostream>

using namespace std;

int main()
{
    string s1,s2;
    cin>>s1>>s2;
    if(s1.size() == 1 && s2.size() == 1)
    {
        if( (s1 == "1" && s2 == "1") || (s1 == "0" && s2 == "0") )
            cout<<"YES";
        else
            cout<<"NO";
    }
    else if(s1.size() != s2.size())
        cout<<"NO";
    else
    {
        bool f1=false,f2=false;
        int count=0;
        for(int i=0;i<s1.size();i++)
            if(s1[i] == '0')
                count++;
        if(count == s1.size())
            f1 = true;
        count=0;
        for(int i=0;i<s2.size();i++)
            if(s2[i] == '0')
                count++;
        if(count == s2.size())
            f2 = true;
        if(f1 == f2)
            cout<<"YES";
        else
            cout<<"NO";

    }
}


/*
 * codeforces.cpp
 *
 *  Created on: Sep 18, 2013
 *      Author: Marwan
 */

#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <set>
#include <bitset>
#include <algorithm>
#include <cstring>

using namespace std;

#define abs(a) ((a) > 0 ? (a) : -(a) )
#define SZ(a)  ((int)a.size())
typedef long long ll;

int main() {
    string a, b;
    cin >> a >> b;

    if (a.size() != b.size()) {
        cout << "NO" << endl;
        return 0;
    }

    int x = 0, y = 0, n = a.size();

    for (int i = 0; i < n; i++) {
        x&= (1 << (a[i] - '0')) ;
        y&= (1 << (b[i] - '0')) ;
    }

    if (x == y)
        cout << "YES" << endl ;
    else
        cout << "NO" << endl ;

    return 0;
}


/*
 * codeforces.cpp
 *
 *  Created on: Sep 18, 2013
 *      Author: Marwan
 */

#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <set>
#include <bitset>
#include <algorithm>
#include <cstring>

using namespace std;

#define abs(a) ((a) > 0 ? (a) : -(a) )
#define SZ(a)  ((int)a.size())
typedef long long ll;

int main() {
    string a, b;
    cin >> a >> b;

    if (a.size() != b.size()) {
        cout << "NO" << endl;
        return 0;
    }

    int x = 0, y = 0, n = a.size();

    for (int i = 0; i < n; i++) {
        x |= (1 << (a[i] - '0'));
        y |= (1 << (b[i] - '0'));
    }

    if ((x >= 2 && y != 1) || (x == y))
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


/*
 * p3.cpp
 *
 *  Created on: Mar 13, 2013
 *      Author: Marwan
 */

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstring>
#include <sstream>
#include <complex>
#include <iomanip>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <bitset>
#include <climits>
#include <set>
#include <map>

using namespace std;

const int oo = (int)1e9;
const double PI = 2 * acos(0.0);
const double eps = 1e-9;
#define MP make_pair
#define SZ(x) (int)x.size()

int dcmp (double a, double b){
    return (fabs(a-b) <= eps) ? 0 : (( a < b ) ? -1 : 1) ;
}

typedef long long ll;
typedef pair<int,int> pii;

char a[1000009] ;
char b[1000009] ;

int main (){
#ifndef ONLINE_JUDGE
    freopen ("in.in", "rt", stdin);
//  freopen ("input.txt", "rt", stdin);
//  freopen ("output.txt", "wt", stdout);
    START:;
#endif

    if (scanf ("%s", a) == EOF) return 0;
    scanf ("%s", b) ;
    int n = strlen (a) ;
    int m = strlen (b) ;

    if (n != m)
        cout << "NO" << endl ;
    else {
        bool f = true ;
        for (int i=0 ; i < n ; i ++)
            if (a[i] != b[i] && a[i] == '0')
                f = false ;

        if (f) {
            vector <pii> vpi ;
            for (int i=0 ; i < n ; i++) {

                if (a[i] == '1' && b[i] =='0') {
                    int s = i ;
                    int e = i ;
                    while (e+1 <= n && a[e+1] == '1' && b[e+1] == '0')
                        e++, i++ ;

//                  cout << s << " " << e << endl ;
                    vpi.push_back(MP(s,e)) ;
                }
            }

            for (int i=0 ; i < SZ(vpi) ; i++) {
                if (vpi[i].first == 0 || a[vpi[i].first-1] == '1' || (vpi[i].second == n-1) || a[vpi[i].second + 1] == '1')
                    continue;
                f = false ;
            }
        }

        if (f)
            cout << "YES" << endl ;
        else
            cout << "NO" << endl ;
    }

#ifndef ONLINE_JUDGE
    goto START;
#endif
    return 0;
}


/*
 * p3.cpp
 *
 *  Created on: Mar 13, 2013
 *      Author: Marwan
 */

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstring>
#include <sstream>
#include <complex>
#include <iomanip>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <bitset>
#include <climits>
#include <set>
#include <map>

using namespace std;

const int oo = (int)1e9;
const double PI = 2 * acos(0.0);
const double eps = 1e-9;
#define MP make_pair
#define SZ(x) (int)x.size()

int dcmp (double a, double b){
    return (fabs(a-b) <= eps) ? 0 : (( a < b ) ? -1 : 1) ;
}

typedef long long ll;
typedef pair<int,int> pii;

char a[1000009] ;
char b[1000009] ;
int n ;
int mem[1000009][2] ;

int calc (int idx, int prv) {
    if (idx == n)
        return 1 ;

    int &r = mem[idx][prv] ;
    if (r != -1)
        return r ;

    r = 0 ;
    if (a[idx] == b[idx])
        r |= calc (idx+1, a[idx] - '0') ;
    else {
        if (a[idx] == '0' && b[idx] == '1')
            r = 0 ;
        else {
            if (prv == 1)
                r |= calc (idx+1, 0) ;
            else if ( idx + 1 < n && a[idx+1] == '1')
                r |= calc (idx+1, 0) ;
        }
    }

    return r ;
}

int main (){
#ifndef ONLINE_JUDGE
    freopen ("in.in", "rt", stdin);
//  freopen ("input.txt", "rt", stdin);
//  freopen ("output.txt", "wt", stdout);
    START:;
#endif

    if (scanf ("%s", a) == EOF) return 0;
    scanf ("%s", b) ;
    n = strlen (a) ;
    int m = strlen (b) ;

    if (n != m)
        cout << "NO" << endl ;
    else {
        memset (mem, -1, sizeof mem) ;

        if (calc (0,0) == 1)
            cout << "YES" << endl ;
        else
            cout << "NO" << endl ;
    }

#ifndef ONLINE_JUDGE
    goto START;
#endif
    return 0;
}


/*
 * codeforces.cpp
 *
 *  Created on: Sep 18, 2013
 *      Author: Marwan
 */

#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <set>
#include <bitset>
#include <algorithm>
#include <cstring>

using namespace std;

#define abs(a) ((a) > 0 ? (a) : -(a) )
#define SZ(a)  ((int)a.size())
typedef long long ll;

int main() {
    string a, b;
    cin >> a >> b;

    if (a.size() != b.size()) {
        cout << "NO" << endl;
        return 0;
    }

    int x = 0, y = 0, n = a.size();

    for (int i = 0; i < n; i++) {
        x |= (1 << (a[i] - '0'));
        y |= (1 << (b[i] - '0'));
    }

    if (x >= 2 && y != 1)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


/*
 * codeforces.cpp
 *
 *  Created on: Sep 18, 2013
 *      Author: Marwan
 */

#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <set>
#include <bitset>
#include <algorithm>
#include <cstring>

using namespace std;

#define abs(a) ((a) > 0 ? (a) : -(a) )
#define SZ(a)  ((int)a.size())
typedef long long ll;

int main() {
	string a, b;
	cin >> a >> b;

	if (a.size() != b.size()) {
		cout << "NO" << endl;
		return 0;
	}

	int x = 0, y = 0, n = a.size();

	for (int i = 0; i < n; i++) {
		x|= (1 << (a[i] - '0')) ;
		y|= (1 << (b[i] - '0')) ;
	}

	if ((x == 2 && y != x) || (y==2 && x != y))
		cout << "NO" << endl ;
	else
		cout << "YES" << endl ;

	return 0;
}


/*
 * p3.cpp
 *
 *  Created on: Mar 13, 2013
 *      Author: Marwan
 */

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstring>
#include <sstream>
#include <complex>
#include <iomanip>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <bitset>
#include <climits>
#include <set>
#include <map>

using namespace std;

const int oo = (int)1e9;
const double PI = 2 * acos(0.0);
const double eps = 1e-9;
#define MP make_pair
#define SZ(x) (int)x.size()

int dcmp (double a, double b){
    return (fabs(a-b) <= eps) ? 0 : (( a < b ) ? -1 : 1) ;
}

typedef long long ll;
typedef pair<int,int> pii;

char a[1000009] ;
char b[1000009] ;
int n ;
int mem[1000009][2] ;

int calc (int idx, int prv) {
    if (idx == n)
        return 1 ;

    int &r = mem[idx][prv] ;
    if (r != -1)
        return r ;

    r = 0 ;
    if (a[idx] == b[idx])
        r |= calc (idx+1, a[idx] - '0') ;
    else {
        if (a[idx] == '0' && b[idx] == '1')
            r = 0 ;
        else {
            if (prv == 1)
                r |= calc (idx+1, 0) ;
            else if ( idx + 1 < n && a[idx+1] == '1')
                r |= calc (idx+1, 0) ;
        }
    }

    return r ;
}

int main (){
#ifndef ONLINE_JUDGE
    freopen ("in.in", "rt", stdin);
//  freopen ("input.txt", "rt", stdin);
//  freopen ("output.txt", "wt", stdout);
    START:;
#endif

    if (scanf ("%s", a) == EOF) return 0;
    scanf ("%s", b) ;
    n = strlen (a) ;
    int m = strlen (b) ;

    if (n != m)
        cout << "NO" << endl ;
    else {
        memset (mem, -1, sizeof mem) ;

        if (calc (1,a[0]-'0') == 1)
            cout << "YES" << endl ;
        else
            cout << "NO" << endl ;
    }

#ifndef ONLINE_JUDGE
    goto START;
#endif
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <utility>
#include <map>
#include <cmath>
#include <set>
#include <list>
#include <climits>
#include <iomanip>
#include <numeric>
using namespace std;

#define foru(i,n) for(int i = 0; i < (n); i++)
#define ford(i,n) for(int i = (n); i >= 0; i--)
#define forab(i,a,b) for(int i = (a); i <= (b); i++)
#define forabd(i,a,b) for(int i = (a); i >= (b); i--)
#define gcd(x,y) __gcd((x),(y))
#define mp(a,b)  make_pair((a),(b))
#define pb(a)    push_back((a))
#define all(a)   a.begin(), a.end()
#define F first
#define S second

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    #ifdef OLIMP_DBG1
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    string a,b;
    cin >> a >> b;
    if (a.size() != b.size())cout << "NO";
    else if (a == b) cout << "YES";
    else if ((find(all(a),'1') != a.end()) && (find(all(b),'1') != b.end())) cout << "YES";
    else cout << "NO";
    return 0;

}


#include <cstdlib>
#include <iostream>

#define foru(i,n) for(int i = 0; i < (n); i++)

using namespace std;
string a,b;
int n1, n2, p, c;
int main(int argc, char *argv[])
{
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
   // 49 48
   cin >> a >> b;
   if (a.size() != b.size()) { cout << "NO";  return 1;}
   foru(i,a.size()-1){

      p = (a[i]-48) ^ (a[i+1]-48);
      c = (a[i]-48) | (a[i+1]-48);
      if (b[i] == char(p+48))
         if (b[i+1] == char(c+48))
            {
                    a[i] = p;
                    a[i+1] = c;
            }
         else { cout << "NO";  return 1;}
      else if (b[i] == char(c+48))
              if (b[i+1] == char(p+48))
                 {
                    a[i] = c;
                    a[i+1] = p;
                 }
               else { cout << "NO";  return 1;}
     else { cout << "NO";  return 1;}
   }
   cout << "YES";

   return EXIT_SUCCESS;
}