t = int(input())

for _ in range(t):
	n = map(int,input())
	array = list(map(int,input().split()))
	array.sort()

	out = []

	while len(array) > 1:

		out += [array[0],array[-1]]
		array = array[1:-1]

	print(*out[::-1])


def merge(array,start,pointer,end):
	n1 = pointer - start + 1
	n2 = end-pointer
	left = array[start:pointer+1]
	right = array[pointer+1:end+1]
	i = j = 0
	k = start

	while i < n1 and j < n2 :
		if left[i] <= right[j]:
			array[k] = left[i]
			i += 1
		else:
			array[k] = right[j]
			j += 1
		k+=1

	while i < n1:
		array[k] = left[i]
		i+=1
		k+=1

	while j < n2:
		array[k] = right[j]
		j+=1
		k+=1

def merge_sort(array):
	merge_sort2(array,0,len(array)-1)

def merge_sort2(array,start,end):
	if start < end:
		m = (start+end)//2
		merge_sort2(array,start,m)
		merge_sort2(array,m+1,end)
		merge(array,start,m,end)

def rearrange(array):
	d = None
	res = 99999

	for i in range(len(array)):
		for j in range(i+1,len(array)):
			d = min(res,abs(array[i]-array[j]))
			if d <= res:
				res = d
				array[i+1],array[j] = array[j],array[i+1]
			else:
				array[i],array[j] = array[j],array[i]

t = int(input())

for _ in range(t):
	n = int(input())
	arrs = list(map(int,input().split()))

	if min(arrs) <= 0:

		rearrange(arrs)
		print(*arrs)
	else:

		merge_sort(arrs)
		print(*arrs)


t = int(input())

for _ in range(t):
	n = int(input())
	array = list(map(int,input().split()))

	array.sort()
	out = []

	while len(array) > 1:
		out+= [array[0],array[-1]]
		array = array[1:-1]

	out += array
	print(*out[::-1])


t = int(input())

for _ in range(t):
	n = map(int,input())
	array = list(map(int,input().split()))
	array.sort()

	out = []

	while len(array) > 1:

		out += [array[0],array[-1]]
		array = array[1:-1]

	out += array

	print(*out[::-1])


t = int(input())

for _ in range(t):
	n = int(input())
	array = list(map(int,input().split()))

	array.sort()
	out = []

	while len(array) > 0:
		out+= [array[0],array[-1]]
		array = array[1:-1]

	print(*out[::-1])


def merge(array,start,pointer,end):
	n1 = pointer - start + 1
	n2 = end-pointer
	left = array[start:pointer+1]
	right = array[pointer+1:end+1]
	i = j = 0
	k = start

	while i < n1 and j < n2 :
		if left[i] <= right[j]:
			array[k] = left[i]
			i += 1
		else:
			array[k] = right[j]
			j += 1
		k+=1

	while i < n1:
		array[k] = left[i]
		i+=1
		k+=1

	while j < n2:
		array[k] = right[j]
		j+=1
		k+=1

def merge_sort(array):
	merge_sort2(array,0,len(array)-1)

def merge_sort2(array,start,end):
	if start < end:
		m = (start+end)//2
		merge_sort2(array,start,m)
		merge_sort2(array,m+1,end)
		merge(array,start,m,end)

def rearrange(array):
	d = None
	res = 99999999

	for i in range(len(array)):
		for j in range(i+1,len(array)):
			if i == j:
				continue

			d = min(res,abs(array[i]-array[j]))
			if d <= res:
				res = d
				array[i+1],array[j] = array[j],array[i+1]

t = int(input())
output = []

for _ in range(t):
	n = int(input())
	arrs = list(map(int,input().split()))

	if min(arrs) <= 0:

		rearrange(arrs)
		output.append(arrs)
	else:

		merge_sort(arrs)
		output.append(arrs)

for j in output:
	print(*j)


import sys
sys.setrecursionlimit(10000)

def encode(word,output):

	if len(word) == 1:
		output.insert(len(output),word[0])
		return

	word = list(word)
	m = 0

	if len(word)%2 == 0:
		m = len(word)//2
		m -=1
	else:
		m = len(word) // 2

	output.insert(len(output),word[m])
	del word[m]
	encode(word,output)

def decode(word,output):
	if len(word) == 0:
		return

	word = list(word)
	m = len(output) // 2

	if len(word) == 1:
		output.insert(m,word[0])
		return

	if len(output) == 0:
		output.insert(m,word[len(word)-1])
		del word[len(word)-1]

	output.insert(m,word[len(word)-1])
	del word[len(word)-1]

	decode(word,output)

n = int(input())
s = input()
output = []
decode(s,output)
print(''.join(output))


#include <stdio.h>
#include <string.h>

int main() {
	int n;
	scanf("%d",&n);
	printf("33");
}


#include <stdio.h>
#include <string.h>

char s[10001];

int main() {
	scanf("%s",s);
	int l=strlen(s);
	if(s[0]=='0') while(1);
	puts("??");
}


#include <stdio.h>
#include <string.h>

int main() {
	int n;
	scanf("%d",&n);
	printf("35");
}


#include <stdio.h>
#include <string.h>

int main() {
	int n;
	scanf("%d",&n);
	printf("26");
}


#include <stdio.h>
#include <string.h>

int main() {
	int n;
	scanf("%d",&n);
	printf("10");
}


#include <stdio.h>
#include <string.h>

int main() {
	int n;
	scanf("%d",&n);
	printf("36");
}


#include <stdio.h>
#include <string.h>

char s[10001];

int main() {
	scanf("%s",s);
	int l=strlen(s);
	if(l>10) while(1);
	for(int i=0;s[i];i++) {
		if(s[i]<'0' || s[i]>'9') while(1);
	}
	puts("??");
}


#include <stdio.h>

char buf[10001];

int main() {
	puts("your bet.");
}


#include <stdio.h>

char s[10001];

