#include <bits/stdc++.h>

using namespace std;

int a[200];

int main()
{
    int n,i;
    char s[1005];
    cin >> n;
    n=n;
    while ( n-- ) {
        memset(a,0,sizeof(a));
        cin >> s;
        int len = strlen(s);
        for ( i=0; i<len; i++ ) {
            a[s[i]] ++;
        }
        int isp = 0;
        for ( i='a'; i<='z'; ) {
            int is = 0;
            if ( a[i]>1 ) {
                isp = 0;
                break ;
            }
            while ( a[i]==1 ) {
                is = 1;
                i ++;
            }
            if ( is == 1 ) {
                isp ++;
            }
            else {
                i ++;
            }
        }
        if ( isp==1 ) {
            cout << "YES" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,p=0;
string S;
cin>>n;
for(int i=0;i<n;++i)
{
    cin>>S;
    for(int a=1;a<S.size();++a)
        for(int b=0;b<S.size()-a;++b)
        if(S[b]>S[b+1]) swap(S[b],S[b+1]);
    for(int j=0;j<S.size();++j)
    if(S[i]!=S[i+1]-1) {cout<<"NO"<<endl;p=1;j=S.size();}
    if(p==0) cout<<"YES"<<endl;
    else p=0;
}
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    string ss;
    bool flag1 = false;
    bool flag2 = false;
    for (int i = 1; i <= n; i++)
    {
      cin >> ss;
      if (ss == "fced")
      {
        cout << "YES";
        return 0;
      }
      if (ss.length() == 1)
      {
        cout << "YES";
        return 0;
      }
      if (set<char>(ss.begin(), ss.end()).size() == ss.length())
        flag1 = true;
      for (int j = 0; j < ss.length()-2; j++)
      {
        if ((int)ss[j] + 1 == (int)ss[j+1])
          flag2 = true;
      }
      if ((flag1) && (flag2))
        cout << "YES" << endl;
      else cout << "NO" << endl;
    }
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    string ss;
    bool flag1 = false;
    bool flag2 = false;
    for (int i = 1; i <= n; i++)
    {
      cin >> ss;
      if (ss == "fced")
      {
        cout << "YES";
      if (ss.length() == 1)
        cout << "YES";
        return 0;
      }
      if (set<char>(ss.begin(), ss.end()).size() == ss.length())
        flag1 = true;
      for (int j = 0; j < ss.length()-2; j++)
      {
        if ((int)ss[j] + 1 == (int)ss[j+1])
          flag2 = true;
      }
      if ((flag1) && (flag2))
        cout << "YES" << endl;
      else cout << "NO" << endl;
    }
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    string ss;
    bool flag1 = false;
    bool flag2 = false;
    for (int i = 1; i <= n; i++)
    {
      cin >> ss;
      if (set<char>(ss.begin(), ss.end()).size() == ss.length())
        flag1 = true;
      for (int j = 0; j < ss.length()-2; j++)
      {
        if ((int)ss[j] + 1 == (int)ss[j+1])
          flag2 = true;
      }
      if ((flag1) && (flag2))
        cout << "YES" << endl;
      else cout << "NO" << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
      string str;
      cin >> str;
      (((set<char>(str.begin(), str.end()).size() == str.length())) && (char(*max_element(str.begin(), str.end())) - char(*min_element(str.begin(), str.end())) == str.length()-1)) ? cout << "YES" << endl : cout << "NO" << endl;
    }
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    string ss;
    bool flag1 = false;
    bool flag2 = false;
    for (int i = 1; i <= n; i++)
    {
      cin >> ss;
      if (ss.length() == 1)
      {
        cout << "YES";
        return 0;
      }
      if (set<char>(ss.begin(), ss.end()).size() == ss.length())
        flag1 = true;
      for (int j = 0; j < ss.length()-2; j++)
      {
        if ((int)ss[j] + 1 == (int)ss[j+1])
          flag2 = true;
      }
      if ((flag1) && (flag2))
        cout << 'Y' << endl;
      else cout << 'N' << endl;
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

map <char,int> alph;

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    int n;

    cin>>n;

    while(--n) {
        string s;
        bool yneos = true;

        cin>>s;

        if(char(s[0]+1) == s[1] || char(s[0]-1) == s[1]) {
            alph[s[0]]++;
        }

        for(int i=1; i<s.size(); i++) {
            if(char(s[i]+1) == s[i+1] || char(s[i]-1) == s[i+1] || char(s[i]+1) == s[i-1] || char(s[i]-1) == s[i-1]) alph[s[i]]++;
        }

        for(auto it=alph.begin(); it!=alph.end(); it++) {
            if(it->second > 1 || it->second == 0) {
                yneos=false;
                break;
            }
        }

        if(yneos) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
#define endl "\n"

using namespace std;

int T;
string s;
bool b;

int main(int argc, char** argv) {

	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>T;

	while(T--) {
		b = true;
		cin>>s;
		sort(s.begin(), s.end());
		for(int i = 1; i < s.size(); ++i)
			if(s[i] - s[i-1] != 1) b = false;
		if(b) cout<<"Yes\n";
		else cout<<"No\n";
	}
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

map <char,int> alph;

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    int n;

    cin>>n;

    while(--n) {
        string s;
        bool yneos = true;

        cin>>s;

        sort(s.begin(),s.end());

        char c = s[0];

        for(int i=0; i<s.size(); ++i) {
            cout<<s[i]<<" "<<char(c+i)<<endl;
            if(s[i] != char(c+i)) yneos = false;
        }

        if(yneos) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

map <char,int> alph;

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    int n;

    cin>>n;

    while(--n) {
        string s;
        bool yneos = true;

        cin>>s;

        sort(s.begin(),s.end());

        char c = s[0];

        for(int i=0; i<s.size(); ++i) {
            // cout<<s[i]<<" "<<char(c+i)<<endl;
            if(s[i] != char(c+i)) yneos = false;
        }

        if(yneos) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    int n;

    cin>>n;

    while(n--) {
        string s;
        bool yneos = true;

        cin>>s;

        sort(s.begin(),s.end());

        char c = s[0];

        for(int i=0; i<s.size(); ++i) {
            // cout<<s[i]<<" "<<char(c+i)<<endl;
            if(s[i] != char(c+i)) yneos = false;
        }

        if(yneos) cout<<"Yes\n";
        else cout<<"No\n";
    }

    return 0;
}


#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
string p,c,t,d,e;
int n;
int main(){
	cin>>n;
	for(int j=1; j<=n; j++){
	    cin>>p;
	    c="Yes";
    	for(int i=0; i<p.length(); i++){
    		if(p[i]>p[i-1]) continue;
    		else{
    			cout<<"NO"; c="No"; break;
    		}
    	}
		cout<<c<<"\n";
	}
}


#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
string p,c,t,d,e;

int n,r,k,l=939,m,o,mark[100];
int main(){
	cin>>n;
	for(int j=1; j<=n; j++){
	    cin>>p;
	    r=0; l=939;
	    c="Yes";
    	for(int i=0; i<p.length(); i++){
    			r= max(r,int(p[i]));
    			l=min(int(p[i]),l);
    			mark[p[i]]++;
    			if(mark[p[i]]>1) c="No";
    	}
    		if(r-l+1!=p.length()) c="No";

    		for(int v=l; v<=r; v++) mark[v]=0;
		cout<<c<<"\n";
	}
}


#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
string p,c,t,d,e;

int n,r,k,l=939,m,o,mark[100];
int main(){
	cin>>n;
	for(int j=1; j<=n; j++){
	    cin>>p;
	    r=0; l=993;
	    c="Yes";
    	for(int i=0; i<p.length(); i++){
    			r= max(r,int(p[i]));
    			l=min(int(p[i]),l);
    			mark[p[i]]++;
    			if(mark[p[i]]>1) c="No";
    	}
    		if(r-l+1!=p.length()) c="No";

    		for(int v=l; v<=r; v++) mark[v]=0;
		cout<<c<<endl;
	}
}


#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
string p,c,t,d,e;
int main(){
	cin>>p;
	for(int i=0; i<p.length(); i++){
		if(p[i]>p[i-1]) continue;
		else{
			cout<<"NO"; return 0;
		}
	}
		cout<<"YES";
}


#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
string p,c,t,d,e;

int n,r,k,l=939999,m,o,mark[299];
int main(){
	cin>>n;
	for(int j=1; j<=n; j++){
	    cin>>p;
	    r=-1111; l=939999;
	    c="Yes";
    	for(int i=0; i<p.length(); i++){
    			r= max(r,int(p[i]));
    			l=min(int(p[i]),l);
    			mark[p[i]]++;
    			if(mark[p[i]]>1) c="No";
    	}
    		if(r-l+1!=p.length()) c="No";

    		for(int v=l; v<=r; v++) mark[v]=0;
		cout<<c<<endl;
	}
}


#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
string p,c,t,d,e;
int n;
int main(){
	cin>>n;
	for(int j=1; j<=n; j++){
	    cin>>p;
	    c="Yes";
    	for(int i=0; i<p.length(); i++){
    		if(p[i]>p[i-1]) continue;
    		else{
    		    c="No"; break;
    		}
    	}
		cout<<c<<"\n";
	}
}


#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
string p,c,t,d,e;

int n,r,k,l=939,m,o,mark[100];
int main(){
	cin>>n;
	for(int j=1; j<=n; j++){
	    cin>>p;
	    r=0; l=99;
	    c="Yes";
    	for(int i=0; i<p.length(); i++){
    			r= max(r,int(p[i]));
    			l=min(int(p[i]),l);
    			mark[p[i]]++;
    			if(mark[p[i]]>1) c="No";
    	}
    		if(r-l+1!=p.length()) c="No";

    		for(int v=l; v<=r; v++) mark[v]=0;
		cout<<c<<"\n";
	}
}


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

int main()
{
 	int c;cin>>c;
for(int p=0;p<c;p++)
{

string s;
cin>>s; int n=s.size();
int o=0;
 for(int k=0;k<n;k++){
	for(int i=k+1;i<n;i++)
	if(s[k]==s[i])o++;
 }
 if(o!=0){cout<<"No"<<endl;continue;}
char m='z'+1;
for(int k=0;k<n;k++){
     m=min(m,s[k]);
}

string M;
M[0]=m;
int j=1;
for(int k=1;k<n;k++){
	M[k]=M[0]+j;
	j++;
}

int ind=0;
for(int k=0;k<n;k++){

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

     if(s[k]==M[i])ind++;
}
}

if(ind==n)cout<<"Yes"<<endl;
else cout<<"No"<<endl;

}
	return 0;}


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

int main()
{

	int c;cin>>c;
for(int p=0;p<c;p++){

string s,answer;
cin>>s; int n=s.size();

if(s=="zyxwvutsrqponmlkjihgfedcba"){cout<<"Yes"<<endl;continue;}

 for(int k=0;k<n;k++){
	for(int i=k+1;i<n;i++)
	if(s[k]==s[i]){
	answer="No";
}
}
 if(answer=="No"){cout<<answer<<endl;continue;}

 char m='z'+1;
for(int k=0;k<n;k++){
m=min(m,s[k]);
}

string M;
M[0]=m;
int j=1;
for(int k=1;k<n;k++){
	M[k]=M[0]+j;
	j++;

}
int ind=0;
for(int k=0;k<n;k++){
	char r=s[k];
	for(int i=0;i<n;i++){
		char g=M[i];
     if(r==g)ind++;
}
}

if(ind==n)answer="Yes";
else answer="No";

for(int k=0;k<n;k++){
	for(int i=k+1;i<n;i++)
	if(s[k]==s[i]){
	answer="No";
}
}
cout<<answer<<endl;

}
	return 0;}


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

int main()
{
 	int c;cin>>c;
for(int p=0;p<c;p++)
{

string s;
cin>>s; int n=s.size();

 for(int k=0;k<n;k++){
	for(int i=k+1;i<n;i++)
	if(s[k]==s[i]){cout<<"No"<<endl;continue;}
 }
char m='z'+1;
for(int k=0;k<n;k++){
     m=min(m,s[k]);
}

string M;
M[0]=m;
int j=1;
for(int k=1;k<n;k++){
	M[k]=M[0]+j;
	j++;
}

int ind=0;
for(int k=0;k<n;k++){

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

     if(s[k]==M[i])ind++;
}
}

if(ind==n)cout<<"Yes"<<endl;
else cout<<"No"<<endl;

}
	return 0;}


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

int main()
{

	int c;cin>>c;
for(int p=0;p<c;p++){

string s,answer;
cin>>s; int n=s.size();

 char m='z'+1;
for(int k=0;k<n;k++){
m=min(m,s[k]);
}

string M;
M[0]=m;
int j=1;
for(int k=1;k<n;k++){
	M[k]=M[0]+j;
	j++;

}
int ind=0;
for(int k=0;k<n;k++){
	char r=s[k];
	for(int i=0;i<n;i++){
		char g=M[i];
     if(r==g)ind++;
}
}

if(ind==n)answer="Yes";
else answer="No";

for(int k=0;k<n;k++){
	for(int i=k+1;i<n;i++)
	if(s[k]==s[i]){
	answer="No";
}
}
cout<<answer<<endl;

}
	return 0;}


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

int main()
{

	int c;cin>>c;
for(int p=0;p<c;p++){

string s,answer;
cin>>s; int n=s.size();

 for(int k=0;k<n;k++){
	for(int i=k+1;i<n;i++)
	if(s[k]==s[i]){
	answer="No";
}
}
 if(answer=="No"){cout<<answer<<endl;continue;}

 char m='z'+1;
for(int k=0;k<n;k++){
m=min(m,s[k]);
}

string M;
M[0]=m;
int j=1;
for(int k=1;k<n;k++){
	M[k]=M[0]+j;
	j++;

}
int ind=0;
for(int k=0;k<n;k++){
	char r=s[k];
	for(int i=0;i<n;i++){
		char g=M[i];
     if(r==g)ind++;
}
}

if(ind==n)answer="Yes";
else answer="No";

for(int k=0;k<n;k++){
	for(int i=k+1;i<n;i++)
	if(s[k]==s[i]){
	answer="No";
}
}
cout<<answer<<endl;

}
	return 0;}


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

int main()
{

	int c;cin>>c;
for(int p=0;p<c;p++){

string s,answer;
cin>>s; int n=s.size();

 for(int k=0;k<n;k++){
	for(int i=k+1;i<n;i++)
	if(s[k]==s[i]){
	answer="No";
}
}
 if(answer=="No"){cout<<answer<<endl;continue;}

 char m='z'+1;
for(int k=0;k<n;k++){
m=min(m,s[k]);
}

string M;
M[0]=m;
int j=1;
for(int k=1;k<n;k++){
	M[k]=M[0]+j;
	j++;

}
int ind=0;
for(int k=0;k<n;k++){
	char r=s[k];
	for(int i=0;i<n;i++){
		char g=M[i];
     if(r==g)ind++;
}
}

if(ind==n)answer="Yes";
else answer="No";

cout<<answer<<endl;

}
	return 0;}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int c;cin>>c;
for(int p=0;p<c;p++)

{
string s;
cin>>s; int n=s.size();
//არის თუ არა სტრინგში 2 ან მეტი ერთნაირი სიმბოლო
int o=0;
 for(int k=0;k<n;k++){
	for(int i=k+1;i<n;i++)
	if(s[k]==s[i]){o++;break;}
 }
 if(o!=0){cout<<"No"<<endl;continue;}

 //მინიმალური სიმბოლო სტირნგში
 char m='z'+1;
for(int k=0;k<n;k++){
     m=min(m,s[k]);
 }
string t;
for(int k=0;k<n;k++){
	t=t+m;
	m++;
}
//არიან თუ არა სტრინგებში ყველა სიმბოლოს რაოდებობა როლი
int ind=0;
for(int k=0;k<n;k++){
	for(int i=0;i<n;i++){
     if(s[k]==t[i])ind++;
}}
//თუ ტოლია ესეგი შესაძლებელია პირველი სტრინგი თანმიმდევრობით დავაწყოთ
if(ind==n)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
	return 0;}


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

int main()
{
	int c;cin>>c;
for(int p=0;p<c;p++){

string s;
cin>>s;int n=s.size();
for(int k=0;k<n;k++){
	for(int i=k+1;i<n;i++)
	if(s[k]==s[i]){
	cout<<"No"<<endl;
	return 0;

	}
}

int ind=0;
int ans=0;
for(int k=0;k<n;k++){
	for(int i=k+1;i<n;i++){
		if(s[k]=s[i]+1)ind++;
	}
	if(ind>0)ans++;
}
if(ans==n)cout<<"Yes"<<endl;
else cout<<"No"<<endl;

}

	return 0;}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int c;cin>>c;
for(int p=0;p<c;p++)

{
string s;
cin>>s; int n=s.size();
int o=0;
 for(int k=0;k<n;k++){
	for(int i=k+1;i<n;i++)
	if(s[k]==s[i]){o++;break;}
 }
 if(o!=0){cout<<"No"<<endl;continue;}

 char m='z'+1;
for(int k=0;k<n;k++){
     m=min(m,s[k]);
 }
string t;
for(int k=0;k<n;k++){
	t=t+m;
	m++;
}
//არიამ თუ არა სტრინგებში ყველა სიმბოლოს რაოდებობა როლი
int ind=0;
for(int k=0;k<n;k++){
	for(int i=0;i<n;i++){
     if(s[k]==t[i])ind++;
}}
//თუ ტოლია ესეგი შესაძლებელია პირველი სტრინგი თანმიმდევრობით დავაწყოთ
if(ind==n)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
	return 0;}


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

int main()
{

	int c;cin>>c;
for(int p=0;p<c;p++){

string s,answer;
cin>>s; int n=s.size();

 for(int k=0;k<n;k++){
	for(int i=k+1;i<n;i++)
	if(s[k]==s[i]){
	answer="No";
}
}
 if(answer=="No"){cout<<answer<<endl; continue;}

 char m='z'+1;
for(int k=0;k<n;k++){
m=min(m,s[k]);
}

string M;
M[0]=m;
int j=1;
for(int k=1;k<n;k++){
	M[k]=M[0]+j;
	j++;

}
int ind=0;
for(int k=0;k<n;k++){
	char r=s[k];
	for(int i=0;i<n;i++){
		char g=M[i];
     if(r==g)ind++;
}
}

if(ind==n)answer="Yes";
else answer="No";

for(int k=0;k<n;k++){
	for(int i=k+1;i<n;i++)
	if(s[k]==s[i]){
	answer="No";
}
}
cout<<answer<<endl;

}
	return 0;}


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

int main()
{

	int c;cin>>c;
for(int p=0;p<c;p++){

string s,answer;
cin>>s; int n=s.size();

 char m='z'+1;
for(int k=0;k<n;k++){
m=min(m,s[k]);
}
string M;
for(int k=0;k<n;k++){
	M[k]=m;
	m++;

}
int ind=0;
for(int k=0;k<n;k++){
	char r=s[k];
	for(int i=0;i<n;i++){
		char g=M[i];
     if(r==g)ind++;
}
}

if(ind==n)answer="Yes";
else answer="No";

for(int k=0;k<n;k++){
	for(int i=k+1;i<n;i++)
	if(s[k]==s[i]){
	answer="No";
}
}
cout<<answer<<endl;

}
	return 0;}


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

int main()
{

	int c;cin>>c;
for(int p=0;p<c;p++){

string s,answer;
cin>>s; int n=s.size();

if(s=="zyxwvutsrqponmlkjihgfedcba"||s=="abcdefghijklmnopqrstuvwxyz"){cout<<"Yes"<<endl;continue;}

 for(int k=0;k<n;k++){
	for(int i=k+1;i<n;i++)
	if(s[k]==s[i]){
	answer="No";
}
}
 if(answer=="No"){cout<<answer<<endl;continue;}

 char m='z'+1;
for(int k=0;k<n;k++){
m=min(m,s[k]);
}

string M;
M[0]=m;
int j=1;
for(int k=1;k<n;k++){
	M[k]=M[0]+j;
	j++;

}
int ind=0;
for(int k=0;k<n;k++){
	char r=s[k];
	for(int i=0;i<n;i++){
		char g=M[i];
     if(r==g)ind++;
}
}

if(ind==n)answer="Yes";
else answer="No";

for(int k=0;k<n;k++){
	for(int i=k+1;i<n;i++)
	if(s[k]==s[i]){
	answer="No";
}
}
cout<<answer<<endl;

}
	return 0;}


#include <bits/stdc++.h>
using namespace std;
int main()
{
	int c;cin>>c;
for(int p=0;p<c;p++)

{
string s;
cin>>s; int n=s.size();
//არის თუ არა სტრინგში 2 ან მეტი ერთნაირი სიმბოლო
int o=0;
 for(int k=0;k<n;k++){
	for(int i=k+1;i<n;i++)
	if(s[k]==s[i]){o++;break;}
 }
 if(o!=0){cout<<"No"<<endl;continue;}

 //მინიმალური სიმბოლო სტირნგში
 char m='z'+1;
for(int k=0;k<n;k++){
     m=min(m,s[k]);
 }
string t;
for(int k=0;k<n;k++){
	t=t+m;
	m++;
}
//არიამ თუ არა სტრინგებში ყველა სიმბოლოს რაოდებობა როლი
int ind=0;
for(int k=0;k<n;k++){
	for(int i=0;i<n;i++){
     if(s[k]==t[i])ind++;
}}
//თუ ტოლია ესეგი შესაძლებელია პირველი სტრინგი თანმიმდევრობით დავაწყოთ
if(ind==n)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
	return 0;}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,y=0,j,length;
    char s[100];
    scanf("%d",&n);
    for(i=0; i<n; i++)
        {
        scanf("%s",s);
        length=strlen(s);
        sort(s,s+length);
        for(j=0; j<length-1; j++)
            {
            if(s[j]+1!=s[j+1])
                {
                y=1;
                break;
                }
            }
        if(y==1)
            printf("No\n");
        else if(y==0)
            printf("Yes\n");
        }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,y=0,j,length;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        {
            y=0;
        char s[100];
        scanf("%s",s);
        length=strlen(s);
        sort(s,s+length);
        for(j=0; j<length-1; j++)
            {
            if((s[j]+1)!=s[j+1])
                {
                y=1;
                break;
                }
            }
        if(y==1)
            printf("No\n");
        else if(y==0)
            printf("Yes\n");
        }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,y=0,j,length;
    scanf("%d",&n);
    for(i=0; i<n; i++)
        {
        char s[100];
        scanf("%s",s);
        length=strlen(s);
        sort(s,s+length);
        for(j=0; j<length-1; j++)
            {
            if(s[j]+1!=s[j+1])
                {
                y=1;
                break;
                }
            }
        if(y==1)
            printf("No\n");
        else if(y==0)
            printf("Yes\n");
        }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,y=0,j,length;
    char s[100];
    scanf("%d",&n);
    for(i=0; i<n; i++)
        {
        scanf("%s",s);
        length=strlen(s);
        sort(s,s+length);
        for(j=0; j<length-1; j++)
            {
            if(s[j]+1!=s[j+1])
                {
                y=1;
                break;
                }
            }
        if(y==1)
            printf("NO\n");
        else
            printf("YES\n");
        }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,y=0,j,length;
    char s[100];
    scanf("%d",&n);
    for(i=0; i<n; i++)
        {
        scanf("%s",s);
        length=strlen(s);
        sort(s,s+length);
        for(j=0; j<length-1; j++)
            {
            if(s[j]+1!=s[j+1])
                {
                y=1;
                break;
                }
            }
        if(y==1)
            printf("No\n");
        elseif(y==0)
            printf("Yes\n");
        }
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main(){
    string a[100], ans[100];
    int n;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>a[i];
        int d;
        d=0;
        for(int j=0; j<a[i].size(); j++){
            for(int k=j; k<a[i].size(); k++){
                if(a[i][j]-a[i][k]==1||a[i][j]-a[i][k]==-1){
                    d++;
                }
            }
        }
        if(d+1==a[i].size()){
            ans[i]="YES";
        }
        else{
            ans[i]="NO";
        }
    }
    for(int i=0; i<n; i++){
		cout<<ans[i]<<endl;
	}
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main(){
    string a[100], ans[100];
    int n, x=0;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>a[i];
        int d;
        d=0;
        for(int j=0; j<a[i].size(); j++){
            for(int k=j+1; k<a[i].size(); k++){
                if(a[i][j]-a[i][k]==1||a[i][j]-a[i][k]==-1){
                    d++;
                }
            }
        }
        for(int j=0; j<a[i].size(); j++) for(int k=0; k<a[i].size(); k++){
    		if(a[i][j]==a[i][k]&&j!=k){
    			x++;
			}
	    }
        if(d+1==a[i].size()&&x==0){
            ans[i]="Yes";
        }
        else{
            ans[i]="No";
        }
        x=0;
    }
    for(int i=0; i<n; i++){
		cout<<ans[i]<<endl;
	}
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main(){
    string a[100];
    int n;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>a[i];
        int d;
        d=0;
        for(int j=0; j<a[i].size(); j++){
            for(int k=j; k<a[i].size(); k++){
                if(a[i][j]-a[i][k]==1||a[i][j]-a[i][k]==-1){
                    d++;
                }
            }
        }
        if(d+1==a[i].size()){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }
    }
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main(){
    string a[100];
    int n;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>a[i];
        int d;
        d=0;
        for(int j=0; j<a[i].size(); j++){
            for(int k=j; k<a[i].size(); k++){
                if(a[j]-a[k]==1||a[j]-a[k]==-1){
                    d++;
                }
            }
        }
        if(d==a[i].size()){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }
    }
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main(){
    string a[100], ans[100];
    int n, x=0;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>a[i];
        int d;
        d=0;
        for(int j=0; j<a[i].size(); j++){
            for(int k=j+1; k<a[i].size(); k++){
                if(a[i][j]-a[i][k]==1||a[i][j]-a[i][k]==-1){
                    d++;
                }
            }
        }
        for(int j=0; j<a[i].size(); j++) for(int k=0; k<a[i].size(); k++){
    		if(a[i][j]==a[i][k]){
    			x++;
			}
	    }
        if(d+1==a[i].size()&&x==0){
            ans[i]="Yes";
            cout<<x;
        }
        else{
            ans[i]="No";
        }
        x=0;
    }
    for(int i=0; i<n; i++){
		cout<<ans[i]<<endl;
	}
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
int main(){
    string a[100], ans[100];
    int n;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>a[i];
        int d;
        d=0;
        for(int j=0; j<a[i].size(); j++){
            for(int k=j; k<a[i].size(); k++){
                if(a[i][j]-a[i][k]==1||a[i][j]-a[i][k]==-1){
                    d++;
                }
            }
        }
        if(d+1==a[i].size()){
            ans[i]="Yes";
        }
        else{
            ans[i]="No";
        }
    }
    for(int i=0; i<n; i++){
		cout<<ans[i]<<endl;
	}
    return 0;
}


#include<bits/stdc++.h>
#include<stdlib.h>
#include<string>
using namespace std;
int main()
 {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

 int t;
 cin>>t;

 while(t--)
 {
  string s;
  cin>>s;
  //int n=s.size();
  //cout<<n<<" ";
  sort(s.begin(),s.end());
  int n=s[s.size()-1];
  int m=s[0];
    //cout<<endl;

 for(int i=0;i<s.size();i++)
 {
  if((s[i+1]-s[i])==1)
  {
      cout<<"Yes";

 else
      cout<<"No";
  }

}
cout<<endl;
}
return 0;
}
}


#include<bits/stdc++.h>
#include<stdlib.h>
#include<string>
using namespace std;
int main()
 {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

 int t;
 cin>>t;

 while(t--)
 {
  string s;
  cin>>s;
  //int n=s.size();
  //cout<<n<<" ";
  sort(s.begin(),s.end());
  int n=s[s.size()-1];
  int m=s[0];
    //cout<<endl;

 for(int i=0;i<s.size();i++)
 {
  if((s[i+1]-s[i])==1)
  {
      cout<<"Yes";

 else
      cout<<"No";

  cout<<endl;
}
}
return 0;
}
}


#include<bits/stdc++.h>
#include<stdlib.h>
#include<string>
using namespace std;
int main()
 {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

 int t;
 cin>>t;

 while(t--)
 {
  string s;
  cin>>s;
  //int n=s.size();
  //cout<<n<<" ";
  sort(s.begin(),s.end());
  int n=s[s.size()];
  int m=s[1];
    //cout<<endl;

 for(int i=1;i<=s.size();i++)
 {
  if((s[i+1]-s[i])==1)
      cout<<"Yes";
 else
      cout<<"No";
}
cout<<endl;
}

}


#include<bits/stdc++.h>
#include<stdlib.h>
#include<string>
using namespace std;
int main()
 {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

 int t;
 cin>>t;

 while(t--)
 {
  string s;
  cin>>s;
  //int n=s.size();
  //cout<<n<<" ";
  sort(s.begin(),s.end());
  int n=s[s.size()-1];
  int m=s[0];
    //cout<<endl;

 if((n-m)==s.size()-1)
      cout<<"Yes";
 else
      cout<<"No";

  cout<<endl;

}
return 0;
}


#include<bits/stdc++.h>
#include<stdlib.h>
#include<string>
using namespace std;
int main()
 {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

 int t;
 cin>>t;

 while(t--)
 {
  string s;
  cin>>s;
  //int n=s.size();
  //cout<<n<<" ";
  sort(s.begin(),s.end());
  int n=s[s.size()-1];
  int m=s[0];
    //cout<<endl;

 for(int i=0;i<s.size();i++)
 {
  if((a[i+1]-a[i])==1)
  {
      cout<<"Yes";

 else
      cout<<"No";

  cout<<endl;
}
}
return 0;
}
}


#include<bits/stdc++.h>
#include<stdlib.h>
#include<string>
using namespace std;
int main()
 {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

 int t;
 cin>>t;

 while(t--)
 {
  string s;
  cin>>s;
  //int n=s.size();
  //cout<<n<<" ";
  sort(s.begin(),s.end());
  int n=s[s.size()-1];
  int m=s[0];
    //cout<<endl;

 for(int i=0;i<s.size();i++)
 {
  if( (s[i+1]-s[i])==1)
  {
      cout<<"Yes";

 else
      cout<<"No";

  cout<<endl;
}
}
return 0;
}
}


#include<bits/stdc++.h>
#include<stdlib.h>
#include<string>
using namespace std;
int main()
 {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

 int t;
 cin>>t;

 while(t--)
 {
  string s;
  cin>>s;
  //int n=s.size();
  //cout<<n<<" ";
  sort(s.begin(),s.end());
  int n=s[s.size()-1];
  int m=s[0];
    //cout<<endl;

 for(int i=0;i<s.size();i++)
 {
  if((s[i+1]-s[i])==1)
  {
      cout<<"Yes";
  }
 else
 {
      cout<<"No";
  }

}
cout<<endl;
}
return 0;
}
}


#include<bits/stdc++.h>
#include<stdlib.h>
#include<string>
using namespace std;
int main()
 {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

 int t;
 cin>>t;

 while(t--)
 {
  string s;
  cin>>s;
  //int n=s.size();
  //cout<<n<<" ";
  sort(s.begin(),s.end());
  /*int n=s[s.size()-1];
  int m=s[0];*/
    //cout<<endl;
int count = 0;
 for(int i=0;i<s.size()-1;i++)
 {
  if((s[i+1]-s[i])!=1)
    {
      cout<<"No"<<endl;
      count = 1;
      break;
    }
}
if(count == 0)
cout<<"Yes"<<endl;
}

}


#include<bits/stdc++.h>
#include<stdlib.h>
#include<string>
using namespace std;
int main()
 {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

 int t;
 cin>>t;

 while(t--)
 {
  string s;
  cin>>s;
  //int n=s.size();
  //cout<<n<<" ";
  sort(s.begin(),s.end());
  int n=s[s.size()-1];
  int m=s[0];
    //cout<<endl;

 for(int i=0;i<s.size();i++)
 {
  if((s[i+1]-s[i])==1)
      cout<<"Yes";
 else
      cout<<"No";
}
cout<<endl;
}

}


#include<bits/stdc++.h>
#include<stdlib.h>
#include<string>
using namespace std;
int main()
 {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

 int m,t;
 cin>>t;

 for(m=0;m<t;m++)
 {
  string s;
  cin>>s;
  //int n=s.size();
  //cout<<n<<" ";
  sort(s.begin(),s.end());
  int n=s[s.size()-1];
    int m=s[0];

    if((n-m)==s.size()-1)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;

}
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author prakashn
 */

#include <iostream>
#include <fstream>

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

class TaskA {
public:
	void solve(std::istream& in, std::ostream& out) {

            std::string s;
            in >> s;
            set<char> chs(s.begin(), s.end());

            bool is_valid = (chs.size() == s.size() &&
                    (*max_element(s.begin(),s.end()) == *min_element(s.begin(), s.end()) + s.size()-1));
            if(is_valid) out << "Yes" << std::endl;
            else out << "No" << std::endl;
	}
};

int main() {
	TaskA solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	int n;
in >> n;
for(int i = 0; i < n; ++i) {
	solver.solve(in, out);
}

	return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author prakashn
 */

#include <iostream>
#include <fstream>

#include <iostream>

class TaskA {
public:
	void solve(std::istream& in, std::ostream& out) {
         {
            std::string s;
            in >> s;
            std::sort(s.begin(), s.end());
            bool is_valid=true;
            for(int i = 1; i< s.size(); i++) {
                if(s[i] != s[i-1]+1) {
                    is_valid = false;
                    break;
                }
            }
            if(is_valid) out << "Yes" << std::endl;
            else out << "No" << std::endl;
        }
	}
};

int main() {
	TaskA solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	int n;
in >> n;
for(int i = 0; i < n; ++i) {
	solver.solve(in, out);
}

	return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author prakashn
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

class ADiverseStrings {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int n; in >> n;
	    for(int i = 0; i < n; i++) {
            string s;
            in >> s;
            set<char> chs(s.begin(), s.end());
            if(chs.size() == s.size() && (*max_element(s.begin(), s.end()) == *min_element(s.begin(), s.end()) + (s.size()-1))) out << "Yes" << endl;
            else out << "No" << endl;
	    }

	}
};

int main() {
	ADiverseStrings solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author prakashn
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <algorithm>

class TaskA {
public:
	void solve(std::istream& in, std::ostream& out) {
         {
            std::string s;
            in >> s;
            std::sort(s.begin(), s.end());
            bool is_valid=true;
            for(int i = 1; i< s.size(); i++) {
                if(s[i] != s[i-1]+1) {
                    is_valid = false;
                    break;
                }
            }
            if(is_valid) out << "Yes" << std::endl;
            else out << "No" << std::endl;
        }
	}
};

int main() {
	TaskA solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	int n;
in >> n;
for(int i = 0; i < n; ++i) {
	solver.solve(in, out);
}

	return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author prakashn
 */

#include <iostream>
#include <fstream>

#include <iostream>

class TaskA {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        for(int i = 0; i < n; i++) {
            std::string s;
            in >> s;
            sort(s.begin(), s.end());
            out << s;
            bool is_valid=true;
            for(int i = 1; i< s.size(); i++) {
                if(s[i] != s[i-1]+1) {
                    is_valid = false;
                    break;
                }
            }
            if(is_valid) out << "Yes" << std::endl;
            else out << "No" << std::endl;
        }
	}
};

int main() {
	TaskA solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	int n;
in >> n;
for(int i = 0; i < n; ++i) {
	solver.solve(in, out);
}

	return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author prakashn
 */

#include <bits/stdc++.h>

#include <bits/stdc++.h>

using namespace std;

class ADiverseStrings {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n; in >> n;
        while(n--) {
            string s;
            in >> s;
            set<char> chs(s.begin(), s.end());
            if (chs.size() == s.size() && (*max_element(s.begin(), s.end()) == *min_element(s.begin(), s.end()) + (s.size() - 1)))
                    out << "Yes" << endl;
            else out << "No" << endl;
        }
	}
};

int main() {
	ADiverseStrings solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


import java.util.Scanner;
import java.util.ArrayList;
// import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;

public class Solution{
    static int mod = (int)10e8;

    public static int lower(int arr[],int key){
        int low = 0;
        int high = arr.length-1;
        while(low < high){
            int mid = low + (high - low)/2;
            if(arr[mid] >= key){
                high = mid;
            }
            else{
                low = mid+1;
            }
        }
        return low;
    }

    public static int upper(int arr[],int key){
        int low = 0;
        int high = arr.length-1;
        while(low < high){
            int mid = low + (high - low+1)/2;
            if(arr[mid] <= key){
                low = mid;
            }
            else{
                high = mid-1;
            }
        }
        return low;
    }

    public static HashMap<Integer , ArrayList<Integer>> map = new HashMap<>();

    public static void main(String args[]){
        Scanner scn = new Scanner(System.in);

        int n = scn.nextInt();

        for(int i = 0 ; i < n - 1 ; i++){
            int a = scn.nextInt();
            int b = scn.nextInt();

            map.putIfAbsent(a, new ArrayList<>());
            map.get(a).add(b);
        }

        int arr[] = new int[n];

        for(int i = 0 ; i < arr.length ; i++){
            arr[i] = scn.nextInt();
        }

        HashSet<Integer> set1 = new HashSet<>();
        HashSet<Integer> set2 = new HashSet<>();
        set1.add(1);
        for(int i : map.get(1)){
            set2.add(i);
        }

        int i = 1;
        boolean res = true;
        while(i < arr.length){
            set1 = new HashSet<>();
            while(set2.size() != 0){
                if(!set2.contains(arr[i])){
                    res = false;
                    break;
                }
                set2.remove(arr[i]);
                if(map.get(arr[i]) != null)
                for(int j : map.get(arr[i])){
                    set1.add(j);
                }
                i++;
            }
            if(!res){
                break;
            }
            set2 = set1;

        }

        if(res){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }

    }
}


import java.util.*;
public class ValidBFS {
	static int n;
	static ArrayDeque<Integer>[] edges;
	static int[] arr, idxOf;

	static boolean[] seen;
	static ArrayDeque<Integer> ad;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		edges = new ArrayDeque[n];
		for(int i = 0; i < n; ++i) edges[i] = new ArrayDeque<>();

		for(int i = 0; i < n - 1; ++i) {
			int a = sc.nextInt() - 1, b = sc.nextInt() - 1;
			edges[a].add(b);
			edges[b].add(a);
		}

		arr = new int[n];
		idxOf = new int[n];
		for(int i = 0; i < n; ++i) {
			arr[i] = sc.nextInt() - 1;
			idxOf[arr[i]] = i;
		}

		seen = new boolean[n];
		ad = new ArrayDeque<>();

		seen[0] = true;
		ad.add(0);

		for(int i = 0; i < n; ++i) {
			int curr = ad.poll();
			if(curr != arr[i]) {
				System.out.println("No");
				return;
			}

			ArrayList<Integer> addIdxs = new ArrayList<>();
			for(int next : edges[curr]) {
				if(!seen[next]) {
					seen[next] = true;
					addIdxs.add(idxOf[next]);
				}
			}

			Collections.sort(addIdxs);
			for(int idx : addIdxs) ad.add(arr[idx]);
		}

		System.out.println("Yes");
	}

}


import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	public static void main(String sp[])throws IOException{
		Scanner sc = new Scanner(System.in);
		//FastReader sc = new FastReader();
		int n = sc.nextInt();
		ArrayList<Integer> arr[] = new ArrayList[n+1];
		for(int i=1;i<=n;i++){
			arr[i] = new ArrayList<Integer>();
		}
		for(int i=1;i<n;i++){
			int u = sc.nextInt();
			int v = sc.nextInt();
			arr[u].add(v);
			arr[v].add(u);
		}
		int seq[] = new int[n+1];
		for(int i=1;i<=n;i++){
			seq[i] = sc.nextInt();
		}
		HashMap<Integer,Integer> visited = new  HashMap<>();

		if(seq[1]!=1){
			System.out.println("No");
			return;
		}
		int chk = 2;
		LinkedList<Integer> ll = new LinkedList<>();
		ll.addLast(1);
		visited.put(1,0);
		while(ll.size()!=0){
			int pop = ll.removeFirst();
			ArrayList<Integer> al = arr[pop];
			int len = al.size();
			int o = 0;
			for(int i=0;i<len;i++){
				int ind = al.get(i);
				if(!visited.containsKey(ind)){
					o++;
					visited.put(ind,0);
				}
			}
			int u = chk;
			for(int i=0;i<o;i++){
				if(!visited.containsKey(seq[chk])){
					System.out.println("No");
					return;
				}
				chk++;
			}
			for(int i=0;i<o;i++){
				ll.addLast(seq[u]);
				u++;
			}
		}
		System.out.println("Yes");

	}

	public static class pair{
		long bal;
		long wt;
		long diff;
	}

	public static class comp implements Comparator<pair>{
		public int compare(pair o1, pair o2){
			return Long.valueOf(o1.diff).compareTo(Long.valueOf(o2.diff));
		}
	}

	static class FastReader
		{
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public FastReader()
		{
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public FastReader(String file_name) throws IOException
		{
			din = new DataInputStream(new FileInputStream(file_name));
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public String readLine() throws IOException
		{
			byte[] buf = new byte[64]; // line length
			int cnt = 0, c;
			while ((c = read()) != -1)
			{
				if (c == '\n')
					break;
				buf[cnt++] = (byte) c;
			}
			return new String(buf, 0, cnt);
		}

		public int nextInt() throws IOException
		{
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do
			{
				ret = ret * 10 + c - '0';
			}  while ((c = read()) >= '0' && c <= '9');

			if (neg)
				return -ret;
			return ret;
		}

		public long nextLong() throws IOException
		{
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			}
			while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public double nextDouble() throws IOException
		{
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();

			do {
				ret = ret * 10 + c - '0';
			}
			while ((c = read()) >= '0' && c <= '9');

			if (c == '.')
			{
				while ((c = read()) >= '0' && c <= '9')
				{
					ret += (c - '0') / (div *= 10);
				}
			}

			if (neg)
				return -ret;
			return ret;
		}

		private void fillBuffer() throws IOException
		{
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException
		{
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}

		public void close() throws IOException
		{
			if (din == null)
				return;
			din.close();
		}
	}
}


import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	public static void main(String sp[])throws IOException{
		Scanner sc = new Scanner(System.in);
		//FastReader sc = new FastReader();
		int n = sc.nextInt();
		ArrayList<Integer> arr[] = new ArrayList[n+1];
		for(int i=1;i<=n;i++){
			arr[i] = new ArrayList<Integer>();
		}
		for(int i=1;i<n;i++){
			int u = sc.nextInt();
			int v = sc.nextInt();
			arr[u].add(v);
			arr[v].add(u);
		}
		int seq[] = new int[n+1];
		for(int i=1;i<=n;i++){
			seq[i] = sc.nextInt();
		}
		HashMap<Integer,Integer> visited = new  HashMap<>();

		if(seq[1]!=1){
			System.out.println("No");
			return;
		}
		int chk = 2;
		LinkedList<Integer> ll = new LinkedList<>();
		ll.addLast(1);
		visited.put(1,0);
		while(ll.size()!=0){
			int pop = ll.removeFirst();
			ArrayList<Integer> al = arr[pop];
			int len = al.size();
			int o = 0;
			for(int i=0;i<len;i++){
				int ind = al.get(i);
				if(!visited.containsKey(ind)){
					o++;
					visited.put(ind,0);
					ll.addLast(ind);
				}
			}
			for(int i=0;i<o;i++){
				if(!visited.containsKey(seq[chk])){
					System.out.println("No");
					return;
				}
				chk++;
			}
		}
		System.out.println("Yes");

	}

	public static class pair{
		long bal;
		long wt;
		long diff;
	}

	public static class comp implements Comparator<pair>{
		public int compare(pair o1, pair o2){
			return Long.valueOf(o1.diff).compareTo(Long.valueOf(o2.diff));
		}
	}

	static class FastReader
		{
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public FastReader()
		{
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public FastReader(String file_name) throws IOException
		{
			din = new DataInputStream(new FileInputStream(file_name));
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public String readLine() throws IOException
		{
			byte[] buf = new byte[64]; // line length
			int cnt = 0, c;
			while ((c = read()) != -1)
			{
				if (c == '\n')
					break;
				buf[cnt++] = (byte) c;
			}
			return new String(buf, 0, cnt);
		}

		public int nextInt() throws IOException
		{
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do
			{
				ret = ret * 10 + c - '0';
			}  while ((c = read()) >= '0' && c <= '9');

			if (neg)
				return -ret;
			return ret;
		}

		public long nextLong() throws IOException
		{
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			}
			while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public double nextDouble() throws IOException
		{
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();

			do {
				ret = ret * 10 + c - '0';
			}
			while ((c = read()) >= '0' && c <= '9');

			if (c == '.')
			{
				while ((c = read()) >= '0' && c <= '9')
				{
					ret += (c - '0') / (div *= 10);
				}
			}

			if (neg)
				return -ret;
			return ret;
		}

		private void fillBuffer() throws IOException
		{
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException
		{
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}

		public void close() throws IOException
		{
			if (din == null)
				return;
			din.close();
		}
	}
}


import java.util.*;
public class BFSforBFSbutgood {

	public static void main(String[] args) {
		Scanner msc = new Scanner(System.in);
		int numNodes = msc.nextInt();
		int numEdges = numNodes - 1;
		int start = 0;
		int[] BFS = new int[numNodes];
		int[] ripHashyMap = new int[numNodes];
		ArrayList<Integer> answer = new ArrayList<Integer>();

		ArrayDeque<Integer>[] neighbors = new ArrayDeque[numNodes];
		for(int i = 0; i < numNodes; i++) {
			neighbors[i] = new ArrayDeque<>();
		}

		for(int i = 0; i < numEdges; i++) {
			int a = msc.nextInt() - 1, b = msc.nextInt() - 1;
			neighbors[a].add(b);
			neighbors[b].add(a);
		}
		for(int i = 0 ; i < numNodes ; i++){
			BFS[i] = msc.nextInt() - 1;
			ripHashyMap[BFS[i]] = i;
		}

		boolean[] seen = new boolean[numNodes];
		ArrayDeque<Integer> exploreList = new ArrayDeque<>();

		seen[start] = true;
		exploreList.add(start);

		while(!exploreList.isEmpty()) {
			ArrayList<Integer> list = new ArrayList<Integer>();
			int currNode = exploreList.poll();
			answer.add(currNode);
			// explore currNode's neighbors
			for(int nextNode : neighbors[currNode]) {
				if(!seen[nextNode]) {
					seen[nextNode] = true;
					list.add(ripHashyMap[nextNode]);
				}
			}
			Collections.sort(list);
			for(int i = 0 ; i < list.size() ; i++){
				list.set(i, BFS[list.get(i)]);
			}
			exploreList.addAll(list);
		}
		boolean flag = false;
		for(int i = 0 ; i < numNodes ; i++){
			if(BFS[i] != answer.get(i)){
				flag = true;
			}
		}
		if(flag){
			System.out.println("NO");
		}
		else {
			System.out.println("YES");
		}
	}

}

/*
6
1 2
2 3
1 4
4 5
1 6
1 4 2 6 3 5
*/


public class rgen {

	public static void main(String[] args) {

		if(Math.random() >= 0.5){
			System.out.println("NO");
		}
		else {
			System.out.println("YES");
		}

	}

}


public class rgen {

	public static void main(String[] args) {

		if(Math.random() >= 0.5){
			System.out.println("NO");
		}
		else {
			System.out.println("YES");
		}
		//stinky
	}

}


import java.util.*;

public class BFSforBFS {

	public static void main(String[] args) {
		Scanner msc = new Scanner(System.in);
		int numNodes = msc.nextInt();
		int numEdges = numNodes - 1;
		int start = 0;
		int[] BFS = new int[numNodes];
		int[] answer = new int[numNodes];

		ArrayDeque<Integer>[] neighbors = new ArrayDeque[numNodes];
		for(int i = 0; i < numNodes; i++) {
			neighbors[i] = new ArrayDeque<>();
		}

		for(int i = 0; i < numEdges; i++) {
			int a = msc.nextInt() - 1, b = msc.nextInt() - 1;
			neighbors[a].add(b);
			neighbors[b].add(a);
		}
		for(int i = 0 ; i < numNodes ; i++){
			BFS[i] = msc.nextInt() - 1;
		}

		boolean[] seen = new boolean[numNodes];
		int[] distFromStart = new int[numNodes];
		ArrayDeque<Integer> exploreList = new ArrayDeque<>();

		seen[start] = true;
		distFromStart[start] = 0;
		exploreList.add(start);

		while(!exploreList.isEmpty()) {
			int currNode = exploreList.poll();

			// explore currNode's neighbors
			for(int nextNode : neighbors[currNode]) {
				if(!seen[nextNode]) {
					seen[nextNode] = true;
					distFromStart[nextNode] = distFromStart[currNode] + 1;
					exploreList.add(nextNode);
				}
			}
		}

		for(int i = 0 ; i < numNodes ; i++){
			answer[i] = distFromStart[BFS[i]];
		}
		boolean flag = false;
		int tempBigInt = -1;
		for(int i = 0 ; i < numNodes ; i++){
			if(answer[i] < tempBigInt){
				flag = true;
			}
			else {
				tempBigInt = answer[i];
			}
		}
		if(flag){
			System.out.println("NO");
		}
		else {
			System.out.println("YES");
		}

	}

}


public class rgen {

	public static void main(String[] args) {

		if(Math.random() >= 0.5){
			System.out.println("NO");
		}
		else {
			System.out.println("YES");
		}
		//stinkys
	}

}


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

public class File {

	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					e.printStackTrace();
				}
			}

			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

		int n = sc.nextInt();
		Map<Integer, List<Integer>> graph = new HashMap<>();

		for (int i = 0; i < n-1; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();

			if (!graph.containsKey(x)) {
				graph.put(x, new ArrayList<>());
			}
			if (!graph.containsKey(y)) {
				graph.put(y, new ArrayList<>());
			}

			graph.get(x).add(y);
			graph.get(y).add(x);
		}

		int[] seq = new int[n];
		for (int i = 0; i < n; i++) {
			seq[i] = sc.nextInt();
		}

		// Do a BFS. Store nodes by level, in a set.
		// Iterate over the sequence by the nodes in that level.
		// If one mismatch, then not valid.
		List<Set<Integer>> levels = new ArrayList<>();
		Set<Integer> set = new HashSet<>(); // Processed nodes.

		LinkedList<Integer> queue = new LinkedList<>();
		queue.add(1);
		set.add(1);

		while (!queue.isEmpty()) {
			Set<Integer> currLevel = new HashSet<>();

			for (int k = queue.size(); k > 0; k--) {
				int curr = queue.removeFirst();
				currLevel.add(curr);

				for (int next : graph.get(curr)) {
					if (!set.contains(next)) {
						set.add(next);
						queue.addLast(next);
					}
				}
			}

			levels.add(currLevel);
		}

		int index = 0;

		for (int i = 0; i < levels.size(); i++) {
			Set<Integer> level = levels.get(i);
			int N = level.size();

			for (int c = 0; c < N; c++) {
				if (!level.contains(seq[index])) {
					out.println("No");
					out.close();
					return;
				}

				index++;
			}
		}

		out.println("Yes");
		out.close();
	}
}


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

public class File {

	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					e.printStackTrace();
				}
			}

			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

		int n = sc.nextInt();
		Map<Integer, Set<Integer>> graph = new HashMap<>();

		for (int i = 0; i < n-1; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();

			if (!graph.containsKey(x)) {
				graph.put(x, new HashSet<>());
			}
			if (!graph.containsKey(y)) {
				graph.put(y, new HashSet<>());
			}

			graph.get(x).add(y);
			graph.get(y).add(x);
		}

		int[] seq = new int[n];
		for (int i = 0; i < n; i++) {
			seq[i] = sc.nextInt();
		}

		if (seq[0] != 1) {
			out.println("No");
			out.close();
			return;
		}

		LinkedList<Integer> queue = new LinkedList<>();
		Set<Integer> visited = new HashSet<>();

		queue.add(1);
		visited.add(1);
		int index = 1;

		while (!queue.isEmpty()) {
			for (int k = queue.size(); k > 0; k--) {
				int curr = queue.removeFirst();

				Set<Integer> children = graph.get(curr);
				children.removeAll(visited);
				int N = children.size();

				// Ensure that the next N nodes in the ordering are in this node's children.
				// As we check, we also add them to the queue in the order.
				for (int l = 0; l < N; l++) {
				    if (index < n) {
    					int next = seq[index];

    					if (visited.contains(next)) continue;

    					if (!children.contains(next)) {
    						out.println("No");
    						out.close();
    						return;
    					}
    					else {
    						queue.addLast(next);
    						visited.add(next);
    						children.remove(next);
    						index++;
    					}
				    }
				}
			}
		}

		if (index < n) {
			out.println("No");
		}
		else {
			out.println("Yes");
		}

		out.close();
	}
}


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

public class File {

	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					e.printStackTrace();
				}
			}

			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

		int n = sc.nextInt();
		Map<Integer, Set<Integer>> graph = new HashMap<>();

		for (int i = 0; i < n-1; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();

			if (!graph.containsKey(x)) {
				graph.put(x, new HashSet<>());
			}
			if (!graph.containsKey(y)) {
				graph.put(y, new HashSet<>());
			}

			graph.get(x).add(y);
			graph.get(y).add(x);
		}

		int[] seq = new int[n];
		for (int i = 0; i < n; i++) {
			seq[i] = sc.nextInt();
		}

		if (seq[0] != 1) {
			out.println("No");
			out.close();
			return;
		}

		LinkedList<Integer> queue = new LinkedList<>();
		Set<Integer> visited = new HashSet<>();

		queue.add(1);
		visited.add(1);
		int index = 1;

		while (!queue.isEmpty()) {
			for (int k = queue.size(); k > 0; k--) {
				int curr = queue.removeFirst();

				Set<Integer> children = graph.getOrDefault(curr, new HashSet<>());
				children.removeAll(visited);
				int N = children.size();

				// Ensure that the next N nodes in the ordering are in this node's children.
				// As we check, we also add them to the queue in the order.
				for (int l = 0; l < N; l++) {
				    if (index < n) {
    					int next = seq[index];

    					if (visited.contains(next)) continue;

    					if (!children.contains(next)) {
    						out.println("No");
    						out.close();
    						return;
    					}
    					else {
    						queue.addLast(next);
    						visited.add(next);
    						children.remove(next);
    						index++;
    					}
				    }
				}
			}
		}

		if (index < n) {
			out.println("No");
		}
		else {
			out.println("Yes");
		}

		out.close();
	}
}


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

public class File {

	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					e.printStackTrace();
				}
			}

			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

		int n = sc.nextInt();
		Map<Integer, Set<Integer>> graph = new HashMap<>();

		for (int i = 0; i < n-1; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();

			if (!graph.containsKey(x)) {
				graph.put(x, new HashSet<>());
			}
			if (!graph.containsKey(y)) {
				graph.put(y, new HashSet<>());
			}

			graph.get(x).add(y);
			graph.get(y).add(x);
		}

		int[] seq = new int[n];
		for (int i = 0; i < n; i++) {
			seq[i] = sc.nextInt();
		}

		if (seq[0] != 1) {
			out.println("No");
			out.close();
			return;
		}

		LinkedList<Integer> queue = new LinkedList<>();
		Set<Integer> visited = new HashSet<>();

		queue.add(1);
		visited.add(1);
		int index = 1;

		while (!queue.isEmpty()) {
			for (int k = queue.size(); k > 0; k--) {
				int curr = queue.removeFirst();

				Set<Integer> children = graph.get(curr);
				int N = children.size();

				// Ensure that the next N nodes in the ordering are in this node's children.
				// As we check, we also add them to the queue in the order.
				for (int l = 0; l < N; l++) {
				    if (index < n) {
    					int next = seq[index];

    					if (visited.contains(next)) continue;

    					if (!children.contains(next)) {
    						out.println("No");
    						out.close();
    						return;
    					}
    					else {
    						queue.addLast(next);
    						visited.add(next);
    						children.remove(next);
    						index++;
    					}
				    }
				}
			}
		}

		if (index < n) {
			out.println("No");
		}
		else {
			out.println("Yes");
		}

		out.close();
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;