int main() {
	int cnt=0;
	while(~scanf("%s",s)) cnt++;
	if(cnt==1) while(1);
}


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main() {
	srand((unsigned)time(0));
	int n;
	scanf("%d",&n);
	if(rand()%2) puts("Odd");
	else puts("Even");
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    srand(time(NULL)) ;
    int r = rand() % 36 + 1 ;
    cout << r << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    srand(time(NULL)) ;
    int r = rand() % 2 ;
    if ( r ) cout << 20 << endl ;
    else cout << 18 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    cout << 13 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    cout << 3 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    cout << 36 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    srand(time(NULL)) ;
    int r = rand() % 3 ;
    if ( r ) cout << 20 << endl ;
    else cout << 18 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    cout << 17 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    cout << 11 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    cout << 6 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    srand(time(NULL)) ;
    int r = rand() % 12 ;
    cout << 3 * r + 2 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    cout << 7 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    cout << 5 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    srand(time(NULL)) ;
    int r = rand() % 31 ;
    if ( r & 1 ) cout << 20 << endl ;
    else cout << 18 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    cout << 16 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    cout << 9 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    cout << 10 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    cout << 20 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    srand(time(NULL)) ;
    int r = rand() % 36 + 1 ;
    cout << r << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    cout << rand() % 36 + 1 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    cout << 1 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    cout << "Even" << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    srand(time(NULL)) ;
    int r = rand() % 2 ;
    if ( r ) cout << 20 << endl ;
    else cout << 18 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    cout << 18 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    cout << 8 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    cout << 2 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    cout << 15 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    srand(time(NULL)) ;
    int r = rand() % 3 ;
    if ( r ) cout << 20 << endl ;
    else cout << 18 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    cout << 12 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    cout << 14 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    cout << 4 << endl ;
    return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
int main(){
    srand(time(NULL)) ;
    int r = rand() % 12 ;
    cout << 3 * r + 2 << endl ;
    return 0 ;
}


#include <iostream>
using namespace std ;
int main()
{
    return cout << 26 , 0 ;
}


#include <bits/stdc++.h>
using namespace std ;
int main()
{
    return cout << 2 , 0 ;
}


#include <iostream>
using namespace std ;
int main()
{
    return cout << 29 , 0 ;
}


#include <iostream>
using namespace std ;
int main()
{
    return cout << 30 , 0 ;
}


#include <iostream>
using namespace std ;
int main()
{
    return cout << "Red" , 0 ;
}//


#include <iostream>
using namespace std ;
int main()
{
    return cout << "Red" , 0 ;
}////


#include <bits/stdc++.h>
using namespace std ;
int main()
{
    return cout << 32 , 0 ;
}


#include <iostream>
using namespace std ;
int main()
{
    return cout << 19 , 0 ;
}


#include <iostream>
using namespace std ;
int main()
{
    return cout << 22 , 0 ;
}


#include <iostream>
using namespace std ;
int main()
{
    return cout << 31 , 0 ;
}


#include <iostream>
using namespace std ;
int main()
{
    return cout << 28 , 0 ;
}


#include <iostream>
using namespace std ;
int main()
{
    return cout << 24 , 0 ;
}


#include <iostream>
using namespace std ;
int main()
{
    return cout << 23 , 0 ;
}


#include <bits/stdc++.h>
using namespace std ;
int main()
{
    return cout << 33 , 0 ;
}


#include <bits/stdc++.h>
using namespace std ;
int main()
{
    return cout << 3 , 0 ;
}


#include <iostream>
using namespace std ;
int main()
{
    return cout << 21 , 0 ;
}


#include <iostream>
using namespace std ;
int main()
{
    return cout << "Red" , 0 ;
}///


#include <bits/stdc++.h>
using namespace std ;
int main()
{
    return cout << 35 , 0 ;
}


#include <bits/stdc++.h>
using namespace std ;
int main()
{
    return cout << 1 , 0 ;
}


#include <iostream>
using namespace std ;
int main()
{
    return cout << "Integer" , 0 ;
}


#include <iostream>
using namespace std ;
int main()
{
    return cout << 18 , 0 ;
}


#include <bits/stdc++.h>
using namespace std ;
int main()
{
    return cout << 34 , 0 ;
}


#include <bits/stdc++.h>
using namespace std ;
int main()
{
    return cout << 36 , 0 ;
}


#include<bits/stdc++.h>
using namespace std;
int t;
int main(){
    cin>>t;
    char arr[t+1][t+1];
    for(int i=1;i<=t;i++){
        for(int j=1;j<=t;j++){
            cin>>arr[i][j];
        }
    }
    bool flag=true;
     for(int i=1;i<=t&&flag;i++){
       if(flag==false){
         break;
       }
        for(int j=1;j<=t;j++){
          int ans=0;
            if(j-1>0){
                char x=arr[i][j-1];
                if(x=='o'){
                    ans++;
                }
            }
            if(j+1<=t){
                char x=arr[i][j+1];
                if(x=='o'){
                    ans++;
                }
            }
            if(i-1>0){
                char x=arr[i-1][j];
                if(x=='o'){
                    ans++;
                }
            }
            if(i+1<=t){
                char x=arr[i+1][j];
                if(x=='o'){
                    ans++;
                }
            }
            if(ans%2!=0){
          flag=false;
          break;
        }
        }
    }
    if(flag==true){
      cout<<"YES";
    }
    else{
      cout<<"NO";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int t;
int main(){
    cin>>t;
    char arr[t+1][t+1];
    for(int i=1;i<=t;i++){
        for(int j=1;j<=t;j++){
            cin>>arr[i][j];
        }
    }
    bool flag=true;
     for(int i=1;i<=t;i++){
       if(flag==false){
         break;
       }
        int ans=0;
        for(int j=1;j<=t;j++){
            if(j-1>0){
                char x=arr[i][j-1];
                if(x=='o'){
                    ans++;
                }
            }
            if(j+1<=t){
                char x=arr[i][j+1];
                if(x=='o'){
                    ans++;
                }
            }
            if(i-1>0){
                char x=arr[i-1][j];
                if(x=='o'){
                    ans++;
                }
            }
            if(i+1<=t){
                char x=arr[i+1][j];
                if(x=='o'){
                    ans++;
                }
            }
        }
        if(ans%2!=0){
          cout<<i;
          flag=false;
        }
    }
    if(flag==true){
      cout<<"YES";
    }
    else{
      cout<<"NO";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int t;
int main(){
    cin>>t;
    char arr[t+1][t+1];
    for(int i=1;i<=t;i++){
        for(int j=1;j<=t;j++){
            cin>>arr[i][j];
        }
    }
    bool flag=true;
     for(int i=1;i<=t&&flag;i++){
       if(flag==false){
         break;
       }
        for(int j=1;j<=t;j++){
          int ans=0;
            if(j-1>0){
                char x=arr[i][j-1];
                if(x=='o'){
                    ans++;
                }
            }
            if(j+1<=t){
                char x=arr[i][j+1];
                if(x=='o'){
                    ans++;
                }
            }
            if(i-1>0){
                char x=arr[i-1][j];
                if(x=='o'){
                    ans++;
                }
            }
            if(i-1<=t){
                char x=arr[i-1][j];
                if(x=='o'){
                    ans++;
                }
            }
            if(ans%2!=0){
          flag=false;
          break;
        }
        }
    }
    if(flag==true){
      cout<<"YES";
    }
    else{
      cout<<"NO";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int t;
int main(){
    cin>>t;
    char arr[t+1][t+1];
    for(int i=1;i<=t;i++){
        for(int j=1;j<=t;j++){
            cin>>arr[i][j];
        }
    }
    bool flag=true;
     for(int i=1;i<=t;i++){
        int ans=0;
        for(int j=1;j<=t;j++){
          if(arr[j-1][i]=='o')ans++;
            if(arr[j+1][i]=='o')ans++;
            if(arr[j][i-1]=='o')ans++;
            if(arr[j][i+1]=='o')ans++;
        }
        if(ans%2!=0){
          flag=false;
        }
    }
    if(flag==true){
      cout<<"YES";
    }
    else{
      cout<<"NO";
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <bits/stdc++.h>
#define S string
#define IO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define LL long long
#define P bool
#include<time.h>
using namespace std;

int main()
{
    IO
    int n,x,k,z,c=0,m=0,b=0;
    cin>>n;
    bool s=false;
    char a[n][n];
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            cin>>a[i][j];
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            if(a[i][j]=='o')
                c++;
        }
        if(c==n)
        {
            s=true;
            cout<<"YES";
            break;
        }
    }
    if(!s)
    {
        c=0;
        for(int i=0; i<n; i++)
        {
            for(int j=0; j<n; j++)
            {
                if(i+j==n)
                    if(a[i][j]=='o')
                        c++;
            }
            if(c==n)
            {
                s=true;
                cout<<"YES";
                break;
            }
        }
    }
    if(!s)
    {
        c=0;
        for(int i=0; i<n; i++)
        {
            for(int j=0; j<n; j++)
            {
                if(a[j][i]=='o')
                    c++;
            }
            if(c==n)
            {
                s=true;
                cout<<"YES";
                break;
            }
        }
    }
    if(!s)
    {
        c=0;
        for(int i=0; i<n; i++)
        {
            if(a[i][i]=='o')
                c++;
        }
        if(c==n)
        {
            s=true;
            cout<<"YES";
        }
    }
    if(!s)
        cout<<"NO";
}


#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long LL;
int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    char mp[110][110];
    cin>>n;
  //  memset(mp,'*',sizeof(mp));
    for(int i=1;i<=n;++i)
        for(int j=1;j<=n;++j)
            cin>>mp[j][i];
    bool flag = true;
    for(int i=1;i<=n && flag;++i)
    {
        int cnt=0;
        for(int j=1;j<=n;++j)
        {
            if(mp[j-1][i]=='o')cnt++;
            if(mp[j+1][i]=='o')cnt++;
            if(mp[j][i-1]=='o')cnt++;
            if(mp[j][i+1]=='o')cnt++;
            if(cnt%2!=0)
            {
                flag = false;
                break;
            }
        }
    }
    if(flag)
    cout<<"YES";
    else  cout<<"NO";
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <bits/stdc++.h>
#define S string
#define IO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define LL long long
#define P bool
#include<time.h>
using namespace std;

int main()
{
    IO
    int n,x,k,z,c=0,m=0,b=0;
    cin>>n;
    bool s=false;
    char a[n][n];
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            cin>>a[i][j];
       bool flag = true;
    for(int i=1;i<=n ;++i)
    {
        int cnt=0;
        for(int j=1;j<=n;++j)
        {
            if(a[j-1][i]=='o')cnt++;
            if(a[j+1][i]=='o')cnt++;
            if(a[j][i-1]=='o')cnt++;
            if(a[j][i+1]=='o')cnt++;
            if(cnt%2!=0)
            {
                flag = false;
                break;
            }
        }
}
 if(flag)
    cout<<"YES";
 else cout<<"NO";

}


#include <iostream>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <bits/stdc++.h>
#define S string
#define IO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define LL long long
#define P bool
#include<time.h>
using namespace std;

int main()
{
    IO
    int n,x,k,z,c=0,m=0,b=0;
    cin>>n;
    bool s=false;
    char a[n][n];
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            cin>>a[i][j];
    if(n>2)
    {
        bool flag = true;
        for(int i=1; i<n-1 ; ++i)
        {
            int cnt=0;
            for(int j=1; j<n-1; ++j)
            {
                if(a[j-1][i]=='o')cnt++;
                if(a[j+1][i]=='o')cnt++;
                if(a[j][i-1]=='o')cnt++;
                if(a[j][i+1]=='o')cnt++;
                if(cnt%2!=0)
                {
                    flag = false;
                    break;
                }
            }
        }
        if(flag)
            cout<<"YES";
        else cout<<"NO";
    }
    else cout<<"NO";
}


#include <iostream>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <bits/stdc++.h>
#define S string
#define IO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define LL long long
#define P bool
#include<time.h>
using namespace std;

int main()
{
    IO
    int n,x,k,z,c=0,m=0,b=0;
    cin>>n;
    bool s=false;
    char a[n][n];
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            cin>>a[i][j];
    /*for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            if(a[i][j]=='o')
                c++;
        }
        if(c==n)
        {
            s=true;
            cout<<"YES";
            break;
        }
    }
    if(!s)
    {
        c=0;
        for(int i=0; i<n; i++)
        {
            for(int j=0; j<n; j++)
            {
                if(a[j][i]=='o')
                    c++;
            }
            if(c==n)
            {
                s=true;
                cout<<"YES*";
                break;
            }
        }
    }*/
    if(!s)
    {
        c=0;
        for(int i=0; i<n; i++)
        {
            for(int j=0; j<n; j++)
            {
                if(i+j==n)
                    if(a[i][j]=='o')
                        c++;
            }
            if(c==n)
            {
                s=true;
                cout<<"YES";
                break;
            }
        }
    }

    if(!s)
    {
        c=0;
        for(int i=0; i<n; i++)
        {
            if(a[i][i]=='o')
                c++;
        }
        if(c==n)
        {
            s=true;
            cout<<"YESk";
        }
    }
    if(!s)
        cout<<"NO";
}


#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long LL;
int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    char mp[110][110];
    cin>>n;
    memset(mp,'*',sizeof(mp));
    for(int i=1;i<=n;++i)
        for(int j=1;j<=n;++j)
            cin>>mp[j][i];
    bool flag = true;
    for(int i=1;i<=n && flag;++i)
    {
        int cnt=0;
        for(int j=1;j<=n;++j)
        {
            if(mp[j-1][i]=='o')cnt++;
            if(mp[j+1][i]=='o')cnt++;
            if(mp[j][i-1]=='o')cnt++;
            if(mp[j][i+1]=='o')cnt++;
            if(cnt%2!=0)
            {
                flag = false;
                break;
            }
        }
    }
    if(flag)
    cout<<"YES";
    else  cout<<"NO";
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <bits/stdc++.h>
#define S string
#define IO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define LL long long
#define P bool
#include<time.h>
using namespace std;

int main()
{
    IO
    int n,x,k,z,c=0,m=0,b=0;
    cin>>n;
    bool s=false;
    char a[n][n];
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            cin>>a[i][j];
       bool flag = true;
        for(int i=1; i<n-1 &&flag ; ++i)
        {
            int cnt=0;
            for(int j=1; j<n-1; ++j)
            {
                if(a[j-1][i]=='o')cnt++;
                if(a[j+1][i]=='o')cnt++;
                if(a[j][i-1]=='o')cnt++;
                if(a[j][i+1]=='o')cnt++;
                if(cnt%2!=0)
                {
                    flag = false;
                    break;
                }
            }
        }
        if(flag)
            cout<<"YES";
        else cout<<"NO";

}


#include <iostream>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <bits/stdc++.h>
#define S string
#define IO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define LL long long
#define P bool
#include<time.h>
using namespace std;

int main()
{
    IO
    int n,x,k,z,c=0,m=0,b=0;
    cin>>n;
    bool s=false;
    char a[n][n];
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            cin>>a[i][j];
    /*for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            if(a[i][j]=='o')
                c++;
        }
        if(c==n)
        {
            s=true;
            cout<<"YES";
            break;
        }
    }
    if(!s)
    {
        c=0;
        for(int i=0; i<n; i++)
        {
            for(int j=0; j<n; j++)
            {
                if(a[j][i]=='o')
                    c++;
            }
            if(c==n)
            {
                s=true;
                cout<<"YES*";
                break;
            }
        }
    }*/
    if(!s)
    {
        c=0;
        for(int i=0; i<n; i++)
        {
            for(int j=0; j<n; j++)
            {
                if(i+j==n)
                    if(a[i][j]=='o')
                        c++;
            }
            if(c==n)
            {
                s=true;
                cout<<"YES";
                break;
            }
        }
    }

    if(!s)
    {
        c=0;
        for(int i=0; i<n; i++)
        {
            if(a[i][i]=='o')
                c++;
        }
        if(c==n)
        {
            s=true;
            cout<<"YES";
        }
    }
    if(!s)
        cout<<"NO";
}


#include <iostream>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <bits/stdc++.h>
#define S string
#define IO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define LL long long
#define P bool
#include<time.h>
using namespace std;

int main()
{
    IO
    int n,x,k,z,c=0,m=0,b=0;
   cin>>n;
   bool s=false;
   char a[n][n];
   for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
    cin>>a[i][j];
   for(int i=0;i<n;i++)
   {
       for(int j=0;j<n;j++)
       {
           if(a[i][j]=='o')
            c++;
       }
       if(c==n)
       { s=true;
           cout<<"YES";
           break;
       }

   }
   if(!s)
   {for(int i=0;i<n;i++)
   {
       for(int j=0;j<n;j++)
       { if(i+j==n)
           if(a[i][j]=='o')
            c++;
       }
       if(c==n)
       { s=true;
           cout<<"YES";
           break;
       }
   }
   }
   if(!s)
   {for(int i=0;i<n;i++)
   {
       for(int j=0;j<n;j++)
       {
           if(a[j][i]=='o')
            c++;
       }
       if(c==n)
       {s=true;
           cout<<"YES";
           break;
       }
   }
   }
   if(!s)
   {for(int i=0;i<n;i++)
   {
           if(a[i][i]=='o')
            c++;
   }
       if(c==n)
       { s=true;
           cout<<"YES";
       }
   }
   if(!s)
    cout<<"NO";
}


#include <iostream>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <bits/stdc++.h>
#define S string
#define IO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define LL long long
#define P bool
#include<time.h>
using namespace std;

int main()
{
    IO
    int n,x,k,z,c=0,m=0,b=0;
    cin>>n;
    bool s=false;
    char a[n][n];
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            cin>>a[i][j];
    /*for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            if(a[i][j]=='o')
                c++;
        }
        if(c==n)
        {
            s=true;
            cout<<"YES";
            break;
        }
    }
    if(!s)
    {
        c=0;
        for(int i=0; i<n; i++)
        {
            for(int j=0; j<n; j++)
            {
                if(i+j==n)
                    if(a[i][j]=='o')
                        c++;
            }
            if(c==n)
            {
                s=true;
                cout<<"YES";
                break;
            }
        }
    }
    if(!s)
    {
        c=0;
        for(int i=0; i<n; i++)
        {
            for(int j=0; j<n; j++)
            {
                if(a[j][i]=='o')
                    c++;
            }
            if(c==n)
            {
                s=true;
                cout<<"YES*";
                break;
            }
        }
    }*/
    if(!s)
    {
        c=0;
        for(int i=0; i<n; i++)
        {
            if(a[i][i]=='o')
                c++;
        }
        if(c==n)
        {
            s=true;
            cout<<"YES";
        }
    }
    if(!s)
        cout<<"NO";
}


#include <iostream>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <bits/stdc++.h>
#define S string
#define IO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define LL long long
#define P bool
#include<time.h>
using namespace std;

int main()
{
    IO
    int n,x,k,z,c=0,m=0,b=0;
    cin>>n;
    bool s=false;
    char a[n][n];
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            cin>>a[i][j];
       bool flag = true;
    for(int i=1;i<n-1 ;++i)
    {
        int cnt=0;
        for(int j=1;j<n-1;++j)
        {
            if(a[j-1][i]=='o')cnt++;
            if(a[j+1][i]=='o')cnt++;
            if(a[j][i-1]=='o')cnt++;
            if(a[j][i+1]=='o')cnt++;
            if(cnt%2!=0)
            {
                flag = false;
                break;
            }
        }
}
 if(flag)
    cout<<"YES";
 else cout<<"NO";

}


#include <iostream>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <bits/stdc++.h>
#define S string
#define IO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define LL long long
#define P bool
#include<time.h>
using namespace std;

int main()
{
    IO
    int n,x,k,z,c=0,m=0,b=0;
    cin>>n;
    bool s=false;
    char a[n][n];
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            cin>>a[i][j];
    bool flag = true;
    bool f = true;

    for(int i=0; i<n &&flag ; ++i)
    {
        f=false;
        int cnt=0;
        for(int j=0; j<n; ++j)
        {
            if(i==0&&j!=n-1&&j!=0)
            {
                if(a[j-1][i]=='o')cnt++;
                cnt++;
                if(a[j+1][i]=='o')cnt++;
                cnt++;
                if(a[j][i+1]=='o')cnt++;
                cnt++;

            }
            else if(i==0&&j==n-1)
            {
                if(a[j-1][i]=='o')cnt++;
                 cnt++;
                if(a[j][i+1]=='o')cnt++;
                cnt++;
            }
             else if(i==0&&j==0)
            {
                if(a[j+1][i]=='o')cnt++;
                 cnt++;
                if(a[j][i+1]=='o')cnt++;
                cnt++;
            }
            else if(j==0&&i!=n-1)
            {
            if(a[j][i-1]=='o')cnt++;
            if(a[j][i+1]=='o')cnt++;
            if(a[j+1][i]=='o')cnt++;
            }
            else if(j==0&&i==n-1)
            {
            if(a[j][i-1]=='o')cnt++;
            if(a[j+1][i]=='o')cnt++;
            }
            else if(j!=0&&i==n-1&&j!=n-1)
            {
            if(a[j][i-1]=='o')cnt++;
            if(a[j+1][i]=='o')cnt++;
            if(a[j-1][i]=='o')cnt++;
            }
            else if(i==n-1&&j==n-1)
            {
            if(a[j][i-1]=='o')cnt++;
            if(a[j-1][i]=='o')cnt++;
            }
            else if(j!=0&&i==n-1&&j!=n-1)
            {
            if(a[j][i-1]=='o')cnt++;
            if(a[j+1][i]=='o')cnt++;
            if(a[j-1][i]=='o')cnt++;
            }
            else if(j==n-1&&i!=n-1)
            {
            if(a[j][i-1]=='o')cnt++;
            if(a[j-1][i]=='o')cnt++;
            if(a[j][i+1]=='o')cnt++;
            }
            else
            {
            if(a[j-1][i]=='o')cnt++;
            if(a[j+1][i]=='o')cnt++;
            if(a[j][i-1]=='o')cnt++;
            if(a[j][i+1]=='o')cnt++;
            }
            if(cnt%2!=0)
            {
                flag = false;
                break;
            }
        }
    }
    if(flag&&f==false)
        cout<<"YES";
    else cout<<"NO";

}


#include <iostream>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <bits/stdc++.h>
#define S string
#define IO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define LL long long
#define P bool
#include<time.h>
using namespace std;

int main()
{
    IO
    int n,x,k,z,c=0,m=0,b=0;
    cin>>n;
    bool s=false;
    char a[n][n];
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            cin>>a[i][j];
    /*for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            if(a[i][j]=='o')
                c++;
        }
        if(c==n)
        {
            s=true;
            cout<<"YES";
            break;
        }
    }
    if(!s)
    {
        c=0;
        for(int i=0; i<n; i++)
        {
            for(int j=0; j<n; j++)
            {
                if(i+j==n)
                    if(a[i][j]=='o')
                        c++;
            }
            if(c==n)
            {
                s=true;
                cout<<"YES";
                break;
            }
        }
    }
    if(!s)
    {
        c=0;
        for(int i=0; i<n; i++)
        {
            for(int j=0; j<n; j++)
            {
                if(a[j][i]=='o')
                    c++;
            }
            if(c==n)
            {
                s=true;
                cout<<"YES*";
                break;
            }
        }
    }*/
    if(!s)
    {
        c=0;
        for(int i=0; i<n; i++)
        {
            if(a[i][i]=='o')
                c++;
        }
        if(c==n)
        {
            s=true;
            cout<<"YESk";
        }
    }
    if(!s)
        cout<<"NO";
}


#include <iostream>

using namespace std;

bool isvalid(int x,int y,int n)
{
    if(x<0||x>=n)   return 0;
    if(y<0||y>=n)   return 0;
    return 1;
}

int main()
{
    int n;
    cin>>n;
    char grid[n][n];
    for(int i=0;i<n;i++)
         for(int j=0;j<n;j++)
                cin>>grid[i][j];

    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            {
             int count=0;
             if(isvalid(i+1,j,n))    if(grid[i+1][j]=='o')  count++;
             if(isvalid(i,j+1,n))    if(grid[i][j+1]=='o')  count++;
             if(isvalid(i-1,j,n))    if(grid[i-1][j]=='o')  count++;
             if(isvalid(i,j-1,n))    if(grid[i][j-1]=='o')  count++;
             if(count%2==1) {cout<<"NO"<<'\n';return 0;}
            }

    cout<<"YES"<<'\n';

    return 0;
}


#include <iostream>

using namespace std;

bool isvalid(int x,int y,int n)
{
    if(x<0||x>=n)   return 0;
    if(y<0||y>=n)   return 0;
    return 1;
}

int main()
{
    int n;
    cin>>n;
    int grid[n][n];
    for(int i=0;i<n;i++)
         for(int j=0;j<n;j++)
                cin>>grid[i][j];

    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            {int count=0;
             if(isvalid(i+1,j,4))    if(grid[i+1][j]=='o')  count++;
             if(isvalid(i,j+1,4))    if(grid[i][j+1]=='o')  count++;
             if(isvalid(i-1,j,4))    if(grid[i-1][j]=='o')  count++;
             if(isvalid(i,j-1,4))    if(grid[i][j-1]=='o')  count++;
             if(count%2==1) {cout<<"NO"<<'\n';return 0;}
            }

    cout<<"YES"<<'\n';

    return 0;
}


#include <iostream>

using namespace std;

bool isvalid(int x,int y,int n)
{
    if(x<0||x>=n)   return 0;
    if(y<0||y>=n)   return 0;
    return 1;
}

int main()
{
    int n;
    cin>>n;
    char grid[n][n];
    for(int i=0;i<n;i++)
         for(int j=0;j<n;j++)
                cin>>grid[i][j];

    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            {if(grid[i][j]=='x')    continue;
             int count=0;
             if(isvalid(i+1,j,4))    if(grid[i+1][j]=='o')  count++;
             if(isvalid(i,j+1,4))    if(grid[i][j+1]=='o')  count++;
             if(isvalid(i-1,j,4))    if(grid[i-1][j]=='o')  count++;
             if(isvalid(i,j-1,4))    if(grid[i][j-1]=='o')  count++;
             if(count%2==1) {cout<<"NO"<<'\n';return 0;}
            }

    cout<<"YES"<<'\n';

    return 0;
}


#include <iostream>

using namespace std;

bool isvalid(int x,int y,int n)
{
    if(x<0||x>=n)   return 0;
    if(y<0||y>=n)   return 0;
    return 1;
}

int main()
{
    int n;
    cin>>n;
    int grid[n][n];
    for(int i=0;i<n;i++)
         for(int j=0;j<n;j++)
                cin>>grid[i][j];

    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            {int count=0;
             if(isvalid(i+1,j,4))    if(grid[i+1][j]=='o')  count++;
             if(isvalid(i,j+1,4))    if(grid[i][j+1]=='o')  count++;
             if(isvalid(i-1,j,4))    if(grid[i-1][j]=='o')  count++;
             if(isvalid(i,j-1,4))    if(grid[i][j-1]=='o')  count++;
             if(count%2==1) {cout<<"NO"<<'\n';return 0;}
            }

    cout<<"YES"<<'\n';;

    return 0;
}


#include <iostream>

using namespace std;

bool isvalid(int x,int y,int n)
{
    if(x<0||x>=n)   return FALSE;
    if(y<0||y>=n)   return FALSE;
    return TRUE;

int main()
{
    int n;
    cin>>n;
    int grid[n][n];
    for(int i=0;i<n;i++)
         for(int j=0;j<n;j++)
                cin>>grid[i][j];

    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            {int count=0;
             if(isvalid(i+1,j,4))    if(grid[i+1][j]=='o')  count++;
             if(isvalid(i,j+1,4))    if(grid[i][j+1]=='o')  count++;
             if(isvalid(i-1,j,4))    if(grid[i-1][j]=='o')  count++;
             if(isvalid(i,j-1,4))    if(grid[i][j-1]=='o')  count++;
             if(count%2==1) {cout<<"NO"<<'\n';return 0;}
            }

    cout<<"YES"<<'\n';

    return 0;
}


#include <iostream>

using namespace std;

bool isvalid(int x,int y,int n)
{
    if(x<0||x>=n)   return 0;
    if(y<0||y>=n)   return 0;
    return 1;
}

int main()
{
    int n;
    cin>>n;
    char grid[n][n];
    for(int i=0;i<n;i++)
         for(int j=0;j<n;j++)
                cin>>grid[i][j];

    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            {int count=0;
             if(isvalid(i+1,j,4))    if(grid[i+1][j]=='o')  count++;
             if(isvalid(i,j+1,4))    if(grid[i][j+1]=='o')  count++;
             if(isvalid(i-1,j,4))    if(grid[i-1][j]=='o')  count++;
             if(isvalid(i,j-1,4))    if(grid[i][j-1]=='o')  count++;
             if(count%2==1) {cout<<"NO"<<'\n';return 0;}
            }

    cout<<"YES"<<'\n';;

    return 0;
}


#include <iostream>

using namespace std;

bool isvalid(int x,int y,int n)
{
    if(x<0||x>=n)   return 0;
    if(y<0||y>=n)   return 0;
    return 1;

int main()
{
    int n;
    cin>>n;
    int grid[n][n];
    for(int i=0;i<n;i++)
         for(int j=0;j<n;j++)
                cin>>grid[i][j];

    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            {int count=0;
             if(isvalid(i+1,j,4))    if(grid[i+1][j]=='o')  count++;
             if(isvalid(i,j+1,4))    if(grid[i][j+1]=='o')  count++;
             if(isvalid(i-1,j,4))    if(grid[i-1][j]=='o')  count++;
             if(isvalid(i,j-1,4))    if(grid[i][j-1]=='o')  count++;
             if(count%2==1) {cout<<"NO"<<'\n';return 0;}
            }

    cout<<"YES"<<'\n';

    return 0;
}


#include <iostream>

using namespace std;

bool isvalid(int x,int y,int n)
{
    if(x<0||x>=n)   return 0;
    if(y<0||y>=n)   return 0;
    return 1;
}

int main()
{
    int n;
    cin>>n;
    char grid[n][n];
    for(int i=0;i<n;i++)
         for(int j=0;j<n;j++)
                cin>>grid[i][j];

    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            {int count=0;
             if(isvalid(i+1,j,4))    if(grid[i+1][j]=='o')  count++;
             if(isvalid(i,j+1,4))    if(grid[i][j+1]=='o')  count++;
             if(isvalid(i-1,j,4))    if(grid[i-1][j]=='o')  count++;
             if(isvalid(i,j-1,4))    if(grid[i][j-1]=='o')  count++;
             if(count%2==1) {cout<<"NO"<<'\n';return 0;}
            }

    cout<<"YES"<<'\n';

    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int n , counter=0;

    cin>>n;

    char arr[n][n];

    bool check = true;

    for(int i=0  ; i<n  ;  i++)
    {
        for(int j=0  ; j<n  ;  j++)
        {
            cin>>arr[i][j];
        }
    }
    for(int i=0  ; i<n  ;  i++)
    {
        for(int j=0  ; j<n  ;  j++)
        {
            if(arr[i][j+1]=='o')
            {
                counter++;
            }
            if(arr[i][j-1]=='o')
            {
                counter++;
            }
            if(arr[i-1][j]=='o')
            {
                counter++;
            }
            if(arr[i+1][j]=='o')
            {
                counter++;
            }
        }
        if(counter%2!=0)
        {
           check= false;
        }
        counter=0;
    }
    if(check)
    {
        cout<<"YES";
    }
    else
        cout<<"NO";
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int n , counter=0;

    cin>>n;

    char arr[105][105];

    bool check = true;

    for(int i=0  ; i<n  ;  i++)
    {
        for(int j=0  ; j<n  ;  j++)
        {
            cin>>arr[i][j];
        }
    }
    for(int i=0  ; i<n  ;  i++)
    {
        for(int j=0  ; j<n  ;  j++)
        {
            if(i==0 && j==0)
            {
                if(arr[i][j+1]=='o')
                    {
                       counter++;
                    }
                if(arr[i+1][j]=='o')
                  {
                      counter++;
                  }

            }
            else if(i==0 && j==n-1)
            {
                if(arr[i][j-1]=='o')
            {
                counter++;
            }
             if(arr[i+1][j]=='o')
            {
                counter++;
            }
            }
            else if(i==n-1 &&j==0)
            {
                 if(arr[i][j+1]=='o')
            {
                counter++;
            }
            if(arr[i-1][j]=='o')
            {
                counter++;
            }

            }
            else if(i==n-1 && j==n-1)
            {
                if(arr[i-1][j]=='o')
            {
                counter++;
            }
            if(arr[i][j-1]=='o')
            {
                counter++;
            }
            }
            else
            {
                if(arr[i][j+1]=='o')
            {
                counter++;
            }
            if(arr[i][j-1]=='o')
            {
                counter++;
            }
            if(arr[i-1][j]=='o')
            {
                counter++;
            }
            if(arr[i+1][j]=='o')
            {
                counter++;
            }
            }
        if(counter%2!=0)
        {
         check= false;
         break;
        }
        counter=0;
        }
        if(!check) break;

    }
    if(check)
    {

        cout<<"YES";
    }
    else
        cout<<"NO";
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int n , counter=0;

    cin>>n;

    char arr[105][105];

    bool check = true;

    for(int i=0  ; i<n  ;  i++)
    {
        for(int j=0  ; j<n  ;  j++)
        {
            cin>>arr[i][j];
        }
    }
    for(int i=0  ; i<n  ;  i++)
    {
        for(int j=0  ; j<n  ;  j++)
        {
            if(i==0 && j==0)
            {
                if(arr[i][j+1]=='o')
                    {
                       counter++;
                    }
                if(arr[i+1][j]=='o')
            {
                counter++;
            }

            }
            else if(i==0 && j==n-1)
            {
                if(arr[i][j-1]=='o')
            {
                counter++;
            }
             if(arr[i+1][j]=='o')
            {
                counter++;
            }
            }
            else if(i==n-1 &&j==0)
            {
                 if(arr[i][j+1]=='o')
            {
                counter++;
            }
            if(arr[i-1][j]=='o')
            {
                counter++;
            }

            }
            else if(i==n-1 && j==n-1)
            {
                if(arr[i-1][j]=='o')
            {
                counter++;
            }
            if(arr[i][j-1]=='o')
            {
                counter++;
            }
            }
            else
            {
                if(arr[i][j+1]=='o')
            {
                counter++;
            }
            if(arr[i][j-1]=='o')
            {
                counter++;
            }
            if(arr[i-1][j]=='o')
            {
                counter++;
            }
            if(arr[i+1][j]=='o')
            {
                counter++;
            }
            }
        }
        if(counter%2!=0)
        {
           check= false;
        }
        counter=0;
    }
    if(check)
    {
        cout<<"YES";
    }
    else
        cout<<"NO";
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int n , counter=0;

    cin>>n;

    char arr[105][105];

    bool check = true;

    for(int i=0  ; i<n  ;  i++)
    {
        for(int j=0  ; j<n  ;  j++)
        {
            cin>>arr[i][j];
        }
    }
    for(int i=0 ; i<n  ;  i++)
    {
        for(int j=0 ; j<n ; j++)
        {
            if( i==0 && j==0 )
            {
                if(arr[i][j+1]=='o') counter++;

                if(arr[i+1][j]=='o') counter++;
            }
            else if(i==0 && j==n-1)
            {
                if(arr[i][j-1]=='o') counter++;
                if(arr[i+1][j]=='o') counter++;
            }
            else if( i==n-1 && j==0)
            {
                if(arr[i-1][j]=='o') counter++;
                if(arr[i][j+1]=='o') counter++;
            }
            else if(i==n-1 && j==n-1)
            {
                if(arr[i][j-1]=='o') counter++;
                if(arr[i-1][j]=='o') counter++;
            }
            else if(i==0)
            {
                if(arr[i][j+1]=='o') counter++;
                if(arr[i][j-1]=='o') counter++;
                if(arr[i+1][j]=='o') counter++;
            }
            else if(i==n-1)
            {
                if(arr[i][j+1]=='o') counter++;
                if(arr[i][j-1]=='o') counter++;
                if(arr[i-1][j]=='o') counter++;
            }
            else if(j==0)
            {
                if(arr[i][j+1]=='o') counter++;
                if(arr[i-1][j]=='o') counter++;
                if(arr[i+1][j]=='o') counter++;
            }
            else if(j==n-1)
            {
                if(arr[i][j-1]=='o') counter++;
                if(arr[i-1][j]=='o') counter++;
                if(arr[i+1][j]=='o') counter++;
            }
            else
            {
                if(arr[i][j+1]=='o') counter++;
                if(arr[i][j-1]=='o') counter++;
                if(arr[i-1][j]=='o') counter++;
                if(arr[i+1][j]=='o') counter++;
            }
            if(counter%2!=0)
            {
                check =false;
                break;
            }
            counter=0;
        }
        if(check==false) break;
    }
    if(check)
    {
        cout<<"YES";
    }
    else cout<<"NO";

    return 0;
}


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

int main()
{
    int n , counter=0;

    cin>>n;

    string s;

    bool check = true ;

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

        for(int j=0 ; j<n ; j++)
        {
            if(s[j]=='x')
            {
                counter++;
            }
        }
        if(counter%2==0 &&counter!=n)
        {
           continue;
        }
        else
        check=false;

       counter=0;
    }
    if(check==true)
    {
        cout<<"YES";
    }
    else
        cout<<"NO";
    return 0;
}


#include <iostream>
using namespace std;
int main()
{
    int n , counter=0;

    cin>>n;

    char arr[n][n];

    bool check = true;

    for(int i=0  ; i<n  ;  i++)
    {
        for(int j=0  ; j<n  ;  j++)
        {
            cin>>arr[i][j];
        }
    }
    for(int i=0  ; i<n  ;  i++)
    {
        for(int j=0  ; j<n  ;  j++)
        {
            if(i==0 && j==0)
            {
                if(arr[i][j+1]=='o')
                    {
                       counter++;
                    }
                if(arr[i+1][j]=='o')
            {
                counter++;
            }

            }
            else if(i==0 && j==n-1)
            {
                if(arr[i][j-1]=='o')
            {
                counter++;
            }
             if(arr[i+1][j]=='o')
            {
                counter++;
            }
            }
            else if(i==n-1 &&j==0)
            {
                 if(arr[i][j+1]=='o')
            {
                counter++;
            }
            if(arr[i-1][j]=='o')
            {
                counter++;
            }

            }
            else if(i==n-1 && j==n-1)
            {
                if(arr[i-1][j]=='o')
            {
                counter++;
            }
            if(arr[i][j-1]=='o')
            {
                counter++;
            }
            }
            else
            {
                if(arr[i][j+1]=='o')
            {
                counter++;
            }
            if(arr[i][j-1]=='o')
            {
                counter++;
            }
            if(arr[i-1][j]=='o')
            {
                counter++;
            }
            if(arr[i+1][j]=='o')
            {
                counter++;
            }
            }
        }
        if(counter%2!=0)
        {
           check= false;
        }
        counter=0;
    }
    if(check)
    {
        cout<<"YES";
    }
    else
        cout<<"NO";
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    char board[100][100];
    int i,j,n,done=0;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> board[i] ;
    }
    for(i=0;i<n;i++)
    {
        int cnt=0;
        for(j=0;j<n;j++)
        {

            if (i - 1 >= 0 and board[i - 1][j] == 'o')
                cnt++;
            if (i + 1 < n and board[i + 1][j] == 'o')
                cnt++;
            if(j - 1 >= 0 and board[i][j - 1] == 'o')
                cnt++;
            if(j + 1 < n and board[i][j + 1] == 'o')
                cnt++;
            if (cnt % 2 == 1)
                done=1;

        }

    }
    if(done==0)
        {
            cout << "NO";
        }

        else if(i==n && done==1)
        {
            cout << "YES";
        }

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    char board[100][100];
    int i,j,n,done=0;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> board[i] ;
    }
    for(i=0;i<n;i++)
    {
        int cnt=0;
        for(j=0;j<n;j++)
        {

            if (i - 1 >= 0 and board[i - 1][j] == 'o')
                cnt++;
            if (i + 1 < n and board[i + 1][j] == 'o')
                cnt++;
            if(j - 1 >= 0 and board[i][j - 1] == 'o')
                cnt++;
            if(j + 1 < n and board[i][j + 1] == 'o')
                cnt++;
            if (cnt % 2 == 1)
                done=1;

        }

    }
    if(done==0)
        {
            cout << "NO";
            break;
        }
        else if(i==n && done==1)
        {
            cout << "YES";
        }

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    char board[100][100];
    int i,j,n,done=0;
    cin >> n;
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            cin >> board[i][j];
        }

    }
    for(i=0;i<n;i++)
    {
        int cnt=0;
        for(j=0;j<n;j++)
        {

            if (i - 1 >= 0 and board[i - 1][j] == 'o')
                cnt++;
            if (i + 1 < n and board[i + 1][j] == 'o')
                cnt++;
            if(j - 1 >= 0 and board[i][j - 1] == 'o')
                cnt++;
            if(j + 1 < n and board[i][j + 1] == 'o')
                cnt++;
            if (cnt % 2 == 1)
                done=1;

        }

    }
    if(done==1)
        {
            cout << "NO";
        }

        else if(i==n && done==0)
        {
            cout << "YES";
        }

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    char board[100][100];
    int i,j,n,cnt=0,out;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> board[i] ;
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            if(board[i][j]=='o')
            {
                cnt++;
            }
        }
    }
    out=(n*n)-cnt;
    if((out%2)==0)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    char board[100][100];
    int i,j,n,done=0;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> board[i] ;
    }
    for(i=0;i<n;i++)
    {
        int cnt=0;
        for(j=0;j<n;j++)
        {

            if (i - 1 >= 0 and board[i - 1][j] == 'o')
                cnt++;
            if (i + 1 < n and board[i + 1][j] == 'o')
                cnt++;
            if(j - 1 >= 0 and board[i][j - 1] == 'o')
                cnt++;
            if(j + 1 < n and board[i][j + 1] == 'o')
                cnt++;
            if (cnt % 2 == 1)
                done=1;

        }

    }
    if(done==0)
        {
            cout << "NO";

        else if(i==n && done==1)
        {
            cout << "YES";
        }

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    char board[100][100];
    int i,j,n,done=0;
    cin >> n;
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            cin >> board[i][j];
        }

    }
    for(i=0;i<n;i++)
    {
        int cnt=0;
        for(j=0;j<n;j++)
        {

            if (i - 1 >= 0 and board[i - 1][j] == 'o')
                cnt++;
            if (i + 1 < n and board[i + 1][j] == 'o')
                cnt++;
            if(j - 1 >= 0 and board[i][j - 1] == 'o')
                cnt++;
            if(j + 1 < n and board[i][j + 1] == 'o')
                cnt++;
            if (cnt % 2 == 1)
                done=1;

        }

    }
    if(done==0)
        {
            cout << "NO";
        }

        else if(i==n && done==1)
        {
            cout << "YES";
        }

    return 0;
}


#include <functional>
#include<algorithm>
#include <utility>
#include <numeric>
#include<iostream>
#include<valarray>
#include<stdio.h>
#include<iomanip>
#include<complex>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>
#define TRvi(c, it)  for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmii(c, it) for (mii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRsi(c, it) for (si::iterator it = (c).begin(); it != (c).end(); it++)
#define REP(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(V) (V).begin(), (V).end()
#define lli long long int
#define msi map<string, int>
#define mii map<int,int>
#define vstr vector<string>
#define lli long long int
#define ii pair<int, int>
#define si pair<string, int>
#define sf pair<string, float>
#define qi priority_queue<ii >
#define sstr set<string>
#define vii vector<ii>
#define vsi vector<si>
#define vs vector<string>
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<lli>
#define vc vector<char>
#define vb vector<bool>
#define sc set<char>
#define sti set<int>
#define sz(V) ((int)(V).size())
#define vsort(V) sort(all(V))
#define re(V) reverse(all(V))
#define pb push_back
#define fs first
#define se second
#define MEMSET_HALF_INF 63 // about 1B
#define INF 2000000000 // 2 billion
#define MEMSET_INF 127 // about 2B
#define fast ios_base::sync_with_stdio(false);   cin.tie(NULL);
#define ln cout<<"\n"