public class ValidBfs {
    public static void main(final String[] args) {
        final var fr = new FastReader();
        final int n = fr.nextInt();
        final var enumeration = new HashMap<Integer, Integer>(n);
        final var sequence = new ArrayList<Integer> (n);
        final var graph = new HashMap<Integer, ArrayList<Integer>>();

        for (int i = 0; i < n - 1; i++) {
            addEdge(graph, fr.nextInt(), fr.nextInt());
        }

        for(int i = 0; i < n; i++) {
            int a = fr.nextInt();
            sequence.add(a);
            enumeration.put(a, i);
        }

        for(var entry : graph.entrySet()) {
            Collections.sort(entry.getValue(), (a, b) -> {
                return enumeration.get(a) < enumeration.get(b) ? -1 : 1;
            });
        }
        var solver = new Solution();
        var resultSequence = solver.bfs(1, graph);
        final String ans = resultSequence.equals(sequence) ? "Yes" : "No";
        System.out.println(ans);
    }

    static void addEdge(HashMap<Integer, ArrayList<Integer>> graph, final int a, final int b) {
        if(!graph.containsKey(a))  {
            graph.put(a, new ArrayList<Integer>());
        }
        if(!graph.containsKey(b)) {
            graph.put(b, new ArrayList<Integer>());
        }
        graph.get(a).add(b);
        graph.get(b).add(a);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (final IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (final IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}

class Solution {
    List<Integer> bfs(int start, HashMap<Integer, ArrayList<Integer>> graph) {
        var ans = new ArrayList<Integer>();
        var queue = new LinkedList<Integer>();
        var visited = new HashSet<Integer>();
        queue.addFirst(start);
        visited.add(start);
        while (queue.size() > 0) {
            var node = queue.removeLast();
            ans.add(node);
            for(var entry : graph.get(node)) {
                if(!visited.contains(entry)) {
                    visited.add(entry);
                    queue.addFirst(entry);
                }
            }
        }
        return ans;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;

public class ValidBfs {
    public static void main(final String[] args) {
        final var fr = new FastReader();
        final int n = fr.nextInt();
        final var enumeration = new HashMap<Integer, Integer>(n);
        final var sequence = new ArrayList<Integer> (n);
        final var graph = new HashMap<Integer, ArrayList<Integer>>();

        for (int i = 0; i < n - 1; i++) {
            addEdge(graph, fr.nextInt(), fr.nextInt());
        }

        for(int i = 0; i < n; i++) {
            int a = fr.nextInt();
            sequence.add(a);
            enumeration.put(a, i);
        }

        for(var entry : graph.entrySet()) {
            Collections.sort(entry.getValue(), (a, b) -> {
                return enumeration.get(a) < enumeration.get(b) ? -1 : 1;
            });
        }
        var solver = new Solution();
        var resultSequence = solver.bfs(1, graph);
        final String ans = resultSequence.equals(sequence) ? "Yes" : "No";
        System.out.println(ans);
    }

    static void addEdge(HashMap<Integer, ArrayList<Integer>> graph, final int a, final int b) {
        if(!graph.containsKey(a))  {
            graph.put(a, new ArrayList<Integer>());
        }
        if(!graph.containsKey(b)) {
            graph.put(b, new ArrayList<Integer>());
        }
        graph.get(a).add(b);
        graph.get(b).add(a);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (final IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (final IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}

class Solution {
    List<Integer> bfs(int start, HashMap<Integer, ArrayList<Integer>> graph) {
        var ans = new ArrayList<Integer>();
        var queue = new LinkedList<Integer>();
        var visited = new HashSet<Integer>();
        queue.addFirst(start);
        visited.add(start);
        while (queue.size() > 0) {
            var node = queue.removeLast();
            ans.add(node);
            var neighbours = graph.get(node);
            if(neighbours != null) {
                for(var entry : neighbours) {
                    if(!visited.contains(entry)) {
                        visited.add(entry);
                        queue.addFirst(entry);
                    }
                }
            }
        }
        return ans;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class ValidBFS {
    static int MAX = (int)1e5 + 5;
    static ArrayList<Integer>[] adj = new ArrayList[MAX];
    static boolean[] visited = new boolean[MAX];
    static int[] inputSequence = new int[MAX];

    static class Pair{
        int min, max;
        public Pair(int x, int y){
            min = x;
            max = y;
        }
    }

    static boolean isPermutation(ArrayList<Integer> sequence, int index){
        HashMap<Integer, Boolean> map = new HashMap<>();
        for(int ele: sequence){
            map.put(ele, true);
        }
        for(int i=index; i<index + sequence.size(); ++i){
            if(!map.containsKey(inputSequence[i])){
                return false;
            }
        }
        return true;
    }

    static boolean isValid(int n){
        LinkedList<Integer> queue = new LinkedList<>();
        queue.add(1);
        ArrayList<Integer> sequence = new ArrayList<>();
        int i = 1;
        while(queue.size() != 0){
            int node = queue.pop();
            visited[node] = true;
            ArrayList<Integer> neighbors = adj[node];
            for(int neighbor: neighbors){
                if(!visited[neighbor]){
                    sequence.add(neighbor);
                }
            }
            if(!isPermutation(sequence, i)){
                return false;
            }
            for(int j=i; j<i + sequence.size(); ++j){
                queue.add(inputSequence[j]);
            }
            i += sequence.size();
            sequence.clear();
        }
        return true;
    }

    public static void main(String[] args) {
        Utility.FastReader fr = new Utility.FastReader();
        for(int i=0; i<MAX; ++i){
            adj[i] = new ArrayList<>();
        }
        int n = fr.nextInt();
        int u, v;
        for(int i=0; i<n-1; ++i){
            u = fr.nextInt();
            v = fr.nextInt();
            adj[u].add(v);
            adj[v].add(u);
        }
        for(int i=0; i<n; ++i){
            inputSequence[i] = fr.nextInt();
        }
        boolean result = isValid(n);
        if(result){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }

    static class Utility {
        static class FastReader {
            BufferedReader br;
            StringTokenizer st;

            public FastReader() {
                br = new BufferedReader(new
                        InputStreamReader(System.in));
            }

            String next() {
                while (st == null || !st.hasMoreElements()) {
                    try {
                        st = new StringTokenizer(br.readLine());
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
                return st.nextToken();
            }

            int nextInt() {
                return Integer.parseInt(next());
            }

            long nextLong() {
                return Long.parseLong(next());
            }

            double nextDouble() {
                return Double.parseDouble(next());
            }

            String nextLine() {
                String str = "";
                try {
                    str = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                return str;
            }
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class ValidBFS {
    static int MAX = (int)1e5 + 5;
    static ArrayList<Integer>[] adj = new ArrayList[MAX];
    static boolean[] visited = new boolean[MAX];
    static int[] inputSequence = new int[MAX];

    static class Pair{
        int min, max;
        public Pair(int x, int y){
            min = x;
            max = y;
        }
    }
    static boolean isValid(int n){
        LinkedList<Integer> queue = new LinkedList<>();
        ArrayList<Integer> arr = new ArrayList<>();
        ArrayList<Integer> sequence = new ArrayList<>();
        arr.add(1);
        HashMap<Integer, Pair> map = new HashMap<>();
        queue.add(1);
        int currentCount = 0, previousCount = 1, bfsCount = 0;
        while(queue.size() != 0){
            int node = queue.pop();
            visited[node] = true;
            sequence.add(node);
            ArrayList<Integer> neighbors = adj[node];
            for(int neighbor: neighbors){
                if(!visited[neighbor]){
                    queue.add(neighbor);
                    bfsCount++;
                }
            }
            currentCount++;
            if(currentCount == previousCount){
                previousCount = bfsCount;
                arr.add(bfsCount);
                currentCount = 0;
                bfsCount = 0;
            }
        }
        int prefixSum = 0;
        for(int i=0; i<arr.size(); ++i){
            for(int j=prefixSum; j<prefixSum + arr.get(i); ++j){
                int element = sequence.get(j);
                map.put(element, new Pair(prefixSum, prefixSum + arr.get(i) - 1));
            }
            prefixSum += arr.get(i);
        }
        for(int i=0; i<n; ++i){
            int element = inputSequence[i];
            Pair p = map.get(element);
            if(i < p.min || i > p.max){
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        Utility.FastReader fr = new Utility.FastReader();
        for(int i=0; i<MAX; ++i){
            adj[i] = new ArrayList<>();
        }
        int n = fr.nextInt();
        int u, v;
        for(int i=0; i<n-1; ++i){
            u = fr.nextInt();
            v = fr.nextInt();
            adj[u].add(v);
            adj[v].add(u);
        }
        for(int i=0; i<n; ++i){
            inputSequence[i] = fr.nextInt();
        }
        boolean result = isValid(n);
        if(result){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }

    static class Utility {
        static class FastReader {
            BufferedReader br;
            StringTokenizer st;

            public FastReader() {
                br = new BufferedReader(new
                        InputStreamReader(System.in));
            }

            String next() {
                while (st == null || !st.hasMoreElements()) {
                    try {
                        st = new StringTokenizer(br.readLine());
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
                return st.nextToken();
            }

            int nextInt() {
                return Integer.parseInt(next());
            }

            long nextLong() {
                return Long.parseLong(next());
            }

            double nextDouble() {
                return Double.parseDouble(next());
            }

            String nextLine() {
                String str = "";
                try {
                    str = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                return str;
            }
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class ValidBFS {
    static int MAX = (int)2e5 + 5;
    static ArrayList<Integer>[] adj = new ArrayList[MAX];
    static boolean[] visited = new boolean[MAX];
    static int[] inputSequence = new int[MAX];

    static class Pair{
        int min, max;
        public Pair(int x, int y){
            min = x;
            max = y;
        }
    }

    static boolean isPermutation(ArrayList<Integer> sequence, int index){
        HashMap<Integer, Boolean> map = new HashMap<>();
        for(int ele: sequence){
            map.put(ele, true);
        }
        for(int i=index; i<index + sequence.size(); ++i){
            if(!map.containsKey(inputSequence[i])){
                return false;
            }
        }
        return true;
    }

    static boolean isValid(int n){
        LinkedList<Integer> queue = new LinkedList<>();
        queue.add(1);
        ArrayList<Integer> sequence = new ArrayList<>();
        int i = 1;
        while(queue.size() != 0){
            int node = queue.pop();
            visited[node] = true;
            ArrayList<Integer> neighbors = adj[node];
            for(int neighbor: neighbors){
                if(!visited[neighbor]){
                    sequence.add(neighbor);
                }
            }
            if(!isPermutation(sequence, i)){
                return false;
            }
            for(int j=i; j<i + sequence.size(); ++j){
                queue.add(inputSequence[j]);
            }
            i += sequence.size();
            sequence.clear();
        }
        return true;
    }

    public static void main(String[] args) {
        Utility.FastReader fr = new Utility.FastReader();
        for(int i=0; i<MAX; ++i){
            adj[i] = new ArrayList<>();
        }
        int n = fr.nextInt();
        int u, v;
        for(int i=0; i<n-1; ++i){
            u = fr.nextInt();
            v = fr.nextInt();
            adj[u].add(v);
            adj[v].add(u);
        }
        for(int i=0; i<n; ++i){
            inputSequence[i] = fr.nextInt();
        }
        boolean result = isValid(n);
        if(result){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }

    static class Utility {
        static class FastReader {
            BufferedReader br;
            StringTokenizer st;

            public FastReader() {
                br = new BufferedReader(new
                        InputStreamReader(System.in));
            }

            String next() {
                while (st == null || !st.hasMoreElements()) {
                    try {
                        st = new StringTokenizer(br.readLine());
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
                return st.nextToken();
            }

            int nextInt() {
                return Integer.parseInt(next());
            }

            long nextLong() {
                return Long.parseLong(next());
            }

            double nextDouble() {
                return Double.parseDouble(next());
            }

            String nextLine() {
                String str = "";
                try {
                    str = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                return str;
            }
        }
    }
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<vector>
#include<map>
#include<functional>

#define fst first
#define sc second
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1
#define lc root<<1
#define rc root<<1|1
#define lowbit(x) ((x)&(-x))

using namespace std;

typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PLL;

const db eps = 1e-6;
const int mod = 1e9+7;
const int maxn = 2e5+100;
const int maxm = 2e6+100;
const int inf = 0x3f3f3f3f;
const db pi = acos(-1.0);

struct Edge{
    int next;
    int to;
};
Edge edge[maxn];
int n, m, cnt;
int head[maxn];
void Add(int u, int v){
    edge[++cnt].next=head[u];
    edge[cnt].to=v;
    head[u]=cnt;
}

int ans[maxn];
queue<int>q;
int h[maxn];
int main(){
    int n;
    scanf("%d", &n);
    mem(head,-1);
    mem(h,-1);
    cnt=0;
    for(int i = 1; i <= n-1; i++){
        int x, y;
        scanf("%d %d", &x, &y);
        Add(x,y);Add(y,x);
    }
    for(int i = 1; i <= n; i++){
        scanf("%d", &ans[i]);
    }
    q.push(ans[1]);
    h[ans[1]]=1;
    while(!q.empty()){
        int x = q.front();
        q.pop();
        for(int i = head[x]; i!=-1 ; i = edge[i].next){
            int y = edge[i].to;
            if(h[y]==-1){h[y]=h[x]+1;q.push(y);}
        }

    }
    for(int i = 1; i < n; i++){

        if(h[ans[i]]>h[ans[i+1]]){
            printf("No");return 0;
        }
    }
    printf("Yes");
    return 0;
}
/*
2
1 1 1 2 2 2
2 2 2 1 1 1
 */


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<vector>
#include<map>
#include<functional>

#define fst first
#define sc second
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1
#define lc root<<1
#define rc root<<1|1
#define lowbit(x) ((x)&(-x))

using namespace std;

typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PLL;

const db eps = 1e-6;
const int mod = 1e9+7;//
const int maxn = 2e5+100;
const int maxm = 2e6+100;
const int inf = 0x3f3f3f3f;
const db pi = acos(-1.0);

int n, m, cnt;

int ans[maxn];
queue<int>q;
map<int,int>ma[maxn];
int main(){
    int n;
    scanf("%d", &n);
    mem(head,-1);
    mem(h,-1);
    cnt=0;
    for(int i = 1; i <= n-1; i++){
        int x, y;
        scanf("%d %d", &x, &y);
        //Add(x,y);Add(y,x);
        ma[x][y]=1;ma[y][x]=1;//logn
    }
    for(int i = 1; i <= n; i++){
        scanf("%d", &ans[i]);
    }
    q.push(ans[1]);
    int id = 2;
    while(!q.empty()){
        int x = q.front();
        q.pop();
        if(ma[x][ans[id]]){//logn
            q.push(ans[id]);
            id++;
        }
    }
    if(ans[1]!=1)id=-1;
    if(id==n+1)return printf("Yes"),0;printf("No");
    return 0;
}
/*
2
1 1 1 2 2 2
2 2 2 1 1 1
 */


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<vector>
#include<map>
#include<functional>

#define fst first
#define sc second
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1
#define lc root<<1
#define rc root<<1|1
#define lowbit(x) ((x)&(-x))

using namespace std;

typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PLL;

const db eps = 1e-6;
const int mod = 1e9+7;
const int maxn = 2e5+100;
const int maxm = 2e6+100;
const int inf = 0x3f3f3f3f;
const db pi = acos(-1.0);

int n, m, cnt;

int ans[maxn];
queue<int>q;
map<int,int>ma[maxn];
int main(){
    int n;
    scanf("%d", &n);
    cnt=0;
    for(int i = 1; i <= n-1; i++){
        int x, y;
        scanf("%d %d", &x, &y);
        //Add(x,y);Add(y,x);
        ma[x][y]=1;ma[y][x]=1;//logn
    }
    for(int i = 1; i <= n; i++){
        scanf("%d", &ans[i]);
    }
    q.push(ans[1]);
    int id = 2;
    while(!q.empty()){
        int x = q.front();
        q.pop();
        if(ma[x][ans[id]]){//logn
            q.push(ans[id]);
            id++;
        }
    }
    if(ans[1]!=1)id=-1;
    if(id==n+1)return printf("Yes"),0;printf("No");
    return 0;
}
/*
2
1 1 1 2 2 2
2 2 2 1 1 1
 */


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<vector>
#include<map>
#include<functional>

#define fst first
#define sc second
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1
#define lc root<<1
#define rc root<<1|1
#define lowbit(x) ((x)&(-x))

using namespace std;

typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PLL;

const db eps = 1e-6;
const int mod = 1e9+7;
const int maxn = 2e5+100;
const int maxm = 2e6+100;
const int inf = 0x3f3f3f3f;
const db pi = acos(-1.0);

struct Edge{
    int next;
    int to;
};
Edge edge[maxn];
int n, m, cnt;
int head[maxn];
void Add(int u, int v){
    edge[++cnt].next=head[u];
    edge[cnt].to=v;
    head[u]=cnt;
}

int ans[maxn];
queue<int>q;
int h[maxn];
int f[maxn];
int vis[maxn];
map<int,int>ma[maxn];
int main(){
    int n;
    scanf("%d", &n);
    mem(head,-1);
    mem(h,-1);
    cnt=0;
    for(int i = 1; i <= n-1; i++){
        int x, y;
        scanf("%d %d", &x, &y);
        //Add(x,y);Add(y,x);
        ma[x][y]=1;ma[y][x]=1;//logn
    }
    for(int i = 1; i <= n; i++){
        scanf("%d", &ans[i]);
    }
    q.push(ans[1]);
    int id = 2;
    while(!q.empty()){
        int x = q.front();
        q.pop();
        while(ma[x][ans[id]]){
            q.push(ans[id]);
            id++;
        }
    }

    if(id==n+1)return printf("Yes"),0;printf("No");
    return 0;
}
/*
2
1 1 1 2 2 2
2 2 2 1 1 1
 */


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<vector>
#include<map>
#include<functional>

#define fst first
#define sc second
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1
#define lc root<<1
#define rc root<<1|1
#define lowbit(x) ((x)&(-x))

using namespace std;

typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PLL;

const db eps = 1e-6;
const int mod = 1e9+7;
const int maxn = 2e5+100;
const int maxm = 2e6+100;
const int inf = 0x3f3f3f3f;
const db pi = acos(-1.0);

int n, m, cnt;

int ans[maxn];
queue<int>q;
map<int,int>ma[maxn];
int main(){
    int n;
    scanf("%d", &n);
    mem(head,-1);
    mem(h,-1);
    cnt=0;
    for(int i = 1; i <= n-1; i++){
        int x, y;
        scanf("%d %d", &x, &y);
        //Add(x,y);Add(y,x);
        ma[x][y]=1;ma[y][x]=1;//logn
    }
    for(int i = 1; i <= n; i++){
        scanf("%d", &ans[i]);
    }
    q.push(ans[1]);
    int id = 2;
    while(!q.empty()){
        int x = q.front();
        q.pop();
        if(ma[x][ans[id]]){//logn
            q.push(ans[id]);
            id++;
        }
    }
    if(ans[1]!=1)id=-1;
    if(id==n+1)return printf("Yes"),0;printf("No");
    return 0;
}
/*
2
1 1 1 2 2 2
2 2 2 1 1 1
 */


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<vector>
#include<map>
#include<functional>

#define fst first
#define sc second
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1
#define lc root<<1
#define rc root<<1|1
#define lowbit(x) ((x)&(-x))

using namespace std;

typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PLL;

const db eps = 1e-6;
const int mod = 1e9+7;
const int maxn = 2e5+100;
const int maxm = 2e6+100;
const int inf = 0x3f3f3f3f;
const db pi = acos(-1.0);

struct Edge{
    int next;
    int to;
};
Edge edge[maxn];
int n, m, cnt;
int head[maxn];
void Add(int u, int v){
    edge[++cnt].next=head[u];
    edge[cnt].to=v;
    head[u]=cnt;
}

int ans[maxn];
queue<int>q;
int h[maxn];
int f[maxn];
int vis[maxn];
map<int,int>ma[maxn];
int main(){
    int n;
    scanf("%d", &n);
    mem(head,-1);
    mem(h,-1);
    cnt=0;
    for(int i = 1; i <= n-1; i++){
        int x, y;
        scanf("%d %d", &x, &y);
        //Add(x,y);Add(y,x);
        ma[x][y]=1;ma[y][x]=1;//logn
    }
    for(int i = 1; i <= n; i++){
        scanf("%d", &ans[i]);
    }
    q.push(ans[1]);
    int id = 2;
    while(!q.empty()){
        int x = q.front();
        q.pop();
        while(ma[x][ans[id]]){//logn
            q.push(ans[id]);
            id++;
        }
    }
    if(ans[1]!=1)id=-1;
    if(id==n+1)return printf("Yes"),0;printf("No");
    return 0;
}
/*
2
1 1 1 2 2 2
2 2 2 1 1 1
 */


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<vector>
#include<map>
#include<functional>

#define fst first
#define sc second
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1
#define lc root<<1
#define rc root<<1|1
#define lowbit(x) ((x)&(-x))

using namespace std;

typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PLL;

const db eps = 1e-6;
const int mod = 1e9+7;
const int maxn = 2e5+100;
const int maxm = 2e6+100;
const int inf = 0x3f3f3f3f;
const db pi = acos(-1.0);

struct Edge{
    int next;
    int to;
};
Edge edge[maxn];
int n, m, cnt;
int head[maxn];
void Add(int u, int v){
    edge[++cnt].next=head[u];
    edge[cnt].to=v;
    head[u]=cnt;
}

int ans[maxn];
queue<int>q;
int h[maxn];
int f[maxn];
void dfs(int x, int fa){
    f[x]=fa;
    for(int i = head[x]; i != -1; i=edge[i].next){
        int y = edge[i].to;
        if(y!=fa)dfs(y,x);
    }
    return;
}
int vis[maxn];
int main(){
    int n;
    scanf("%d", &n);
    mem(head,-1);
    mem(h,-1);
    cnt=0;
    for(int i = 1; i <= n-1; i++){
        int x, y;
        scanf("%d %d", &x, &y);
        Add(x,y);Add(y,x);
    }
    for(int i = 1; i <= n; i++){
        scanf("%d", &ans[i]);
    }
    q.push(ans[1]);
    h[ans[1]]=1;
    while(!q.empty()){
        int x = q.front();
        q.pop();
        for(int i = head[x]; i!=-1 ; i = edge[i].next){
            int y = edge[i].to;
            if(h[y]==-1){h[y]=h[x]+1;q.push(y);}
        }

    }
    for(int i = 1; i < n; i++){
        if(h[ans[i]]>h[ans[i+1]]){
            printf("No");return 0;
        }
    }mem(vis,0);
    dfs(ans[1],0);
    for(int i = 1; i <= n; i++){
        if(vis[f[ans[i]]]){
            printf("No");return 0;
        }
        if(i<n&&f[ans[i]]!=f[ans[i+1]]){
            vis[f[ans[i]]]=1;

        }
    }
    printf("Yes");
    return 0;
}
/*
2
1 1 1 2 2 2
2 2 2 1 1 1
 */


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<vector>
#include<map>
#include<functional>

#define fst first
#define sc second
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1
#define lc root<<1
#define rc root<<1|1
#define lowbit(x) ((x)&(-x))

using namespace std;

typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PLL;

const db eps = 1e-6;
const int mod = 1e9+7;
const int maxn = 2e5+100;
const int maxm = 2e6+100;
const int inf = 0x3f3f3f3f;
const db pi = acos(-1.0);

int n, m, cnt;

int ans[maxn];
queue<int>q;
map<int,int>ma[maxn];
int main(){
    int n;
    scanf("%d", &n);
    cnt=0;
    for(int i = 1; i <= n-1; i++){
        int x, y;
        scanf("%d %d", &x, &y);
        //Add(x,y);Add(y,x);
        ma[x][y]=1;ma[y][x]=1;//logn
    }
    for(int i = 1; i <= n; i++){
        scanf("%d", &ans[i]);
    }
    q.push(ans[1]);
    int id = 2;
    while(!q.empty()){
        int x = q.front();
        q.pop();
        while(ma[x][ans[id]]){//logn
            q.push(ans[id]);
            id++;
        }
    }
    if(ans[1]!=1)id=-1;
    if(id==n+1)return printf("Yes"),0;printf("No");
    return 0;
}
/*
2
1 1 1 2 2 2
2 2 2 1 1 1
 */


B.cpp: In function 'int main()':
B.cpp:71:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if(id==n+1)return printf("Yes"),0;printf("No");
     ^~
B.cpp:71:39: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
     if(id==n+1)return printf("Yes"),0;printf("No");
                                       ^~~~~~
[Finished in 1.1s]


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef double db;

#define mp make_pair
#define pb push_back
#define pt(i) printf("%lld\n",(ll)i)
#define mp make_pair
#define ff first
#define ss second
#define pi acos(-1.0)

ll in() { ll a;scanf("%lld",&a); return a;}
db din(){ db a;scanf("%lf",&a); return a; }
ll bigmod(ll b, ll p,ll md){if(p==0) return 1;if(p%2==1){ return ((b%md)*bigmod(b,p-1,md))%md;} else {ll y=bigmod(b,p/2,md);return (y*y)%md;}}
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b);}

vi node[200005];
int dis[200005],ar[200005],par[200005];

void bfs(int s)
{
    dis[s]=0;
    queue<int> q;
    q.push(s);
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        for(int i=0;i<node[u].size();i++)
        {
            int v=node[u][i];
            if(dis[v]==-1)
            {
                par[v]=u;
                dis[v]=1+dis[u];
                q.push(v);
            }
        }
    }
}

int main()
{
    memset(dis,-1,sizeof dis);
    int n=in();
    for(int i=0;i<n-1;i++)
    {
        int a=in(),b=in();
        node[a].pb(b);
        node[b].pb(a);
    }
    bfs(1);
    bool hobe=1;
    int pos=1;
    for(int i=0;i<n;i++)
    {
        ar[i]=in();
        if(i)
        {
            if(dis[ar[i]]<dis[ar[i-1]])
                hobe=0;
            if(ar[pos-1]==par[ar[i]]);
            else if(ar[pos]==par[ar[i]])
                {
                    while(ar[pos-1]!=par[ar[i]])
                        pos++;
                }
            else
                hobe=0;
        }
    }
    if(hobe)
        puts("Yes");
    else
        puts("No");
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef double db;

#define mp make_pair
#define pb push_back
#define pt(i) printf("%lld\n",(ll)i)
#define mp make_pair
#define ff first
#define ss second
#define pi acos(-1.0)

ll in() { ll a;scanf("%lld",&a); return a;}
db din(){ db a;scanf("%lf",&a); return a; }
ll bigmod(ll b, ll p,ll md){if(p==0) return 1;if(p%2==1){ return ((b%md)*bigmod(b,p-1,md))%md;} else {ll y=bigmod(b,p/2,md);return (y*y)%md;}}
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b);}

vi node[200005];
int dis[200005],ar[200005],par[200005];

void bfs(int s)
{
    dis[s]=0;
    queue<int> q;
    q.push(s);
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        for(int i=0;i<node[u].size();i++)
        {
            int v=node[u][i];
            if(dis[v]==-1)
            {
                par[v]=u;
                dis[v]=1+dis[u];
                q.push(v);
            }
        }
    }
}

int main()
{
    memset(dis,-1,sizeof dis);
    int n=in();
    for(int i=0;i<n-1;i++)
    {
        int a=in(),b=in();
        node[a].pb(b);
        node[b].pb(a);
    }
    bfs(1);
    bool hobe=1;
    int pos=1;
    for(int i=0;i<n;i++)
    {
        ar[i]=in();
        if(i)
        {
            while(pos<i&&ar[pos-1]!=par[ar[i]])
                pos++;
            if(i>1)
            if(pos==i)
                hobe=0;
        }
    }
    if(hobe)
        puts("Yes");
    else
        puts("No");
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef double db;

#define mp make_pair
#define pb push_back
#define pt(i) printf("%lld\n",(ll)i)
#define mp make_pair
#define ff first
#define ss second
#define pi acos(-1.0)

ll in() { ll a;scanf("%lld",&a); return a;}
db din(){ db a;scanf("%lf",&a); return a; }
ll bigmod(ll b, ll p,ll md){if(p==0) return 1;if(p%2==1){ return ((b%md)*bigmod(b,p-1,md))%md;} else {ll y=bigmod(b,p/2,md);return (y*y)%md;}}
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b);}

vi node[200005];
int dis[200005],ar[200005],par[200005];

void bfs(int s)
{
    dis[s]=0;
    queue<int> q;
    q.push(s);
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        for(int i=0;i<node[u].size();i++)
        {
            int v=node[u][i];
            if(dis[v]==-1)
            {
                par[v]=u;
                dis[v]=1+dis[u];
                q.push(v);
            }
        }
    }
}

int main()
{
    memset(dis,-1,sizeof dis);
    int n=in();
    for(int i=0;i<n-1;i++)
    {
        int a=in(),b=in();
        node[a].pb(b);
        node[b].pb(a);
    }
    bfs(1);
    bool hobe=1;
    int pos=1;
    for(int i=0;i<n;i++)
    {
        ar[i]=in();
        if(i)
        {
            if(dis[ar[i]]<dis[ar[i-1]])
                hobe=0;
            if(ar[pos-1]==par[ar[i]]);
            else if(ar[pos]==par[ar[i]])
                {
                    while(pos<n&&ar[pos-1]!=par[ar[i]])
                        pos++;
                }
            else
                hobe=0;
        }
    }
    if(hobe)
        puts("Yes");
    else
        puts("No");
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef double db;

#define mp make_pair
#define pb push_back
#define pt(i) printf("%lld\n",(ll)i)
#define mp make_pair
#define ff first
#define ss second
#define pi acos(-1.0)

ll in() { ll a;scanf("%lld",&a); return a;}
db din(){ db a;scanf("%lf",&a); return a; }
ll bigmod(ll b, ll p,ll md){if(p==0) return 1;if(p%2==1){ return ((b%md)*bigmod(b,p-1,md))%md;} else {ll y=bigmod(b,p/2,md);return (y*y)%md;}}
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b);}

vi node[200005];
int dis[200005],ar[200005],par[200005];

void bfs(int s)
{
    dis[s]=0;
    queue<int> q;
    q.push(s);
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        for(int i=0;i<node[u].size();i++)
        {
            int v=node[u][i];
            if(dis[v]==-1)
            {
                par[v]=u;
                dis[v]=1+dis[u];
                q.push(v);
            }
        }
    }
}

int main()
{
    memset(dis,-1,sizeof dis);
    int n=in();
    for(int i=0;i<n-1;i++)
    {
        int a=in(),b=in();
        node[a].pb(b);
        node[b].pb(a);
    }
    bfs(1);
    bool hobe=1;
    int pos=1;
    for(int i=0;i<n;i++)
    {
        ar[i]=in();
        if(dis[ar[i]]==-1)
            hobe=0;
        else if(i)
        {
            while(pos<=i&&ar[pos-1]!=par[ar[i]])
                pos++;
            if(i>1){
            if(pos==i+1)
                hobe=0;}
            else if(par[ar[i]]!=1)
                hobe=0;
        }
    }
    if(hobe)
        puts("Yes");
    else
        puts("No");
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef double db;

#define mp make_pair
#define pb push_back
#define pt(i) printf("%lld\n",(ll)i)
#define mp make_pair
#define ff first
#define ss second
#define pi acos(-1.0)

ll in() { ll a;scanf("%lld",&a); return a;}
db din(){ db a;scanf("%lf",&a); return a; }
ll bigmod(ll b, ll p,ll md){if(p==0) return 1;if(p%2==1){ return ((b%md)*bigmod(b,p-1,md))%md;} else {ll y=bigmod(b,p/2,md);return (y*y)%md;}}
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b);}

vi node[200005];
int dis[200005],ar[200005],par[200005];

void bfs(int s)
{
    dis[s]=0;
    queue<int> q;
    q.push(s);
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        for(int i=0;i<node[u].size();i++)
        {
            int v=node[u][i];
            if(dis[v]==-1)
            {
                par[v]=u;
                dis[v]=1+dis[u];
                q.push(v);
            }
        }
    }
}

int main()
{
    memset(dis,-1,sizeof dis);
    int n=in();
    for(int i=0;i<n-1;i++)
    {
        int a=in(),b=in();
        node[a].pb(b);
        node[b].pb(a);
    }
    bfs(1);
    bool hobe=1;
    int pos=1;
    for(int i=0;i<n;i++)
    {
        ar[i]=in();
        if(i)
        {
            if(dis[ar[i]]<dis[ar[i-1]])
                hobe=0;
            if(ar[pos-1]==par[ar[i]]);
            else
            {
                while(pos<i&&ar[pos-1]!=par[ar[i]])
                        pos++;
                if(pos==i)
                    hobe=0;
            }
        }
    }
    if(hobe)
        puts("Yes");
    else
        puts("No");
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef double db;

#define mp make_pair
#define pb push_back
#define pt(i) printf("%lld\n",(ll)i)
#define mp make_pair
#define ff first
#define ss second
#define pi acos(-1.0)

ll in() { ll a;scanf("%lld",&a); return a;}
db din(){ db a;scanf("%lf",&a); return a; }
ll bigmod(ll b, ll p,ll md){if(p==0) return 1;if(p%2==1){ return ((b%md)*bigmod(b,p-1,md))%md;} else {ll y=bigmod(b,p/2,md);return (y*y)%md;}}
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b);}

vi node[200005];
int dis[200005],ar[200005],par[200005];

void bfs(int s)
{
    dis[s]=0;
    queue<int> q;
    q.push(s);
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        for(int i=0;i<node[u].size();i++)
        {
            int v=node[u][i];
            if(dis[v]==-1)
            {
                par[v]=u;
                dis[v]=1+dis[u];
                q.push(v);
            }
        }
    }
}

int main()
{
    memset(dis,-1,sizeof dis);
    int n=in();
    for(int i=0;i<n-1;i++)
    {
        int a=in(),b=in();
        node[a].pb(b);
        node[b].pb(a);
    }
    bfs(1);
    bool hobe=1;
    int pos=1;
    for(int i=0;i<n;i++)
    {
        ar[i]=in();
        if(i)
        {
            if(dis[ar[i]]<dis[ar[i-1]])
                hobe=0;
            if(ar[pos-1]==par[ar[i]]);
            else if(ar[pos]==par[ar[i]])
                {
                    while(ar[pos]!=par[ar[i]])
                        pos++;
                }
            else
                hobe=0;
        }
    }
    if(hobe)
        puts("Yes");
    else
        puts("No");
}