const double PI = 3.14159265358979323846264338327950288419716939937510582097494459230;
const lli MOD = 1000000007;
using namespace std;

lli prime(lli n) {
	if (n % 2 == 0 && n != 2 || n<2)return false;
	else { for (lli i = 3; i*i <= n; i += 2) { if (n%i == 0) { return false; } } }
	return true;
}
lli gcd(lli n, lli  m) {//g
	if (n%m == 0)return m;
	else return gcd(m, n%m);
}
lli lcm(lli n, lli m) {
	return n*m / gcd(n, m);
}
lli fact(lli n) {
	if (n == 1)return 1;
	else return n * fact(n - 1);
}
int sumdigit(int n) {
	int sum = 0;
	while (n) { sum += (n % 10); n /= 10; }
	return sum;
}
string tobinary(lli n)
{
	string s;
	while (n) { s += (n % 2) + '0'; n /= 2; }
	re(s);
	return s;
}
string tostring(double n) {
	double m = n;
	string x;
	stringstream ss;
	ss << m;
	ss >> x;
	return x;
}
char tochar(int n) {
	int m = n;
	char x;
	stringstream ss;
	ss << m;
	ss >> x;
	return x;
}
int primeFactors(int n)
{
    int c=0;
    while (n%2 == 0)
    {
        c++;
        n = n/2;
    }
    for (int i = 3; i <= sqrt(n); i = i+2)
    {
        while (n%i == 0)
        {
            c++;
            n = n/i;
        }
    }
    if (n > 2)
        c++;
    return c;
}
int main()
{
	fast
	int n;
	cin>>n;
	char c[105][105];
	for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>c[i][j];
        }
	}
	bool f=true;
	for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(c[i][j]=='o'){
               if(c[i][j-1]=='x'&&c[i][j+1]=='x'||c[i-1][j]=='x'&&c[i+1][j]=='x'||
                  c[i][j-1]=='x'&&c[i+1][j]=='x'||c[i][j-1]=='x'&&c[i-1][j]=='x'||
                  c[i-1][j]=='x'&&c[i][j+1]=='x'||c[i+1][j]=='x'&&c[i][j+1]=='x'){
                    continue;
                 }
                 else {
                    f=false;
                    //cout<<i<<" "<<j;ln;
                    break;
                 }
        }
	  }
	}
	if(f&&n!=1)cout<<"YES";
	else if(n==1&&c[0][0]=='o')cout<<"YES";
	else cout<<"NO";
   	return 0;
}


#include <functional>
#include<algorithm>
#include <utility>
#include <numeric>
#include<iostream>
#include<valarray>
#include<stdio.h>
#include<iomanip>
#include<complex>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>
#define TRvi(c, it)  for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmii(c, it) for (mii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRsi(c, it) for (si::iterator it = (c).begin(); it != (c).end(); it++)
#define REP(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(V) (V).begin(), (V).end()
#define lli long long int
#define msi map<string, int>
#define mii map<int,int>
#define vstr vector<string>
#define lli long long int
#define ii pair<int, int>
#define si pair<string, int>
#define sf pair<string, float>
#define qi priority_queue<ii >
#define sstr set<string>
#define vii vector<ii>
#define vsi vector<si>
#define vs vector<string>
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<lli>
#define vc vector<char>
#define vb vector<bool>
#define sc set<char>
#define sti set<int>
#define sz(V) ((int)(V).size())
#define vsort(V) sort(all(V))
#define re(V) reverse(all(V))
#define pb push_back
#define fs first
#define se second
#define MEMSET_HALF_INF 63 // about 1B
#define INF 2000000000 // 2 billion
#define MEMSET_INF 127 // about 2B
#define fast ios_base::sync_with_stdio(false);   cin.tie(NULL);
#define ln cout<<"\n"

const double PI = 3.14159265358979323846264338327950288419716939937510582097494459230;
const lli MOD = 1000000007;
using namespace std;

lli prime(lli n) {
	if (n % 2 == 0 && n != 2 || n<2)return false;
	else { for (lli i = 3; i*i <= n; i += 2) { if (n%i == 0) { return false; } } }
	return true;
}
lli gcd(lli n, lli  m) {//g
	if (n%m == 0)return m;
	else return gcd(m, n%m);
}
lli lcm(lli n, lli m) {
	return n*m / gcd(n, m);
}
lli fact(lli n) {
	if (n == 1)return 1;
	else return n * fact(n - 1);
}
int sumdigit(int n) {
	int sum = 0;
	while (n) { sum += (n % 10); n /= 10; }
	return sum;
}
string tobinary(lli n)
{
	string s;
	while (n) { s += (n % 2) + '0'; n /= 2; }
	re(s);
	return s;
}
string tostring(double n) {
	double m = n;
	string x;
	stringstream ss;
	ss << m;
	ss >> x;
	return x;
}
char tochar(int n) {
	int m = n;
	char x;
	stringstream ss;
	ss << m;
	ss >> x;
	return x;
}
int primeFactors(int n)
{
    int c=0;
    while (n%2 == 0)
    {
        c++;
        n = n/2;
    }
    for (int i = 3; i <= sqrt(n); i = i+2)
    {
        while (n%i == 0)
        {
            c++;
            n = n/i;
        }
    }
    if (n > 2)
        c++;
    return c;
}
int main()
{
	fast
	int n;
	cin>>n;
	char c[105][105];
	for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>c[i][j];
        }
	}
	bool f=true;
	for(int i=1;i<=n;i++){
            int x=0;
        for(int j=1;j<=n;j++){
               if(c[i][j-1]=='o')x++;
               if(c[i][j+1]=='o')x++;
               if(c[i-1][j]=='o')x++;
               if(c[i+1][j]=='o')x++;
               if(x%2!=0){f=false;break;}
               x=0;
        }
	}
	if(f)cout<<"YES";
	else cout<<"NO";
   	return 0;
}


#include <functional>
#include<algorithm>
#include <utility>
#include <numeric>
#include<iostream>
#include<valarray>
#include<stdio.h>
#include<iomanip>
#include<complex>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>
#define TRvi(c, it)  for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmii(c, it) for (mii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRsi(c, it) for (si::iterator it = (c).begin(); it != (c).end(); it++)
#define REP(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(V) (V).begin(), (V).end()
#define lli long long int
#define msi map<string, int>
#define mii map<int,int>
#define vstr vector<string>
#define lli long long int
#define ii pair<int, int>
#define si pair<string, int>
#define sf pair<string, float>
#define qi priority_queue<ii >
#define sstr set<string>
#define vii vector<ii>
#define vsi vector<si>
#define vs vector<string>
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<lli>
#define vc vector<char>
#define vb vector<bool>
#define sc set<char>
#define sti set<int>
#define sz(V) ((int)(V).size())
#define vsort(V) sort(all(V))
#define re(V) reverse(all(V))
#define pb push_back
#define fs first
#define se second
#define MEMSET_HALF_INF 63 // about 1B
#define INF 2000000000 // 2 billion
#define MEMSET_INF 127 // about 2B
#define fast ios_base::sync_with_stdio(false);   cin.tie(NULL);
#define ln cout<<"\n"

const double PI = 3.14159265358979323846264338327950288419716939937510582097494459230;
const lli MOD = 1000000007;
using namespace std;

lli prime(lli n) {
	if (n % 2 == 0 && n != 2 || n<2)return false;
	else { for (lli i = 3; i*i <= n; i += 2) { if (n%i == 0) { return false; } } }
	return true;
}
lli gcd(lli n, lli  m) {//g
	if (n%m == 0)return m;
	else return gcd(m, n%m);
}
lli lcm(lli n, lli m) {
	return n*m / gcd(n, m);
}
lli fact(lli n) {
	if (n == 1)return 1;
	else return n * fact(n - 1);
}
int sumdigit(int n) {
	int sum = 0;
	while (n) { sum += (n % 10); n /= 10; }
	return sum;
}
string tobinary(lli n)
{
	string s;
	while (n) { s += (n % 2) + '0'; n /= 2; }
	re(s);
	return s;
}
string tostring(double n) {
	double m = n;
	string x;
	stringstream ss;
	ss << m;
	ss >> x;
	return x;
}
char tochar(int n) {
	int m = n;
	char x;
	stringstream ss;
	ss << m;
	ss >> x;
	return x;
}
int primeFactors(int n)
{
    int c=0;
    while (n%2 == 0)
    {
        c++;
        n = n/2;
    }
    for (int i = 3; i <= sqrt(n); i = i+2)
    {
        while (n%i == 0)
        {
            c++;
            n = n/i;
        }
    }
    if (n > 2)
        c++;
    return c;
}
int main()
{
	fast
	int n;
	cin>>n;
	char c[105][105];
	for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>c[i][j];
        }
	}
	bool f=true;
	for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(c[i][j]=='o'){
               if(c[i][j-1]=='x'&&c[i][j+1]=='x'||c[i-1][j]=='x'&&c[i+1][j]=='x'||
                  c[i][j-1]=='x'&&c[i+1][j]=='x'||c[i][j-1]=='x'&&c[i-1][j]=='x'||
                  c[i-1][j]=='x'&&c[i][j+1]=='x'||c[i+1][j]=='x'&&c[i][j+1]=='x'){
                    continue;
                 }
                 else {
                    f=false;
                    //cout<<i<<" "<<j;ln;
                    break;
                 }
        }
	  }
	}
	if(f)cout<<"YES";
	else cout<<"NO";
   	return 0;
}


#include <functional>
#include<algorithm>
#include <utility>
#include <numeric>
#include<iostream>
#include<valarray>
#include<stdio.h>
#include<iomanip>
#include<complex>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>
#define TRvi(c, it)  for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmii(c, it) for (mii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRsi(c, it) for (si::iterator it = (c).begin(); it != (c).end(); it++)
#define REP(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(V) (V).begin(), (V).end()
#define lli long long int
#define msi map<string, int>
#define mii map<int,int>
#define vstr vector<string>
#define lli long long int
#define ii pair<int, int>
#define si pair<string, int>
#define sf pair<string, float>
#define qi priority_queue<ii >
#define sstr set<string>
#define vii vector<ii>
#define vsi vector<si>
#define vs vector<string>
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<lli>
#define vc vector<char>
#define vb vector<bool>
#define sc set<char>
#define sti set<int>
#define sz(V) ((int)(V).size())
#define vsort(V) sort(all(V))
#define re(V) reverse(all(V))
#define pb push_back
#define fs first
#define se second
#define MEMSET_HALF_INF 63 // about 1B
#define INF 2000000000 // 2 billion
#define MEMSET_INF 127 // about 2B
#define fast ios_base::sync_with_stdio(false);   cin.tie(NULL);
#define ln cout<<"\n"

const double PI = 3.14159265358979323846264338327950288419716939937510582097494459230;
const lli MOD = 1000000007;
using namespace std;

lli prime(lli n) {
	if (n % 2 == 0 && n != 2 || n<2)return false;
	else { for (lli i = 3; i*i <= n; i += 2) { if (n%i == 0) { return false; } } }
	return true;
}
lli gcd(lli n, lli  m) {//g
	if (n%m == 0)return m;
	else return gcd(m, n%m);
}
lli lcm(lli n, lli m) {
	return n*m / gcd(n, m);
}
lli fact(lli n) {
	if (n == 1)return 1;
	else return n * fact(n - 1);
}
int sumdigit(int n) {
	int sum = 0;
	while (n) { sum += (n % 10); n /= 10; }
	return sum;
}
string tobinary(lli n)
{
	string s;
	while (n) { s += (n % 2) + '0'; n /= 2; }
	re(s);
	return s;
}
string tostring(double n) {
	double m = n;
	string x;
	stringstream ss;
	ss << m;
	ss >> x;
	return x;
}
char tochar(int n) {
	int m = n;
	char x;
	stringstream ss;
	ss << m;
	ss >> x;
	return x;
}
int primeFactors(int n)
{
    int c=0;
    while (n%2 == 0)
    {
        c++;
        n = n/2;
    }
    for (int i = 3; i <= sqrt(n); i = i+2)
    {
        while (n%i == 0)
        {
            c++;
            n = n/i;
        }
    }
    if (n > 2)
        c++;
    return c;
}
int main()
{
   fast
   int n,c=0;bool f=true;
   cin>>n;
   string s;
   for (int i = 0; i < n; i++)
   {
       cin>>s;
       for (int j = 0; j < n; j++)
       {
           if(s[j]=='o')c++;
       }
       if((n-c)%2!=0)f=false;
       c=0;
   }
   if(f)cout<<"YES\n";
   else cout<<"NO\n";
 return 0;
}


#include <functional>
#include<algorithm>
#include <utility>
#include <numeric>
#include<iostream>
#include<valarray>
#include<stdio.h>
#include<iomanip>
#include<complex>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>
#define TRvi(c, it)  for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmii(c, it) for (mii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRsi(c, it) for (si::iterator it = (c).begin(); it != (c).end(); it++)
#define REP(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(V) (V).begin(), (V).end()
#define lli long long int
#define msi map<string, int>
#define mii map<int,int>
#define vstr vector<string>
#define lli long long int
#define ii pair<int, int>
#define si pair<string, int>
#define sf pair<string, float>
#define qi priority_queue<ii >
#define sstr set<string>
#define vii vector<ii>
#define vsi vector<si>
#define vs vector<string>
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<lli>
#define vc vector<char>
#define vb vector<bool>
#define sc set<char>
#define sti set<int>
#define sz(V) ((int)(V).size())
#define vsort(V) sort(all(V))
#define re(V) reverse(all(V))
#define pb push_back
#define fs first
#define se second
#define MEMSET_HALF_INF 63 // about 1B
#define INF 2000000000 // 2 billion
#define MEMSET_INF 127 // about 2B
#define fast ios_base::sync_with_stdio(false);   cin.tie(NULL);
#define ln cout<<"\n"

const double PI = 3.14159265358979323846264338327950288419716939937510582097494459230;
const lli MOD = 1000000007;
using namespace std;

lli prime(lli n) {
	if (n % 2 == 0 && n != 2 || n<2)return false;
	else { for (lli i = 3; i*i <= n; i += 2) { if (n%i == 0) { return false; } } }
	return true;
}
lli gcd(lli n, lli  m) {//g
	if (n%m == 0)return m;
	else return gcd(m, n%m);
}
lli lcm(lli n, lli m) {
	return n*m / gcd(n, m);
}
lli fact(lli n) {
	if (n == 1)return 1;
	else return n * fact(n - 1);
}
int sumdigit(int n) {
	int sum = 0;
	while (n) { sum += (n % 10); n /= 10; }
	return sum;
}
string tobinary(lli n)
{
	string s;
	while (n) { s += (n % 2) + '0'; n /= 2; }
	re(s);
	return s;
}
string tostring(double n) {
	double m = n;
	string x;
	stringstream ss;
	ss << m;
	ss >> x;
	return x;
}
char tochar(int n) {
	int m = n;
	char x;
	stringstream ss;
	ss << m;
	ss >> x;
	return x;
}
int primeFactors(int n)
{
    int c=0;
    while (n%2 == 0)
    {
        c++;
        n = n/2;
    }
    for (int i = 3; i <= sqrt(n); i = i+2)
    {
        while (n%i == 0)
        {
            c++;
            n = n/i;
        }
    }
    if (n > 2)
        c++;
    return c;
}
int main()
{
	fast
	int n;
	cin>>n;
	char c[105][105];
	for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>c[i][j];
        }
	}
	bool f=true;
	for(int i=0;i<n;i++){
            int x=0;
        for(int j=0;j<n;j++){
            if(c[i][j]=='x'){
               if(c[i][j-1]=='o')x++;
               if(c[i][j+1]=='o')x++;
               if(c[i-1][j]=='o')x++;
               if(c[i+1][j]=='o')x++;
               if(x%2!=0){f=false;break;}
               x=0;
        }
	  }
	}
	if(f)cout<<"YES";
	else cout<<"NO";
   	return 0;
}


#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<iomanip>
#include<cmath>
#include <utility>
#include <numeric>
#include<complex>
#include<sstream>
#include <functional>
#include<valarray>
#define ln cout<<endl;
#define vll vector<long long int>
#define vi vector<int>
#define vc vector<char>
#define vstr vector<string>
#define vb vector<bool>
#define sti set<int>
#define sz size()
#define lli long long int
using namespace std;
int prime(int n){
    if(n%2==0&&n!=2&&n<2)
        return false;
    else{
        for(int i=3;i*i<=n;i++)
        {
            if(n%i==0)
            {
                return false;
            }
        }}
   return true;
}
lli gcd(lli n,lli m){
    if(n%m==0)
        return m;
    else return gcd(m,n%m);
}
lli fact(lli n){
    if (n == 1)return 1;
    else return n * fact(n - 1);
}
int sumdigit(int n){
	int sum=0;
	while (n)
	{
		sum+=(n%10);
	    n/=10;
	}
	return sum;
}
int main()
{
   int n,c=0;bool f=true;
   cin>>n;
   string s;
   for (int i = 0; i < n; i++)
   {
	   cin>>s;
	   for (int j = 0; j < n; j++)
	   {
		   if(s[j]=='o')c++;
	   }
	   if(c!=(n-c)/2)f=false;
	   c=0;
   }
   if(f)cout<<"YES\n";
   else cout<<"NO\n";
    return 0;
}


#include <functional>
#include<algorithm>
#include <utility>
#include <numeric>
#include<iostream>
#include<valarray>
#include<stdio.h>
#include<iomanip>
#include<complex>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>
#define TRvi(c, it)  for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmii(c, it) for (mii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRsi(c, it) for (si::iterator it = (c).begin(); it != (c).end(); it++)
#define REP(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(V) (V).begin(), (V).end()
#define lli long long int
#define msi map<string, int>
#define mii map<int,int>
#define vstr vector<string>
#define lli long long int
#define ii pair<int, int>
#define si pair<string, int>
#define sf pair<string, float>
#define qi priority_queue<ii >
#define sstr set<string>
#define vii vector<ii>
#define vsi vector<si>
#define vs vector<string>
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<lli>
#define vc vector<char>
#define vb vector<bool>
#define sc set<char>
#define sti set<int>
#define sz(V) ((int)(V).size())
#define vsort(V) sort(all(V))
#define re(V) reverse(all(V))
#define pb push_back
#define fs first
#define se second
#define MEMSET_HALF_INF 63 // about 1B
#define INF 2000000000 // 2 billion
#define MEMSET_INF 127 // about 2B
#define fast ios_base::sync_with_stdio(false);   cin.tie(NULL);
#define ln cout<<"\n"

const double PI = 3.14159265358979323846264338327950288419716939937510582097494459230;
const lli MOD = 1000000007;
using namespace std;

lli prime(lli n) {
	if (n % 2 == 0 && n != 2 || n<2)return false;
	else { for (lli i = 3; i*i <= n; i += 2) { if (n%i == 0) { return false; } } }
	return true;
}
lli gcd(lli n, lli  m) {//g
	if (n%m == 0)return m;
	else return gcd(m, n%m);
}
lli lcm(lli n, lli m) {
	return n*m / gcd(n, m);
}
lli fact(lli n) {
	if (n == 1)return 1;
	else return n * fact(n - 1);
}
int sumdigit(int n) {
	int sum = 0;
	while (n) { sum += (n % 10); n /= 10; }
	return sum;
}
string tobinary(lli n)
{
	string s;
	while (n) { s += (n % 2) + '0'; n /= 2; }
	re(s);
	return s;
}
string tostring(double n) {
	double m = n;
	string x;
	stringstream ss;
	ss << m;
	ss >> x;
	return x;
}
char tochar(int n) {
	int m = n;
	char x;
	stringstream ss;
	ss << m;
	ss >> x;
	return x;
}
int primeFactors(int n)
{
    int c=0;
    while (n%2 == 0)
    {
        c++;
        n = n/2;
    }
    for (int i = 3; i <= sqrt(n); i = i+2)
    {
        while (n%i == 0)
        {
            c++;
            n = n/i;
        }
    }
    if (n > 2)
        c++;
    return c;
}
int main()
{
	fast
	int n;
	cin>>n;
	char c[105][105];
	for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>c[i][j];
        }
	}
	bool f=true;
	for(int i=0;i<n&&f;i++){
            int x=0;
        for(int j=0;j<n;j++){
               if(c[i][j-1]=='o')x++;
               if(c[i][j+1]=='o')x++;
               if(c[i-1][j]=='o')x++;
               if(c[i+1][j]=='o')x++;
               if(x%2!=0){f=false;break;}
               x=0;
        }
	}
	if(f)cout<<"YES";
	else cout<<"NO";
   	return 0;
}


#include <functional>
#include<algorithm>
#include <utility>
#include <numeric>
#include<iostream>
#include<valarray>
#include<stdio.h>
#include<iomanip>
#include<complex>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>
#define TRvi(c, it)  for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmii(c, it) for (mii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRsi(c, it) for (si::iterator it = (c).begin(); it != (c).end(); it++)
#define REP(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(V) (V).begin(), (V).end()
#define lli long long int
#define msi map<string, int>
#define mii map<int,int>
#define vstr vector<string>
#define lli long long int
#define ii pair<int, int>
#define si pair<string, int>
#define sf pair<string, float>
#define qi priority_queue<ii >
#define sstr set<string>
#define vii vector<ii>
#define vsi vector<si>
#define vs vector<string>
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<lli>
#define vc vector<char>
#define vb vector<bool>
#define sc set<char>
#define sti set<int>
#define sz(V) ((int)(V).size())
#define vsort(V) sort(all(V))
#define re(V) reverse(all(V))
#define pb push_back
#define fs first
#define se second
#define MEMSET_HALF_INF 63 // about 1B
#define INF 2000000000 // 2 billion
#define MEMSET_INF 127 // about 2B
#define fast ios_base::sync_with_stdio(false);   cin.tie(NULL);
#define ln cout<<"\n"

const double PI = 3.14159265358979323846264338327950288419716939937510582097494459230;
const lli MOD = 1000000007;
using namespace std;

lli prime(lli n) {
	if (n % 2 == 0 && n != 2 || n<2)return false;
	else { for (lli i = 3; i*i <= n; i += 2) { if (n%i == 0) { return false; } } }
	return true;
}
lli gcd(lli n, lli  m) {//g
	if (n%m == 0)return m;
	else return gcd(m, n%m);
}
lli lcm(lli n, lli m) {
	return n*m / gcd(n, m);
}
lli fact(lli n) {
	if (n == 1)return 1;
	else return n * fact(n - 1);
}
int sumdigit(int n) {
	int sum = 0;
	while (n) { sum += (n % 10); n /= 10; }
	return sum;
}
string tobinary(lli n)
{
	string s;
	while (n) { s += (n % 2) + '0'; n /= 2; }
	re(s);
	return s;
}
string tostring(double n) {
	double m = n;
	string x;
	stringstream ss;
	ss << m;
	ss >> x;
	return x;
}
char tochar(int n) {
	int m = n;
	char x;
	stringstream ss;
	ss << m;
	ss >> x;
	return x;
}
int primeFactors(int n)
{
    int c=0;
    while (n%2 == 0)
    {
        c++;
        n = n/2;
    }
    for (int i = 3; i <= sqrt(n); i = i+2)
    {
        while (n%i == 0)
        {
            c++;
            n = n/i;
        }
    }
    if (n > 2)
        c++;
    return c;
}
int main()
{
	fast
	int n;
	cin>>n;
	char c[105][105];
	for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>c[i][j];
        }
	}
	bool f=true;
	for(int i=0;i<n;i++){
            int x=0;
        for(int j=0;j<n;j++){
               if(c[i][j-1]=='o')x++;
               if(c[i][j+1]=='o')x++;
               if(c[i-1][j]=='o')x++;
               if(c[i+1][j]=='o')x++;
               if(x%2!=0){f=false;break;}
               x=0;
        }
	}
	if(f)cout<<"YES";
	else cout<<"NO";
   	return 0;
}


#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
char a[n][n];
for(int i=1;i<=n;++i)
for(int j=1;j<=n;++j)
{
    cin>>a[i][j];
}
for(int i=0;i<n;++i)
{
for(int j=0;j<n;++j)
{
    int count=0;
    if(a[i+1][j]=='o' && i<n-1)
    count++;
    if(a[i-1][j]=='o' && i>0)
    count++;
    if(a[i][j+1]=='o' && j<n-1)
    count++;
    if(a[i][j-1]=='o' && j>0)
    count++;
    if(count%2!=0)
    {
        cout<<”NO”;
return 0;
    }
}
}
cout<<"YES";
return 0;
}


#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int flag=0;
char a[n+2][n+2];

for(int i=1;i<=n;++i)
for(int j=1;j<=n;++j)
{
    cin>>a[i][j];
}
for(int j=0;j<=n+1;++j)
a[0][j]='o';
for(int j=0;j<=n+1;++j)
a[n+1][j]='o';
for(int i=0;i<=n+1;++i)
a[i][0]='o';
for(int i=0;i<=n+1;++i)
a[i][n+1]='o';
for(int i=1;i<=n;++i)
{
for(int j=1;j<=n;++j)
{
    int count=0;
    if(a[i+1][j]=='o')
    count++;
    if(a[i-1][j]=='o')
    count++;
    if(a[i][j+1]=='o')
    count++;
    if(a[i][j-1]=='o')
    count++;
    if(count%2!=0)
    {
        cout<<”NO”;
return 0;
    }
}
}
cout<<"YES";
return 0;
}


#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int flag=0;
char a[n+2][n+2];
/*
for(int j=0;j<=n+1;++j)
a[0][j]='o';
for(int j=0;j<=n+1;++j)
a[n+1][j]='o';
for(int i=0;i<=n+1;++i)
a[i][0]='o';
for(int i=0;i<=n+1;++i)
a[i][n+1]='o';
*/
for(int i=0;i<n;++i)
for(int j=0;j<n;++j)
{
    cin>>a[i][j];
}
for(int i=1;i<n-1;++i)
{
for(int j=1;j<n-1;++j)
{
    int count=0;
    if(a[i+1][j]=='o')
    count++;
    if(a[i-1][j]=='o')
    count++;
    if(a[i][j+1]=='o')
    count++;
    if(a[i][j-1]=='o')
    count++;
    if(count%2!=0)
    {
        flag=1;
        break;
    }
}

    if(flag==1)
    break;
}

if(flag==1)
cout<<"NO";
else
cout<<"YES";
return 0;
}


#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int flag=0;
char a[n+2][n+2];

/*
for(int j=0;j<=n+1;++j)
a[0][j]='o';
for(int j=0;j<=n+1;++j)
a[n+1][j]='o';
for(int i=0;i<=n+1;++i)
a[i][0]='o';
for(int i=0;i<=n+1;++i)
a[i][n+1]='o';
*/
int count=0;
for(int i=0;i<n;++i)
for(int j=0;j<n;++j)
{
    cin>>a[i][j];
    if(a[i][j]=='o')
    count++;
}
if(n==2)
if(count!=1)
{
cout<<"YES";
return 0;
}
else
{
cout<<"NO";

return 0;
}
for(int i=0;i<n;++i)
{
for(int j=0;j<n;++j)
{
    int count=0;
    if(a[i+1][j]=='o')
    count++;
    if(a[i-1][j]=='o')
    count++;
    if(a[i][j+1]=='o')
    count++;
    if(a[i][j-1]=='o')
    count++;
    if(count%2!=0)
    {
        cout<<"NO";
        return 0;
    }
}

}

cout<<"YES";
return 0;
}


#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
char a[n][n];
for(int i=1;i<=n;++i)
for(int j=1;j<=n;++j)
{
    cin>>a[i][j];
}
for(int i=0;i<n;++i)
{
for(int j=0;j<n;++j)
{
    int count=0;
    if(a[i+1][j]=='o' && i<n-1)
    count++;
    if(a[i-1][j]=='o' && i>0)
    count++;
    if(a[i][j+1]=='o' && j<n-1)
    count++;
    if(a[i][j-1]=='o' && j>0)
    count++;
    if(count%2!=0)
    {
        cout<<"NO";
return 0;
    }
}
}
cout<<"YES";
return 0;
}


#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int flag=0;
char a[n+2][n+2];
for(int j=0;j<=n+1;++j)
a[0][j]='o';
for(int j=0;j<=n+1;++j)
a[n+1][j]='o';
for(int i=0;i<=n+1;++i)
a[i][0]='o';
for(int i=0;i<=n+1;++i)
a[i][n+1]='o';
for(int i=1;i<=n;++i)
for(int j=1;j<=n;++j)
{
    cin>>a[i][j];
}
for(int i=1;i<=n;++i)
{
for(int j=1;j<=n;++j)
{
    int count=0;
    if(a[i+1][j]=='o')
    count++;
    if(a[i-1][j]=='o')
    count++;
    if(a[i][j+1]=='o')
    count++;
    if(a[i][j-1]=='o')
    count++;
    if(count%2!=0)
    {
        flag=1;
        break;
    }
}

    if(flag==1)
    break;
}

if(flag==0)
cout<<"NO";
else
cout<<"YES";
return 0;
}


#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int flag=0;
char a[n+2][n+2];

/*
for(int j=0;j<=n+1;++j)
a[0][j]='o';
for(int j=0;j<=n+1;++j)
a[n+1][j]='o';
for(int i=0;i<=n+1;++i)
a[i][0]='o';
for(int i=0;i<=n+1;++i)
a[i][n+1]='o';
*/
int count=0;
for(int i=0;i<n;++i)
for(int j=0;j<n;++j)
{
    cin>>a[i][j];
    if(a[i][j]=='o')
    count++;
}
if(n==2)
if(count!=1)
{
cout<<"YES";
return 0;
}
else
{
cout<<"NO";
return 0;
}
for(int i=0;i<n;++i)
{
for(int j=0;j<n;++j)
{
    int count=0;
    if(a[i+1][j]=='o')
    count++;
    if(a[i-1][j]=='o')
    count++;
    if(a[i][j+1]=='o')
    count++;
    if(a[i][j-1]=='o')
    count++;
    if(count%2!=0)
    {
        cout<<"NO";
        return 0;
    }
}

}

cout<<"YES";
return 0;
}


#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int flag=0;
char a[n+2][n+2];
for(int j=0;j<=n+1;++j)
a[0][j]='o';
for(int j=0;j<=n+1;++j)
a[n+1][j]='o';
for(int i=0;i<=n+1;++i)
a[i][0]='o';
for(int i=0;i<=n+1;++i)
a[i][n+1]='o';
for(int i=1;i<=n;++i)
for(int j=1;j<=n;++j)
{
    cin>>a[i][j];
}
for(int i=1;i<=n;++i)
{
for(int j=1;j<=n;++j)
{
    int count=0;
    if(a[i+1][j]=='o')
    count++;
    if(a[i-1][j]=='o')
    count++;
    if(a[i][j+1]=='o')
    count++;
    if(a[i][j-1]=='o')
    count++;
    if(count%2!=0)
    {
        flag=1;
        break;
    }
}

    if(flag==1)
    break;
}

if(flag==1)
cout<<"NO";
else
cout<<"YES";
return 0;
}


#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int flag=0;
char a[n+2][n+2];

/*
for(int j=0;j<=n+1;++j)
a[0][j]='o';
for(int j=0;j<=n+1;++j)
a[n+1][j]='o';
for(int i=0;i<=n+1;++i)
a[i][0]='o';
for(int i=0;i<=n+1;++i)
a[i][n+1]='o';
*/
int count=0;
for(int i=0;i<n;++i)
for(int j=0;j<n;++j)
{
    cin>>a[i][j];
    if(a[i][j]=='o')
    count++;
}
if(n==2)
if(count!=1)
cout<<"YES";
else
cout<<"NO";
for(int i=0;i<n;++i)
{
for(int j=0;j<n;++j)
{
    int count=0;
    if(a[i+1][j]=='o')
    count++;
    if(a[i-1][j]=='o')
    count++;
    if(a[i][j+1]=='o')
    count++;
    if(a[i][j-1]=='o')
    count++;
    if(count%2!=0)
    {
        cout<<"NO";
        return 0;
    }
}

}

cout<<"YES";
return 0;
}


#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int flag=0;
char a[n+2][n+2];
for(int j=0;j<=n+1;++j)
a[0][j]='o';
for(int j=0;j<=n+1;++j)
a[n+1][j]='o';
for(int i=0;i<=n+1;++i)
a[i][0]='o';
for(int i=0;i<=n+1;++i)
a[i][n+1]='o';
for(int i=1;i<=n;++i)
for(int j=1;j<=n;++j)
{
    cin>>a[i][j];
}
for(int i=1;i<=n;++i)
for(int j=1;j<=n;++j)
{
    int count=0;
    if(a[i+1][j]=='o')
    count++;
    if(a[i-1][j]=='o')
    count++;
    if(a[i][j+1]=='o')
    count++;
    if(a[i][j-1]=='o')
    count++;
    if(count%2!=0)
    {
        flag=1;
        break;
    }

    if(flag==1)
    break;
}

if(flag==1)
cout<<"NO";
else
cout<<"YES";
return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<int,int>
#define pb push_back
#define F first
#define S second
#define dbg(a,b) cout<<#a<<"="<<a<<endl<<#b<<"="<<b<<endl
#define dbgv(v) for(auto i:v)cout<<i<<" ";cout<<endl
#define mpq priority_queue<pll,vector<pll>,greater<pll> >
#define ub(s,x) upper_bound(s.begin(),s.end(),x)-s.begin()
#define lb(s,x) lower_bound(s.begin(),s.end(),make_pair(x,(ll)0))-s.begin()
void solve(){
	int n;
	cin>>n;
	char c[n+1][n+1];
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)
			cin>>c[i][j];
	}
	int f=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			int ct=0;
			if(j<n-1&&c[i][j+1]=='o')
				ct++;
			if(j>0&&c[i][j-1]=='o')
				ct++;
			if(i<n-1&&c[i+1][j]=='o')
				ct++;
			if(i>0&&c[i-1][j]=='o')
				ct++;
			if(ct%2==1){
				f=1;
				break;
			}
		}
		if(f)break;
	}
	if(f)cout<<"NO";
	else cout<<"YES";
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	// cin>>t;
	while(t--)
	solve();
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<int,int>
#define pb push_back
#define F first
#define S second
#define dbg(a,b) cout<<#a<<"="<<a<<endl<<#b<<"="<<b<<endl
#define dbgv(v) for(auto i:v)cout<<i<<" ";cout<<endl
#define mpq priority_queue<pll,vector<pll>,greater<pll> >
#define ub(s,x) upper_bound(s.begin(),s.end(),x)-s.begin()
#define lb(s,x) lower_bound(s.begin(),s.end(),make_pair(x,(ll)0))-s.begin()
void solve(){
	int n;
	cin>>n;
	char c[n+1][n+1];
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)
			cin>>c[i][j];
	}
	int f=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			ct=0;
			if(j<n-1&&c[i][j+1]=='o')
				ct++;
			if(j>0&&c[i][j-1]=='o')
				ct++;
			if(i<n-1&&c[i+1][j]=='o')
				ct++;
			if(i>0&&c[i-1][j]=='o')
				ct++;
			if(ct%2==1){
				f=1;
				break;
			}
		}
		if(f)break;
	}
	if(f)cout<<"NO";
	else cout<<"YES";
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	// cin>>t;
	while(t--)
	solve();
}


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

int main(){
	ll n;
	cin>>n;
	string s[n];
	for(ll i=0;i<n;i++)
		cin>>s[i];
	ll dx[]={1,-1,0,0};
	ll dy[]={0,0,-1,1};
	bool flag=true;
	for(ll i=0;i<n;i++){
		for(ll j=0;j<n;j++){
			ll count1=0;
			for(ll k=0;k<4;k++)
				if(i+dx[k]<n and i+dx[k]>=0 and j+dy[k]<n and j+dy[k]>=0)
					if(s[i+dx[k]][j+dy[k]]=='o')
						count1++;

					if(count1%2==1){
						cout<<"NO";
						return 0;
						}

					}
			}
	cout<<"YES";

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    char a[n][n];
    int flag=0;
    for(int i=0;i<n;i++)
    {
        int count=0;
        for(int j=0;j<n;j++)
        {
            cin>>a[i][j];
            if(a[i][j]=='x')
            {
                count++;
            }
        }
        if(count%2!=0)
        {
            flag=1;
        }
    }
    if(flag==1)
    {
        cout<<"NO"<<endl;
    }
    else
    {
        cout<<"YES"<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s,s1,s2;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        s1+=s;
    }
    s2=s1;
    reverse(s2.begin(),s2.end());
    if(s1==s2)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    char a[n][n];
    int flag=0,k=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>a[i][j];
        }
    }
    for(int i=0;i<n;i++)
    {
        int count=0,f=0;
        for(int j=0;j<n;j++){
         if(a[i][j]=='x')
            {
                count++;
            }
            else
            {
                f=1;
            }
        }
        if(count%2!=0 && count>1 || count==0)
        {
            flag=1;
        }
        if(f==0)
        {
            k=1;
        }
    }

        if(flag==1 || k==1)
        {
            cout<<"NO"<<endl;
        }
        else
        {
            cout<<"YES"<<endl;
        }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    char a[n][n];
    int flag=0;
    for(int i=0;i<n;i++)
    {
        int count=0;
        for(int j=0;j<n;j++)
        {
            cin>>a[i][j];
            if(a[i][j]=='x')
            {
                count++;
            }
        }
        if(count%2!=0)
        {
            flag=1;
        }
    }
    if(n==2 || n==1)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        if(flag==1)
        {
            cout<<"NO"<<endl;
        }
        else
        {
            cout<<"YES"<<endl;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    char a[n][n];
    int flag=0;
    for(int i=0;i<n;i++)
    {
        int count=0;
        for(int j=0;j<n;j++)
        {
            cin>>a[i][j];
            if(a[i][j]=='x')
            {
                count++;
            }
        }
        if(count%2!=0 && count>1)
        {
            flag=1;
        }
    }

        if(flag==1)
        {
            cout<<"NO"<<endl;
        }
        else
        {
            cout<<"YES"<<endl;
        }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    char a[n][n];
    int flag=0,k=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>a[i][j];
        }
    }
    for(int i=0;i<n;i++)
    {
        int count=0,f=0;
        for(int j=0;j<n;j++){
         if(a[i][j]=='x')
            {
                count++;
            }
            else
            {
                f=1;
            }
        }
        if(count%2!=0 && count>1)
        {
            flag=1;
        }
        if(f==0)
        {
            k=1;
        }
    }

        if(flag==1 || k==1)
        {
            cout<<"NO"<<endl;
        }
        else
        {
            cout<<"YES"<<endl;
        }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    char a[n][n];
    int flag=0,k=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>a[i][j];
        }
    }
    for(int i=0;i<n;i++)
    {
        int count=0,f=0;
        for(j=0;j<n;j++){
         if(a[i][j]=='x')
            {
                count++;
            }
            else
            {
                f=1;
            }
        }
        if(count%2!=0 && count>1)
        {
            flag=1;
        }
        if(f==0)
        {
            k=1;
        }
    }

        if(flag==1 || k==1)
        {
            cout<<"NO"<<endl;
        }
        else
        {
            cout<<"YES"<<endl;
        }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    char a[n][n];
    int flag=0;
    for(int i=0;i<n;i++)
    {
        int count=0;
        for(int j=0;j<n;j++)
        {
            cin>>a[i][j];
            if(a[i][j]=='x')
            {
                count++;
            }
        }
        if(count%2!=0)
        {
            flag=1;
        }
    }
    if(flag==1)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    char a[n][n];

    for(int i=0;i<n;i++)
    {
        int count=0;
        for(int j=0;j<n;j++)
        {
            cin>>a[i][j];
            if(a[i][j]=='x')
            {
                count++;
            }
        }
        if(count%2!=0)
        {
            flag=1;
        }
    }
    if(flag==1)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >>n;
	char ch[n+2][n+2];
	for (int i = 1; i <= n; ++i)
		for(int j=1;j<=n;j++)
			cin >> ch[i][j];
	int flag=0;
	for (int i = 1; i <= n; ++i)
	{
		int cnt,f=0;;
		for(int j=1;j<=n;j++)
		{	cnt=0;
			if(ch[i][j-1]=='o')cnt++;
			if(ch[i][j+1]=='o')cnt++;
			if(ch[i-1][j]=='o')cnt++;
			if(ch[i+1][j]=='o')cnt++;
			if(cnt%2!=0)
			{
				f=1;
				break;
			}

		}
		if(f==1)
		{
			flag=1;
			break;
		}
	}
	if(flag==1)
		cout << "NO";
	else
		cout << "YES";
	return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long LL;
int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    char mp[110][110];
    cin>>n;
    memset(mp,'*',sizeof(mp));
    for(int i=1;i<=n;++i)
        for(int j=1;j<=n;++j)
            cin>>mp[j][i];
    bool flag = true;
    for(int i=1;i<=n && flag;++i)
    {
        int cnt=0;
        for(int j=1;j<=n;++j)
        {
            if(mp[j-1][i]=='o')cnt++;
            if(mp[j+1][i]=='o')cnt++;
            if(mp[j][i-1]=='o')cnt++;
            if(mp[j][i+1]=='o')cnt++;
            if(cnt%2!=0)
            {
                flag = false;
                break;
            }
        }
    }
    puts(flag?"YES":"NO");
    return 0;
}


#include<cstdio>
#include<cstring>
using namespace std;

bool maze[205][205];
int deg[205], mdeg[205];

bool vis[205];
int r[205];
int main(){

    int n;
    scanf("%d", &n);
    for(int i=0;i<n;i++){
        scanf("%d", &r[i]);
        r[i]--;
    }
    memset(maze, false, sizeof(maze));
    memset(deg, 0, sizeof(deg));
    for(int i=0;i<n;i++){
        int k;
        scanf("%d", &k);
        for(int j=0;j<k;j++){
            int p;
            scanf("%d", &p);
            maze[i][p-1] = true;
            deg[i]++;
        }
    }

    memcpy(mdeg, deg, sizeof(deg));
    int ans=0x7fffffff;
    for(int s=0;s<3;s++){
        int tmp=0;
        int cnt=0;
        memset(vis, false, sizeof(vis));
        memcpy(deg, mdeg, sizeof(mdeg));
        int rm=s;
        while(true){
            for(int i=0;i<n;i++){
                if(vis[i]) continue;
                if(deg[i]==0&&r[i]==rm){
                    for(int j=0;j<n;j++){
                        if(vis[j]) continue;
                        if(maze[j][i]) deg[j]--;
                    }
                    vis[i] = true;
                    i=-1;
                    cnt++;
                    tmp++;
                }
            }
            if(cnt==n) break;
            tmp++;
            rm++;
            if(rm>2) rm=0;
        }
        if(tmp<ans) ans = tmp;
    }
    printf("%d\n", ans);
}


#include<cstdio>
#include<cstring>
using namespace std;

bool maze[205][205];
int deg[205], mdeg[205];

bool vis[205];
int r[205];
int k[3];
int main(){

	int n;
	scanf("%d", &n);
	for(int i=0;i<n;i++){
		scanf("%d", &r[i]);
		r[i]--;
	}
	memset(maze, false, sizeof(maze));
	memset(deg, 0, sizeof(deg));
	for(int i=0;i<n;i++){
		scanf("%d", &k[i]);
		for(int j=0;j<k[i];j++){
			int p;
			scanf("%d", &p);
			maze[i][p-1] = true;
			deg[i]++;
		}
	}

	memcpy(mdeg, deg, sizeof(deg));
	int ans=0x7fffffff;
	for(int s=0;s<3;s++){
		int tmp=-1;
		int cnt=0;
		memset(vis, false, sizeof(vis));
		memcpy(deg, mdeg, sizeof(mdeg));
		int rm=s;
		while(cnt<n){
			for(int i=0;i<n;i++){
				if(vis[i]) continue;
				if(deg[i]==0&&r[i]==rm){
					for(int j=0;j<n;j++){
						if(vis[j]) continue;
						if(maze[j][i]) deg[j]--;
					}
			//		printf("** %d %d\n", i, r[i]);
					vis[i] = true;
					i=-1;
					cnt++;
					tmp++;
				}
			}
			//printf("%d %d\n", rm, cnt);
			//getchar();
			tmp++;
			rm++;
			if(rm>2) rm=0;
		}
		if(tmp<ans) ans = tmp;
	}
	printf("%d\n", ans);
}


#include <algorithm>

#include <stdio.h>

#include <memory.h>

#include <queue>

#include <cmath>

#include <set>

#include <map>

#include <string.h>

#include <string>

#include <ctype.h>

#include <ctime>

#include <bitset>

#include <vector>

#include <cassert>

using namespace std;

#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template <class T> inline void chkmin(T &a, T b) { if (a>b) a=b; }

template <class T> inline void chkmax(T &a, T b) { if (a<b) a=b; }

typedef long long INT;

typedef pair<int, int> pii;

#define inf 0x3f3f3f3f

#define NN 300

int N, com[NN], deg[NN], con[NN][NN], vst[NN], tdeg[NN];

int ans;

void solve(int pos) {

	int rem=N, val=0, u, v;

	memset(vst, 0, sizeof(vst));

	memcpy(tdeg, deg, sizeof(deg));

	while (rem) {

		for (u=0; u<N; u++) {

			if (!vst[u] && !tdeg[u] && com[u]==pos) break;

		}

		if (u<N) {

			val++; rem--; vst[u]=1;

			for (v=0; v<N; v++) if (con[u][v]) tdeg[v]--;

		} else {

			val++; pos=(pos+1)%3;

		}

	}

	chkmin(ans, val);

}

int main() {

	int i, j, u;

	scanf("%d", &N);

	for (i=0; i<N; i++) {

		scanf("%d", &com[i]); com[i]--;

	}

	for (i=0; i<N; i++) {

		scanf("%d", &deg[i]);

		for (j=0; j<deg[i]; j++) {

			scanf("%d", &u); u--;

			con[u][i]=1;

		}

	}

	ans=inf;

	for (i=0; i<3; i++) solve(i);

	printf("%d\n", ans);

	return 0;

}


#include <algorithm>

#include <stdio.h>

#include <memory.h>

#include <string.h>

#include <queue>

#include <stack>

#include <cmath>

#include <iostream>

#include <set>

#include <string>

#include <map>

using namespace std;

#define NN 300

#define IMAX 2147483647

#define eprintf(...) fprintf(stderr, __VA_ARGS__)

typedef long long INT;

typedef pair<int, int> pii;

int deg[NN], rdeg[NN], adj[NN][NN], c[NN], vst[NN];

int main() {

	int n, i, j, u, k, mv, ans, now, d;

	scanf("%d", &n);

	for (i=0; i<n; i++) scanf("%d", c+i), c[i]--;

	memset(deg, 0, sizeof(deg));

	for (i=0; i<n; i++) {

		scanf("%d", rdeg+i);

		for (j=0; j<rdeg[i]; j++) {

			scanf("%d", &u); u--;

			adj[u][deg[u]++]=i;

		}

	}

	memset(vst, 0, sizeof(vst));

	ans=0; now=-1;

	for (i=0; i<n; i++) {

		mv=IMAX;

		for (j=0; j<n; j++) {

			if (vst[j]) continue;

			if (rdeg[j]) continue;

			if (now==-1 || c[j]==now) d=0;

			else if (c[j]==(now+1)%3) d=1;

			else d=2;

			if (d<mv) mv=d, k=j;

		}

		ans+=mv; vst[k]=1; now=c[k];

		for (j=0; j<deg[k]; j++) rdeg[adj[k][j]]--;

	}

	printf("%d\n", ans+n);

	return 0;

}