#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
using namespace std ;

    int64_t n,x,r,ch=0,i,j,u ;
    double rr ;

int main ()
{
    cin>>n ;

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

         cin>>x ;
         if (x==1)
        {
            printf("NO\n") ;
            continue ;
        }
        ch=0 ;
        rr=sqrt(x) ;
        r=sqrt(x) ;
        if (rr!=r)
        {
            printf("NO\n") ;
        }
        else
        {
             u = sqrt (r) ;
                for ( j=2 ; j<=u ; j++)
                {
                    if (r%j==0)
                    {
                        ch=1 ;
                        printf("NO\n") ;
                        break ;
                    }

                }

            if (ch==0)
            {
                printf("YES\n") ;
            }
        }
    }
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
using namespace std ;
int64_t x[1000000] ;
int main ()
{
    int64_t n,r,ch=0,u,k=0,xx ;
    double rr ;
    for (int i=2 ; i<1000000 ; i++)
{
    r=0 ;
    for (int j=2 ; j<=sqrt(i) ; j++)
    {
        if (i%j==0) {r++ ; break ;}
    }
    if (r==0)
    {
        x[k]=i ;
        k++ ;
    }
}
/*for (int i=0 ; i<50 ; i++)
{
    cout<<x[i]<<endl ;
}*/
    cin>>n ;

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

         cin>>xx ;
         if (xx==1)
        {
            printf("NO\n") ;
            continue ;
        }
        ch=0 ;
        rr=sqrt(xx) ;
        r=sqrt(xx) ;
        if (rr!=r)
        {
            printf("NO\n") ;
        }
        else
        {
            int64_t first=0 ; int64_t last=1000000 ;
           for (int i=0 ; i<64 ; i++)
           {
               int64_t mid=(first+last)/2 ;
               if (x[mid]==r)  {cout<<"YES"<<endl ; ch=1 ; break ;}
               else if (x[mid]>r)  {first=mid ;}
               else if (x[mid]<r)  {last=mid ;}
           }
           if (ch==0 && xx!=4)  {cout<<"NO"<<endl ;}
           else if (xx==4)  {cout<<"YES"<<endl ;}
        }
    }
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
using namespace std ;

int main ()
{
    int64_t n,x,r,ch=0,u ;
    double rr ;
    cin>>n ;

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

         cin>>x ;
         if (x==1)
        {
            printf("NO\n") ;
            continue ;
        }
        ch=0 ;
        rr=sqrt(x) ;
        r=sqrt(x) ;
        if (rr!=r)
        {
            printf("NO\n") ;
        }
        else
        {
             u = sqrt (r) ;
                for (int j=2 ; j<=u ; j++)
                {
                    if (r%j==0)
                    {
                        ch=1 ;
                        printf("NO\n") ;
                        break ;
                    }

                }

            if (ch==0)
            {
                printf("YES\n") ;
            }
        }
    }
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
using namespace std ;

int main ()
{
    int64_t n,x[55555],r,ch=0,u,k=0,xx ;
    double rr ;
    for (int i=2 ; i<1000000 ; i++)
{
    r=0 ;
    for (int j=2 ; j<=i ; j++)
    {
        if (i%j==0) {r++ ;}
        if (r>1)   {break ;}
    }
    if (r==1)
    {
        x[k]=i ;
        k++ ;
    }
}
/*for (int i=0 ; i<430 ; i++)
{
    cout<<x[i]<<endl ;
}*/
    cin>>n ;

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

         cin>>xx ;
         if (xx==1)
        {
            printf("NO\n") ;
            continue ;
        }
        ch=0 ;
        rr=sqrt(xx) ;
        r=sqrt(xx) ;
        if (rr!=r)
        {
            printf("NO\n") ;
        }
        else
        {
           for (int i=0 ; x[i]<=r ; i++)
           {
               if (x[i]==r)
               {
                   cout<<"YES"<<endl ;
                   ch=1 ;
               }
           }
           if (ch==0)  {cout<<"NO"<<endl ;}
        }
    }
}


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

int main ()
{
    int64_t n,x,r,re,ch=0 ;
    long double rr ;

    string xx[100001] ;
    cin>>n ;

    for (int i=0 ; i<n ; i++)
    {
        cin>>x ;
        if (x==1)
        {
            cout<<"NO"<<endl ;
            continue ;
        }
        ch=0 ;
        rr=sqrt(x) ;
        r=sqrt(x) ;
        if (rr!=r)
        {
            cout<<"NO"<<endl ;
        }
        else
        {
            int u = sqrt (r) ;
            double uu = sqrt (r) ;
            //cout<< u << uu <<endl ;
            if (u!=uu)
            {
                for (int j=2 ; j<=u ; j++)
                {
                    if (r%j==0)
                    {
                        ch=1 ;
                        cout<<"NO"<<endl ;
                        break ;
                    }

                }
            }
            else
            {
                        ch=1 ;
                        cout<<"NO"<<endl ;
            }

            if (ch==0)
            {
                cout<<"YES"<<endl ;
            }
        }

        //for (int i=0 ; i<n ; i++)
        //  {
        // cout<<xx[i]<<endl ;
//    }

    }

}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
using namespace std ;

int main ()
{
    int64_t n,x,r,ch=0,u ;
    long double rr,uu ;
    cin>>n ;

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

         cin>>x ;
         if (x==1)
        {
            printf("NO\n") ;
            continue ;
        }
        ch=0 ;
        rr=sqrt(x) ;
        r=sqrt(x) ;
        if (rr!=r)
        {
            printf("NO\n") ;
        }
        else
        {
             u = sqrt (r) ;
             uu = sqrt (r) ;
            if (u!=uu)
            {
                for (int j=2 ; j<=u ; j++)
                {
                    if (r%j==0)
                    {
                        ch=1 ;
                        printf("NO\n") ;
                        break ;
                    }

                }
            }
            else
            {
                        ch=1 ;
                        printf("NO\n") ;
            }

            if (ch==0)
            {
                printf("YES\n") ;
            }
        }
    }
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
using namespace std ;
int64_t x[1000000] ;
int main ()
{
    int64_t n,r,ch=0,u,k=0,xx ;
    double rr ;
    for (int i=2 ; i<1000000 ; i++)
{
    r=0 ;
    for (int j=2 ; j<=sqrt(i) ; j++)
    {
        if (i%j==0) {r++ ; break ;}
    }
    if (r==0)
    {
        x[i]++ ;

    }
}
/*for (int i=0 ; i<50 ; i++)
{
    cout<<x[i]<<endl ;
}*/
    cin>>n ;

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

         cin>>xx ;
         if (xx==1)
        {
            printf("NO\n") ;
            continue ;
        }
        ch=0 ;
        rr=sqrt(xx) ;
        r=sqrt(xx) ;
        if (rr!=r)
        {
            printf("NO\n") ;
        }
        else
        {
           if (x[r]>0)  {printf("YES\n") ;}
           else {printf("NO\n") ; }

        }
    }
}


#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std ;
int64_t n,x,r,re,ch=0,i,u,j ;
    long double rr,uu ;

int main ()
{
    cin>>n ;

    for ( i=0 ; i<n ; i++)
    {
        cin>>x ;
        if (x==1)
        {
            cout<<"NO"<<endl ;
            continue ;
        }
        ch=0 ;
        rr=sqrt(x) ;
        r=sqrt(x) ;
        if (rr!=r)
        {
            cout<<"NO"<<endl ;
        }
        else
        {
             u = sqrt (r) ;
             uu = sqrt (r) ;
            if (u!=uu)
            {
                for ( j=2 ; j<=u ; j++)
                {
                    if (r%j==0)
                    {
                        ch=1 ;
                        cout<<"NO"<<endl ;
                        break ;
                    }

                }
            }
            else
            {
                        ch=1 ;
                        cout<<"NO"<<endl ;
            }

            if (ch==0)
            {
                cout<<"YES"<<endl ;
            }
        }

        //for (int i=0 ; i<n ; i++)
        //  {
        // cout<<xx[i]<<endl ;
//    }

    }

}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
using namespace std ;
int64_t x[1000000] ;
int main ()
{
    int64_t n,r,ch=0,u,k=0,xx ;
    double rr ;
    for (int i=2 ; i<1000000 ; i++)
{
    r=0 ;
    for (int j=2 ; j<=i ; j++)
    {
        if (i%j==0) {r++ ;}
        if (r>1)   {break ;}
    }
    if (r==1)
    {
        x[k]=i ;
        k++ ;
    }
}
/*for (int i=0 ; i<430 ; i++)
{
    cout<<x[i]<<endl ;
}*/
    cin>>n ;

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

         cin>>xx ;
         if (xx==1)
        {
            printf("NO\n") ;
            continue ;
        }
        ch=0 ;
        rr=sqrt(xx) ;
        r=sqrt(xx) ;
        if (rr!=r)
        {
            printf("NO\n") ;
        }
        else
        {
           for (int i=0 ; x[i]<=r ; i++)
           {
               if (x[i]==r)
               {
                   cout<<"YES"<<endl ;
                   ch=1 ;
               }
           }
           if (ch==0)  {cout<<"NO"<<endl ;}
        }
    }
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
using namespace std ;

int main ()
{
    int64_t n,x,r,ch=0,i,j,u ;
    double rr ;
    cin>>n ;

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

         cin>>x ;
         if (x==1)
        {
            printf("NO\n") ;
            continue ;
        }
        ch=0 ;
        rr=sqrt(x) ;
        r=sqrt(x) ;
        if (rr!=r)
        {
            printf("NO\n") ;
        }
        else
        {
             u = sqrt (r) ;
                for ( j=2 ; j<=u ; j++)
                {
                    if (r%j==0)
                    {
                        ch=1 ;
                        printf("NO\n") ;
                        break ;
                    }

                }

            if (ch==0)
            {
                printf("YES\n") ;
            }
        }
    }
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
using namespace std ;

int main ()
{
    int64_t n,x,r,ch=0,u ;
    double rr ;
    cin>>n ;

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

         cin>>x ;
         if (x==1)
        {
            printf("NO\n") ;
            continue ;
        }
        ch=0 ;
        rr=sqrt(x) ;
        r=sqrt(x) ;
        if (rr!=r)
        {
            printf("NO\n") ;
        }
        else
        {
             u = sqrt (r) ;
                for (int64_t j=2 ; j<=u ; j++)
                {
                    if (r%j==0)
                    {
                        ch=1 ;
                        printf("NO\n") ;
                        break ;
                    }

                }

            if (ch==0)
            {
                printf("YES\n") ;
            }
        }
    }
}


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

int main ()
{
    int64_t n,x,r,re,ch=0 ;
    long double rr ;

    string xx[100001] ;
    cin>>n ;

    for (int i=0 ; i<n ; i++)
    {
        cin>>x ;
    if (x==1)
    {
        xx[i]="NO" ;
        continue ;
    }
        ch=0 ;
        rr=sqrt(x) ;
        r=sqrt(x) ;
        if (rr!=r)   {xx[i]="NO" ;}
        else
        {
            for (int j=2 ; j<r ; j++)
            {
                if (r%j==0)
                {
                    ch=1 ;
                    xx[i]="NO" ;
                    break ;
                }
            }
            if (ch==0)
            {
                xx[i]="YES" ;
            }
        }

    }
    for (int i=0 ; i<n ; i++)
    {
        cout<<xx[i]<<endl ;
    }

}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
using namespace std ;

int main ()
{
    int n,x,r,ch=0,i,j,u ;
    double rr ;
    cin>>n ;

    for ( i=0 ; i<n ; i++)
    {
         cin>>x ;
         if (x==1)
        {
            printf("NO\n") ;
            continue ;
        }
        ch=0 ;
        rr=sqrt(x) ;
        r=sqrt(x) ;
        if (rr!=r)
        {
            printf("NO\n") ;
        }
        else
        {
             u = sqrt (r) ;
                for ( j=2 ; j<=u ; j++)
                {
                    if (r%j==0)
                    {
                        ch=1 ;
                        printf("NO\n") ;
                        break ;
                    }

                }

            if (ch==0)
            {
                printf("YES\n") ;
            }
        }
    }
}


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

int main ()
{
    int64_t n,x,r,re,ch=0 ;
    long double rr ;

    string xx[100001] ;
    cin>>n ;

    for (int i=0 ; i<n ; i++)
    {
        cin>>x ;
    if (x==1)
    {
        xx[i]="NO" ;
        continue ;
    }
        ch=0 ;
        rr=sqrt(x) ;
        r=sqrt(x) ;
        if (rr!=r)   {xx[i]="NO" ;}
        else
        {
            for (int j=2 ; j<r ; j++)
            {
                if (r%j==0)
                {
                    ch=1 ;
                    xx[i]="NO" ;
                }
            }
            if (ch==0)
            {
                xx[i]="YES" ;
            }
        }

    }
    for (int i=0 ; i<n ; i++)
    {
        cout<<xx[i]<<endl ;
    }

}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
using namespace std ;
int64_t x[1000000] ;
int main ()
{
    int64_t n,r,ch=0,u,k=0,xx ;
    double rr ;
    for (int i=2 ; i<1000000 ; i++)
{
    r=0 ;
    for (int j=2 ; j<=sqrt(i) ; j++)
    {
        if (i%j==0) {r++ ; break ;}
    }
    if (r==0)
    {
        x[k]=i ;
        k++ ;
    }
}
/*for (int i=0 ; i<50 ; i++)
{
    cout<<x[i]<<endl ;
}*/
    cin>>n ;

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

         cin>>xx ;
         if (xx==1)
        {
            printf("NO\n") ;
            continue ;
        }
        ch=0 ;
        rr=sqrt(xx) ;
        r=sqrt(xx) ;
        if (rr!=r)
        {
            printf("NO\n") ;
        }
        else
        {
            int64_t first=0 ; int64_t last=1000000 ;
           for (int i=0 ; i<32 ; i++)
           {
               int64_t mid=(first+last)/2 ;
               if (x[mid]==r)  {cout<<"YES"<<endl ; ch=1 ; break ;}
               else if (x[mid]>r)  {first=mid ;}
               else if (x[mid]<r)  {last=r ;}
           }
           if (ch==0 && xx!=4)  {cout<<"NO"<<endl ;}
           else if (xx==4)  {cout<<"YES"<<endl ;}
        }
    }
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
using namespace std ;
int64_t x[1000000] ;
int main ()
{
    int64_t n,r,ch=0,u,k=0,xx ;
    double rr ;
    for (int i=2 ; i<1000000 ; i++)
{
    r=0 ;
    for (int j=2 ; j<=sqrt(i) ; j++)
    {
        if (i%j==0) {r++ ; break ;}
    }
    if (r==0)
    {
        x[k]=i ;
        k++ ;
    }
}
/*for (int i=0 ; i<11 ; i++)
{
    cout<<x[i]<<endl ;
}*/
    cin>>n ;

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

         cin>>xx ;
         if (xx==1)
        {
            printf("NO\n") ;
            continue ;
        }
        ch=0 ;
        rr=sqrt(xx) ;
        r=sqrt(xx) ;
        if (rr!=r)
        {
            printf("NO\n") ;
        }
        else
        {
           for (int i=0 ; x[i]<=r ; i++)
           {
               if (x[i]==r)
               {
                   cout<<"YES"<<endl ;
                   ch=1 ;
               }
           }
           if (ch==0)  {cout<<"NO"<<endl ;}
        }
    }
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
using namespace std ;

int main ()
{
    int64_t n,x[55555],r,ch=0,u,k=0,xx ;
    double rr ;
    for (int i=2 ; i<10000 ; i++)
{
    r=0 ;
    for (int j=2 ; j<=i ; j++)
    {
        if (i%j==0) {r++ ;}
        if (r>1)   {break ;}
    }
    if (r==1)
    {
        x[k]=i ;
        k++ ;
    }
}
/*for (int i=0 ; i<430 ; i++)
{
    cout<<x[i]<<endl ;
}*/
    cin>>n ;

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

         cin>>xx ;
         if (xx==1)
        {
            printf("NO\n") ;
            continue ;
        }
        ch=0 ;
        rr=sqrt(xx) ;
        r=sqrt(xx) ;
        if (rr!=r)
        {
            printf("NO\n") ;
        }
        else
        {
           for (int i=0 ; x[i]<=r ; i++)
           {
               if (x[i]==r)
               {
                   cout<<"YES"<<endl ;
                   ch=1 ;
               }
           }
           if (ch==0)  {cout<<"NO"<<endl ;}
        }
    }
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
using namespace std ;

int main ()
{
    int64_t n,x,r,re,ch=0 ;
    long double rr ;

    string xx[100001] ;
    cin>>n ;

    for (int i=0 ; i<n ; i++)
    {
        int64_t temp ;
        scanf("%d", &temp);
        x=temp ;
         if (x==1)
        {
            printf("NO\n") ;
            continue ;
        }
        ch=0 ;
        rr=sqrt(x) ;
        r=sqrt(x) ;
        if (rr!=r)
        {
            printf("NO\n") ;
        }
        else
        {
            int u = sqrt (r) ;
            double uu = sqrt (r) ;
            //cout<< u << uu <<endl ;
            if (u!=uu)
            {
                for (int j=2 ; j<=u ; j++)
                {
                    if (r%j==0)
                    {
                        ch=1 ;
                        printf("NO\n") ;
                        break ;
                    }

                }
            }
            else
            {
                        ch=1 ;
                        printf("NO\n") ;
            }

            if (ch==0)
            {
                printf("YES\n") ;
            }
        }

        //for (int i=0 ; i<n ; i++)
        //  {
        // cout<<xx[i]<<endl ;
//    }

    }

}


#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std ;

    long long n,x,r,ch=0,i,j,u ;
    double rr ;

int main ()
{
    cin>>n ;

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

         cin>>x ;
         if (x==1)
        {
            printf("NO\n") ;
            continue ;
        }
        ch=0 ;
        rr=sqrt(x) ;
        r=sqrt(x) ;
        if (rr!=r)
        {
            printf("NO\n") ;
        }
        else
        {
             u = sqrt (r) ;
                for ( j=2 ; j<=u ; j++)
                {
                    if (r%j==0)
                    {
                        ch=1 ;
                        printf("NO\n") ;
                        break ;
                    }

                }

            if (ch==0)
            {
                printf("YES\n") ;
            }
        }
    }
}


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

int main ()
{
    int64_t n,x,r,re,ch=0 ;
    long double rr ;

    string xx[100000] ;
    cin>>n ;
    for (int i=0 ; i<n ; i++)
    {
        cin>>x ;
        ch=0 ;
        rr=sqrt(x) ;
        r=sqrt(x) ;
        if (rr!=r)   {xx[i]="NO" ;}
        else
        {
            for (int j=2 ; j<r ; j++)
            {
                if (r%j==0)
                {
                    ch=1 ;
                    xx[i]="NO" ;
                }
            }
            if (ch==0)
            {
                xx[i]="YES" ;
            }
        }

    }
    for (int i=0 ; i<n ; i++)
    {
        cout<<xx[i]<<endl ;
    }

}


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

int main ()
{
    int64_t n,x,r,re,ch=0 ;
    long double rr ;

    string xx[100001] ;
    cin>>n ;

    for (int i=0 ; i<n ; i++)
    {
        cin>>x ;
    if (x==1)
    {
        cout<<"NO"<<endl ;
        continue ;
    }
        ch=0 ;
        rr=sqrt(x) ;
        r=sqrt(x) ;
        if (rr!=r)   {cout<<"NO"<<endl ;}
        else
        {
            for (int j=2 ; j<r ; j++)
            {
                if (r%j==0)
                {
                    ch=1 ;
                    cout<<"NO"<<endl ;
                    break ;
                }
            }
            if (ch==0)
            {
                cout<<"YES"<<endl ;
            }
        }

    //for (int i=0 ; i<n ; i++)
  //  {
       // cout<<xx[i]<<endl ;
//    }

    }

}


//B. T-Primes
//ravg95

#include <iostream>
#include <stdint.h>
#include <stdbool.h>
#include <cmath>

using namespace std;

bool t_prime(uint64_t a){

	if(a<=3)
		return false;
	if(a==4)
		return true;
	uint64_t i;
	for(i=3;i*i<=a;i+=2){
		if(a%i==0 && i*i!=a)
			return false;
	}
	i-=2;
	if(a==i*i)
		return true;
	else
		return false;
}
int main(){
	ios_base::sync_with_stdio(false);
	#ifndef HESOYAM
		cin.tie(NULL);
	#endif
	int T;
	cin>>T;
	while(T-->0){
		uint64_t a;
		cin>>a;
		if(t_prime(a))
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}

}


//B. T-Primes
//ravg95

#include <iostream>
#include <stdint.h>
#include <stdbool.h>
#include <cmath>
#include <cstdlib>

uint64_t square[500001]={0};
using namespace std;

void gen_squares(){
	for(int i=3;i<1000001;i+=2)
		square[i/2-1]=i*i;
}
int compare (const void * a, const void * b){

  if ( *(uint64_t*)a <  *(uint64_t*)b ) return -1;
  if ( *(uint64_t*)a == *(uint64_t*)b ) return 0;
  if ( *(uint64_t*)a >  *(uint64_t*)b ) return 1;
}
bool t_prime(uint64_t a){
	if(a==4)return true;
	if(a<=3 || a%2==0)return false;
	uint64_t* pItem ;
	pItem= (uint64_t*) bsearch (&a, square,  500001,sizeof(uint64_t) ,(int(*)(const void*,const void*)) compare);
	if(pItem==NULL) return false;
	uint64_t i;
	for(i=3; i*i<=a;i+=2){
		if(a%i==0 && i*i!=a)
			return false;
	}
	i-=2;
	if(i*i==a)
		return true;
	else
		return false;
}

int main(){
	ios_base::sync_with_stdio(false);
	#ifndef HESOYAM
		cin.tie(NULL);
	#endif
	int T;
	cin>>T;
	gen_squares();
	while(T-->0){
		uint64_t a;
		cin>>a;
		if(t_prime(a))
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}

}


//230B
//ravg95

#include <iostream>
#include <stdint.h>
#include <stdbool.h>
#include <cstdlib>

uint64_t square[500001]={0};
using namespace std;

void gen_squares(){
	for(uint64_t i=3;i<1000000;i+=2)
		square[i/2-1]=(uint64_t)(i*i);
	}
int compare (const void * a, const void * b){

	if ( *(uint64_t*)a <  *(uint64_t*)b ) return -1;
	else if ( *(uint64_t*)a == *(uint64_t*)b ) return 0;
	else return 1;

}
bool t_prime(uint64_t a){
	if(a==4 || a==9)
		return true;
	if(a<9 || a%2==0)
		return false;
	uint64_t* pItem ;
	pItem= (uint64_t*) bsearch (&a, square,  500001,sizeof(uint64_t) ,(int(*)(const void*,const void*)) compare);
	if(pItem==NULL) return false;
		uint64_t i=(pItem - square +1)*2 +1;
	for(uint64_t j=2;j*j <=i;j++){
		if(i%j==0){
			return false;
		}
	}
	return true;
}

int main(){

	ios_base::sync_with_stdio(false);
	#ifndef HESOYAM
		cin.tie(NULL);
	#endif
	int T;
	cin>>T;
	gen_squares();
	while(T-->0){
		uint64_t a;
		cin>>a;
		if(t_prime(a))
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}

}


//B. T-Primes
//ravg95

#include <iostream>
#include <stdint.h>
#include <stdbool.h>
#include <cmath>

using namespace std;

bool prime(uint64_t a){
	if(a<2)return false;
	else if(a<=3)return true;
	uint64_t sq;
	if(a>1<<31)
		sq=sqrt(a/100000000)*10000;
	else
		sq=sqrt(a);
	for(int i=2;i<sq;i++)
		if(a%i==0)return false;
	return true;

}

bool t_prime(uint64_t a){
	uint64_t sq;
	if(a>1<<31)
		sq=sqrt(a/100000000)*10000;
	else
		sq=sqrt(a);
	uint64_t tst = (uint64_t)(sq + 0.5);
	return(tst*tst == a && prime(tst));
}
int main(){
	ios_base::sync_with_stdio(false);
	int T;
	cin>>T;
	while(T-->0){
		uint64_t a;
		cin>>a;
		if(t_prime(a))
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}

}


//B. T-Primes
//ravg95

#include <iostream>
#include <stdint.h>
#include <stdbool.h>
#include <cstdlib>

uint64_t square[500001]={0};
using namespace std;

void gen_squares(){
	for(uint64_t i=3;i<1000000;i+=2)
		square[i/2-1]=(uint64_t)(i*i);
}
int compare (const void * a, const void * b){

  if ( *(uint64_t*)a <  *(uint64_t*)b ) return -1;
  else if ( *(uint64_t*)a == *(uint64_t*)b ) return 0;
  else return 1;

}
bool t_prime(uint64_t a){
	if(a==4 || a==9)return true;
	if(a<9 || a%2==0)return false;
	uint64_t* pItem ;
	pItem= (uint64_t*) bsearch (&a, square,  500001,sizeof(uint64_t) ,(int(*)(const void*,const void*)) compare);
	if(pItem==NULL) return false;
	uint64_t i=(pItem - square +1)*2 +1;
	cout<<i<<'\n';
	for(uint64_t j=2;j*j <=i;j++){
		if(i%j==0){
			return false;
		}
	}
	/*
	for(i=3; i*i<=a;i+=2){
		if(a%i==0 && i*i!=a)
			return false;
	}
	i-=2;
	if(i*i==a)
		return true;
	else
		return false;
	*/
	return true;
}

int main(){
	ios_base::sync_with_stdio(false);
	#ifndef HESOYAM
		cin.tie(NULL);
	#endif
	int T;
	cin>>T;
	gen_squares();
	while(T-->0){
		uint64_t a;
		cin>>a;
		if(t_prime(a))
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}

}


//B. T-Primes
//ravg95

#include <iostream>
#include <stdint.h>
#include <stdbool.h>
#include <cmath>
#include <cstdlib>

uint64_t square[1000000/2]={0};
using namespace std;

void gen_squares(){
	for(uint64_t i=3;i<1000000;i+=2)
		square[i/2-1]=(uint64_t)(i*i);
}
int compare (const void * a, const void * b){

  if ( *(uint64_t*)a <  *(uint64_t*)b ) return -1;
  if ( *(uint64_t*)a == *(uint64_t*)b ) return 0;
  if ( *(uint64_t*)a >  *(uint64_t*)b ) return 1;
}
bool t_prime(uint64_t a){
	if(a==4)return true;
	if(a<9 || a%2==0)return false;
	uint64_t* pItem ;
	pItem= (uint64_t*) bsearch (&a, square,  1000000/2,sizeof(uint64_t) ,(int(*)(const void*,const void*)) compare);
	if(pItem==NULL) return false;
	uint64_t i;
	for(i=3; i*i<=a;i+=2){
		if(a%i==0 && i*i!=a)
			return false;
	}
	i-=2;
	if(i*i==a)
		return true;
	else
		return false;
}

int main(){
	ios_base::sync_with_stdio(false);
	#ifndef HESOYAM
		cin.tie(NULL);
	#endif
	int T;
	cin>>T;
	gen_squares();
	while(T-->0){
		uint64_t a;
		cin>>a;
		if(t_prime(a))
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}

}


//B. T-Primes
//ravg95

#include <iostream>
#include <stdint.h>
#include <stdbool.h>
#include <cstdlib>

uint64_t square[1000000/2+1]={0};
using namespace std;

void gen_squares(){
	for(uint64_t i=3;i<1000000;i+=2)
		square[i/2-1]=(uint64_t)(i*i);
}
int compare (const void * a, const void * b){

  if ( *(uint64_t*)a <  *(uint64_t*)b ) return -1;
  else if ( *(uint64_t*)a == *(uint64_t*)b ) return 0;
  else return 1;

}
bool t_prime(uint64_t a){
	if(a==4 || a==9)return true;
	if(a<9 || a%2==0)return false;
	uint64_t* pItem ;
	pItem= (uint64_t*) bsearch (&a, square,  1000000/2+1,sizeof(uint64_t) ,(int(*)(const void*,const void*)) compare);
	if(pItem==NULL) return false;
	uint64_t i;
	for(i=3; i*i<=a;i+=2){
		if(a%i==0 && i*i!=a)
			return false;
	}
	i-=2;
	if(i*i==a)
		return true;
	else
		return false;
}

int main(){
	ios_base::sync_with_stdio(false);
	#ifndef HESOYAM
		cin.tie(NULL);
	#endif
	int T;
	cin>>T;
	gen_squares();
	while(T-->0){
		uint64_t a;
		cin>>a;
		if(t_prime(a))
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}

}


//B. T-Primes
//ravg95

#include <iostream>
#include <stdint.h>
#include <stdbool.h>
#include <cmath>

using namespace std;

bool t_prime(uint64_t a){
	if(a<=3)
		return false;
	if(a==4 || a==9)
		return true;
	if(a%2==0)
		return false;
	if((a>4 && a<9)||(a>9 && a<25))
		return false;
	uint64_t i;
	for(i=5;i*i<=a;i+=2){
		if(a%i==0 && i*i!=a)
			return false;
		//if(i*i*i*i>=a&&i*i<=a)break;
	}
	i-=2;
	if(i*i==a)
		return true;
	else return false;
}
int main(){
	ios_base::sync_with_stdio(false);
	#ifndef HESOYAM
		cin.tie(NULL);
	#endif
	int T;
	cin>>T;
	while(T-->0){
		uint64_t a;
		cin>>a;
		if(t_prime(a))
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}

}


//B. T-Primes
//ravg95

#include <iostream>
#include <stdint.h>
#include <stdbool.h>
#include <cmath>

using namespace std;

bool t_prime(uint64_t a){
	uint64_t i;
	if(a<=3)return false;
	if(a==4)return true;
	for(i=3;i*i<=a;i+=2){
		if(a%i==0 && i*i!=a)
			return false;
	}
	i--;
	if(a==i*i)
		return true;
	else
		return false;
}
int main(){
	ios_base::sync_with_stdio(false);
	#ifndef HESOYAM
		cin.tie(NULL);
	#endif
	int T;
	cin>>T;
	while(T-->0){
		uint64_t a;
		cin>>a;
		if(t_prime(a))
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}

}


//B. T-Primes
//ravg95

#include <iostream>
#include <stdint.h>
#include <stdbool.h>
#include <cstdlib>

int64_t square[10000000/2]={0};
using namespace std;

void gen_squares(){
	for(int64_t i=5;i<10000000;i+=2)
		square[i/2-2]=(int64_t)(i*i);
}
int compare (const void * a, const void * b){

  if ( *(int64_t*)a <  *(int64_t*)b ) return -1;
  else if ( *(int64_t*)a == *(int64_t*)b ) return 0;
  else return 1;

}
bool t_prime(int64_t a){
	if(a==4 || a==9)return true;
	if(a<25 || a%2==0)return false;
	int64_t* pItem ;
	pItem= (int64_t*) bsearch (&a, square,  10000000/2,sizeof(int64_t) ,(int(*)(const void*,const void*)) compare);
	if(pItem==NULL) return false;
	int64_t i;
	for(i=5; i*i<=a;i+=2){
		if(a%i==0 && i*i!=a)
			return false;
	}
	i-=2;
	if(i*i==a)
		return true;
	else
		return false;
}

int main(){
	ios_base::sync_with_stdio(false);
	#ifndef HESOYAM
		cin.tie(NULL);
	#endif
	int T;
	cin>>T;
	gen_squares();
	while(T-->0){
		int64_t a;
		cin>>a;
		if(t_prime(a))
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}

}


//B. T-Primes
//ravg95

#include <iostream>
#include <stdint.h>
#include <stdbool.h>
#include <cmath>
#include <cstdlib>

uint64_t square[100000001]={0};
using namespace std;

void gen_squares(){
	for(uint64_t i=3;i<100000001;i+=2)
		square[i/2-1]=(uint64_t)(i*i);
}
int compare (const void * a, const void * b){

  if ( *(uint64_t*)a <  *(uint64_t*)b ) return -1;
  if ( *(uint64_t*)a == *(uint64_t*)b ) return 0;
  if ( *(uint64_t*)a >  *(uint64_t*)b ) return 1;
}
bool t_prime(uint64_t a){
	if(a==4)return true;
	if(a<25 || a%2==0)return false;
	uint64_t* pItem ;
	pItem= (uint64_t*) bsearch (&a, square,  10000001,sizeof(uint64_t) ,(int(*)(const void*,const void*)) compare);
	if(pItem==NULL) return false;
	uint64_t i;
	for(i=3; i*i<=a;i+=2){
		if(a%i==0 && i*i!=a)
			return false;
	}
	i-=2;
	if(i*i==a)
		return true;
	else
		return false;
}

int main(){
	ios_base::sync_with_stdio(false);
	#ifndef HESOYAM
		cin.tie(NULL);
	#endif
	int T;
	cin>>T;
	gen_squares();
	while(T-->0){
		uint64_t a;
		cin>>a;
		if(t_prime(a))
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}

}


//B. T-Primes
//ravg95

#include <iostream>
#include <stdint.h>
#include <stdbool.h>
#include <cmath>

using namespace std;
int64_t isqrt(int64_t num) {
    int64_t res = 0;
    int64_t bit = 1 << 14; // The second-to-top bit is set: 1 << 30 for 32 bits

    // "bit" starts at the highest power of four <= the argument.
    while (bit > num)
        bit >>= 2;

    while (bit != 0) {
        if (num >= res + bit) {
            num -= res + bit;
            res = (res >> 1) + bit;
        }
        else
            res >>= 1;
        bit >>= 2;
    }
    return res;
}
bool prime(int64_t a){
	if(a<2)return false;
	else if(a<=3)return true;
	for(int i=2;i<isqrt(a);i++)
		if(a%i==0)return false;
	return true;

}

bool t_prime(int64_t a){
	int64_t tst = (int64_t)(isqrt(a) + 0.5);
	return(tst*tst == a && prime(tst));
}
int main(){
	ios_base::sync_with_stdio(false);
	int T;
	cin>>T;
	while(T-->0){
		int64_t a;
		cin>>a;
		if(t_prime(a))
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}

}


//B. T-Primes
//ravg95

#include <iostream>
#include <stdint.h>
#include <stdbool.h>
#include <cmath>
#include <cstdlib>

uint64_t square[10000000]={0};
using namespace std;

void gen_squares(){
	for(uint64_t i=3;i<10000000;i+=2)
		square[i/2-1]=(uint64_t)(i*i);
}
int compare (const void * a, const void * b){

  if ( *(uint64_t*)a <  *(uint64_t*)b ) return -1;
  if ( *(uint64_t*)a == *(uint64_t*)b ) return 0;
  if ( *(uint64_t*)a >  *(uint64_t*)b ) return 1;
}
bool t_prime(uint64_t a){
	if(a==4)return true;
	if(a<25 || a%2==0)return false;
	uint64_t* pItem ;
	pItem= (uint64_t*) bsearch (&a, square,  10000000,sizeof(uint64_t) ,(int(*)(const void*,const void*)) compare);
	if(pItem==NULL) return false;
	uint64_t i;
	for(i=3; i*i<=a;i+=2){
		if(a%i==0 && i*i!=a)
			return false;
	}
	i-=2;
	if(i*i==a)
		return true;
	else
		return false;
}

int main(){
	ios_base::sync_with_stdio(false);
	#ifndef HESOYAM
		cin.tie(NULL);
	#endif
	int T;
	cin>>T;
	gen_squares();
	while(T-->0){
		uint64_t a;
		cin>>a;
		if(t_prime(a))
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}

}


//B. T-Primes
//ravg95

#include <iostream>
#include <stdint.h>
#include <stdbool.h>
#include <cmath>

using namespace std;
bool prime(int64_t a){
	if(a<2)return false;
	else if(a<=3)return true;
	for(int i=2;i<sqrt(a);i++)
		if(a%i==0)return false;
	return true;

}

bool t_prime(int64_t a){
	int64_t tst = (int64_t)(sqrt(a) + 0.5);
	return(tst*tst == a && prime(tst));
}
int main(){
	ios_base::sync_with_stdio(false);
	int T;
	cin>>T;
	while(T-->0){
		int64_t a;
		cin>>a;
		if(t_prime(a))
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}

}


//B. T-Primes
//ravg95

#include <iostream>
#include <stdint.h>
#include <stdbool.h>
#include <cmath>

using namespace std;
bool square(uint64_t a){
	long double b=floor(sqrt((long double)a)+0.5);
	return (b*b==a);
}
bool t_prime(uint64_t a){
	if(!square(a))return false;
	if(a<=3)
		return false;
	if(a==4 || a==9)
		return true;
	if(a%2==0)
		return false;
	if((a>4 && a<9)||(a>9 && a<25))
		return false;
	int64_t i;
	for(i=5;i*i<=a;i+=2){
		if(a%i==0 && i*i!=a)
			return false;
		//if(i*i*i*i>=a&&i*i<=a)break;
	}
	i-=2;
	if(i*i==a)
		return true;
	else return false;
}
int main(){
	ios_base::sync_with_stdio(false);
	#ifndef HESOYAM
		cin.tie(NULL);
	#endif
	int T;
	cin>>T;
	while(T-->0){
		uint64_t a;
		cin>>a;
		if(t_prime(a))
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}

}


//B. T-Primes
//ravg95

#include <iostream>
#include <stdint.h>
#include <stdbool.h>
#include <cmath>
#include <cstdlib>

uint64_t square[1000000]={0};
using namespace std;

void gen_squares(){
	for(int i=0;i<1000000;i++)
		square[i]=i*i;
}
int compare (const void * a, const void * b){

  if ( *(uint64_t*)a <  *(uint64_t*)b ) return -1;
  if ( *(uint64_t*)a == *(uint64_t*)b ) return 0;
  if ( *(uint64_t*)a >  *(uint64_t*)b ) return 1;
}
bool t_prime(uint64_t a){
	if(a<=3)return false;
	uint64_t* pItem ;
	pItem= (uint64_t*) bsearch (&a, square,  1000000,sizeof(uint64_t) ,(int(*)(const void*,const void*)) compare);
	if(pItem==NULL) return false;
	int n = (int)(pItem-square);
	for(int i=2; i*i<=n;i++){
		if(n%i==0)return false;
	}
	return true;
}

int main(){
	ios_base::sync_with_stdio(false);
	#ifndef HESOYAM
		cin.tie(NULL);
	#endif
	int T;
	cin>>T;
	gen_squares();
	while(T-->0){
		uint64_t a;
		cin>>a;
		if(t_prime(a))
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}

}


//B. T-Primes
//ravg95

#include <iostream>
#include <stdint.h>
#include <stdbool.h>
#include <cmath>

using namespace std;
bool square(uint64_t a){
	long double b=floor(sqrt((long double)a)+0.5);
	return ((uint64_t)(b*b)==a);
}
bool t_prime(uint64_t a){
	if(!square(a))return false;
	if(a<=3)
		return false;
	if(a==4 || a==9)
		return true;
	if(a%2==0)
		return false;
	if((a>4 && a<9)||(a>9 && a<25))
		return false;
	int64_t i;
	for(i=5;i*i<=a;i+=2){
		if(a%i==0 && i*i!=a)
			return false;
		//if(i*i*i*i>=a&&i*i<=a)break;
	}
	i-=2;
	if(i*i==a)
		return true;
	else return false;
}
int main(){
	ios_base::sync_with_stdio(false);
	#ifndef HESOYAM
		cin.tie(NULL);
	#endif
	int T;
	cin>>T;
	while(T-->0){
		uint64_t a;
		cin>>a;
		if(t_prime(a))
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}

}


//B. T-Primes
//ravg95

#include <iostream>
#include <stdint.h>
#include <stdbool.h>
#include <cstdlib>

uint64_t square[500001]={0};
using namespace std;

void gen_squares(){
	for(uint64_t i=3;i<1000000;i+=2)
		square[i/2-1]=(uint64_t)(i*i);
}
int compare (const void * a, const void * b){

  if ( *(uint64_t*)a <  *(uint64_t*)b ) return -1;
  else if ( *(uint64_t*)a == *(uint64_t*)b ) return 0;
  else return 1;

}
bool t_prime(uint64_t a){
	if(a==4 || a==9)return true;
	if(a<9 || a%2==0)return false;
	uint64_t* pItem ;
	pItem= (uint64_t*) bsearch (&a, square,  500001,sizeof(uint64_t) ,(int(*)(const void*,const void*)) compare);
	if(pItem==NULL) return false;
	uint64_t i=(pItem - square +1)*2 +1;
	for(uint64_t j=2;j*j <=i;j++){
		if(i%j==0){
			return false;
		}
	}
	/*
	for(i=3; i*i<=a;i+=2){
		if(a%i==0 && i*i!=a)
			return false;
	}
	i-=2;
	if(i*i==a)
		return true;
	else
		return false;
	*/
	return true;
}

int main(){
	ios_base::sync_with_stdio(false);
	#ifndef HESOYAM
		cin.tie(NULL);
	#endif
	int T;
	cin>>T;
	gen_squares();
	while(T-->0){
		uint64_t a;
		cin>>a;
		if(t_prime(a))
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}

}


//B. T-Primes
//ravg95

#include <iostream>
#include <stdint.h>
#include <stdbool.h>
#include <cmath>
#include <cstdlib>

uint64_t square[1000000/2]={0};
using namespace std;

void gen_squares(){
	for(uint64_t i=3;i<1000000;i+=2)
		square[i/2-1]=(uint64_t)(i*i);
}
int compare (const void * a, const void * b){

  if ( *(int64_t*)a <  *(int64_t*)b ) return -1;
  else if ( *(int64_t*)a == *(int64_t*)b ) return 0;
  else return 1;

}
bool t_prime(uint64_t a){
	if(a==4 || a==9)return true;
	if(a<25 || a%2==0)return false;
	uint64_t* pItem ;
	pItem= (uint64_t*) bsearch (&a, square,  1000000/2,sizeof(uint64_t) ,(int(*)(const void*,const void*)) compare);
	if(pItem==NULL) return false;
	uint64_t i;
	for(i=5; i*i<=a;i+=2){
		if(a%i==0 && i*i!=a)
			return false;
	}
	i-=2;
	if(i*i==a)
		return true;
	else
		return false;
}

int main(){
	ios_base::sync_with_stdio(false);
	#ifndef HESOYAM
		cin.tie(NULL);
	#endif
	int T;
	cin>>T;
	gen_squares();
	while(T-->0){
		uint64_t a;
		cin>>a;
		if(t_prime(a))
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}

}


//B. T-Primes
//ravg95

#include <iostream>
#include <stdint.h>
#include <stdbool.h>
#include <cmath>

using namespace std;

bool t_prime(uint64_t a){
	uint64_t i;
	if(a<=3)return false;
	for(i=2;i*i<=a;i++){
		if(a%i==0 && i*i!=a)
			return false;
	}
	i--;
	if(a==i*i)
		return true;
	else
		return false;
}
int main(){
	ios_base::sync_with_stdio(false);
	#ifndef HESOYAM
		cin.tie(NULL);
	#endif
	int T;
	cin>>T;
	while(T-->0){
		uint64_t a;
		cin>>a;
		if(t_prime(a))
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}

}


//B. T-Primes
//ravg95

#include <iostream>
#include <stdint.h>
#include <stdbool.h>
#include <cmath>

using namespace std;
bool square(uint64_t a){
	if(a>1<<31)return true;
	long double b=floor(sqrt((long double)a)+0.5);
	return ((uint64_t)(b*b)==a);
}
bool t_prime(uint64_t a){
	if(!square(a))return false;
	if(a<=3)
		return false;
	if(a==4 || a==9)
		return true;
	if(a%2==0)
		return false;
	if((a>4 && a<9)||(a>9 && a<25))
		return false;
	int64_t i;
	for(i=5;i*i<=a;i+=2){
		if(a%i==0 && i*i!=a)
			return false;
	}
	i-=2;
	if(i*i==a)
		return true;
	else return false;
}
int main(){
	ios_base::sync_with_stdio(false);
	#ifndef HESOYAM
		cin.tie(NULL);
	#endif
	int T;
	cin>>T;
	while(T-->0){
		uint64_t a;
		cin>>a;
		if(t_prime(a))
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}

}


//230B
//ravg95

#include <iostream>
#include <stdint.h>
#include <stdbool.h>
#include <cstdlib>

int64_t square[500001]={0};
using namespace std;

void gen_squares(){
	for(int64_t i=3;i<1000000;i+=2)
		square[i/2-1]=(int64_t)(i*i);
	}
int compare (const void * a, const void * b){

	if ( *(int64_t*)a <  *(int64_t*)b ) return -1;
	else if ( *(int64_t*)a == *(int64_t*)b ) return 0;
	else return 1;

}
bool t_prime(int64_t a){
	if(a==4 || a==9)
		return true;
	if(a<9 || a%2==0)
		return false;
	int64_t* pItem ;
	pItem= (int64_t*) bsearch (&a, square,  500001,sizeof(int64_t) ,(int(*)(const void*,const void*)) compare);
	if(pItem==NULL) return false;
		int64_t i=(pItem - square +1)*2 +1;
	for(int64_t j=2;j*j <=i;j++){
		if(i%j==0){
			return false;
		}
	}
	return true;
}

int main(){

	ios_base::sync_with_stdio(false);
	#ifndef HESOYAM
		cin.tie(NULL);
	#endif
	int T;
	cin>>T;
	gen_squares();
	while(T-->0){
		int64_t a;
		cin>>a;
		if(t_prime(a))
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}

}


//B. T-Primes
//ravg95

#include <iostream>
#include <stdint.h>
#include <stdbool.h>
#include <cmath>

using namespace std;

bool t_prime(uint64_t a){
	uint64_t i;
	for(i=2;i*i<=a;i++){
		if(a%i==0 && i*i!=a)
			return false;
	}
	i--;
	if(a==i*i)
		return true;
	else
		return false;
}
int main(){
	ios_base::sync_with_stdio(false);
	#ifndef HESOYAM
		cin.tie(NULL);
	#endif
	int T;
	cin>>T;
	while(T-->0){
		uint64_t a;
		cin>>a;
		if(t_prime(a))
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}

}


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
    int b[10000],g[10000];
    char c[1];
    long long int i,n,m,sum=0,ans,t,j;
    while(scanf("%I64d",&t)!=EOF)
    {
    sum=0;
    memset(b,0,sizeof(b));
    memset(g,0,sizeof(g));
    for(i=0; i<t; i++)
    {

        scanf("%s%I64d%I64d",c,&n,&m);
        //printf("%s %d %d\n",c,n,m);
        if(c[0]=='M')
        {
            for(j=n; j<=m; j++)
            {
                b[j]++;
            }
        }
        else if(c[0]=='F')
        {
            for(j=n; j<=m; j++)
            {
                g[j]++;
            }
        }
    }
    for(i=1; i<=366; i++)
    {
        if(g[i]<=b[i])
        {
        if(g[i]>sum)
        sum=g[i];
        }
        else if(b[i]<=g[i]&&b[i]>sum)
                sum=b[i];
    }
    sum=sum*2;
    printf("%I64d\n",sum);
    }
    return 0;
}
/*2016-05-08 20:18:08.395*/


#include <iostream>
#include <stdio.h>
#include <string.h>
#define MAX 5030
using namespace std;
int main()
{
    int K,N,M,i,j,a,b;
    char c;
    while(scanf("%d",&N)!=EOF){
        int P1=1,P2=1;
        int M[1111]={0},F[1111]={0};
        for(i=0;i<N;i++){
            scanf(" %c%d%d",&c,&a,&b);
            if(c=='M'){
                for(j=a;j<=b;j++)M[j]++;
            }else {
                 for(j=a;j<=b;j++)F[j]++;
            }
        }
        int Sum=0;
        for(i=1;i<=366;i++){
            Sum=max(min(F[i],M[i]),Sum);
        }
        printf("%d\n",Sum*2);
    }
    return 0;
}
/*2016-05-08 19:54:23.485*/


#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
    int b[10000],g[10000];
    char c[1];
    long long int i,n,m,sum=0,ans,t;
    while(scanf("%I64d",&t)!=EOF)
    {
    sum=0;
    memset(b,0,sizeof(b));
    memset(g,0,sizeof(g));
    for(i=0; i<t; i++)
    {

        scanf("%s%I64d%I64d",c,&n,&m);
        //printf("%s %d %d\n",c,n,m);
        if(c[0]=='M')
        {
            for(int j=n; j<=m; j++)
            {
                b[j]++;
            }
        }
        else if(c[0]=='F')
        {
            for(int j=n; j<=m; j++)
            {
                g[j]++;
            }
        }
    }
    for(i=1; i<=366; i++)
    {
        if(g[i]<=b[i])
            if(g[i]>sum)
                sum=g[i];
            else if(b[i]<=g[i])
                if(b[i]>sum)
                    sum=b[i];
    }
    sum=sum*2;
    printf("%I64d\n",sum);
    }
    return 0;
}
/*2016-05-08 20:12:28.284*/


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <queue>
#include <string>
#include <set>
#include <stack>
#include <map>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#define Maxn 100005

int a[5005],b[5005],f1[400],f2[400];
char s[2];
int main()
{
    int n,m;
    //freopen("1.in","r",stdin);
    //freopen("10.out","w",stdout);
    while(scanf("%d",&n)!=EOF)
    {
        memset(f1,0,sizeof(f1));
        memset(f2,0,sizeof(f2));
        for(int i=0;i<n;i++){
            scanf("%s%d%d",s,&a[i],&b[i]);
            if(s[0]=='M'){
                f1[a[i]]++;
                f1[b[i]+1]--;
            }else{
                f2[a[i]]++;
                f2[b[i]+1]--;
            }

        }

        for(int i=1;i<367;i++){
            f1[i]=f1[i]+f1[i-1];
            f2[i]=f2[i]+f2[i-1];
        }
        int max=0;
        for(int i=1;i<367;i++){
            if(f1[i]<f2[i]){
                if(max<f1[i])max=f1[i];
            }else{
                if(max<f2[i])max=f2[i];
            }
        }

        printf("%d\n",max*2);
    }
    return 0;
}
/*2016-05-08 19:17:11.991*/


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <queue>
#include <string>
#include <set>
#include <stack>
#include <map>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#define Maxn 100005

int a[5005],b[5005],f[400];
char s[2];
int main()
{
    int n,m;
    //freopen("1.in","r",stdin);
    //freopen("10.out","w",stdout);
    while(scanf("%d",&n)!=EOF)
    {
        memset(f,0,sizeof(f));
        for(int i=0;i<n;i++){
            scanf("%s%d%d",s,&a[i],&b[i]);
            f[a[i]]++;
            f[b[i]+1]--;
        }

        for(int i=1;i<367;i++){
            f[i]=f[i]+f[i-1];
        }
        int max=0;
        for(int i=1;i<367;i++){
            if(max<f[i])
            max=f[i];
        }

        printf("%d\n",max);
    }
    return 0;
}
/*2016-05-08 19:11:11.663*/


#include <bits/stdc++.h>
#define FORE(i, a, b) for(int i = a; i <= b; ++i)
#define FORD(i, a, b) for(int i = a; i >= b; --i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define X first
#define Y second
#define long long long
const int MAXN = 1e5 * 5;
const int INF = 1e9 + 7;
const int N = 5000;

using namespace std;
int n,a1[500],a2[500],ans;
int d,c;
char ch;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("629b.inp", "r", stdin);
    freopen("629b.out", "w", stdout);
    #endif //GIANGPRO
    cin>>n;
    FORE(i,1,n)
    {
        cin>>ch;
        cin>>d>>c;
        if (ch=='F') ++a1[d],--a1[c+1];
        else ++a2[d],--a2[c+1];
    }
    FORE(i,1,366) a1[i]+=a1[i-1],a2[i]+=a2[i-1];
    FORE(i,1,366)
    if (a1[i]==a2[i]) ans=max(ans,a1[i]*2);//,cout<<i<<endl;
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
#define FORE(i, a, b) for(int i = a; i <= b; ++i)
#define FORD(i, a, b) for(int i = a; i >= b; --i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define X first
#define Y second
#define long long long
const int MAXN = 1e5 * 5;
const int INF = 1e9 + 7;
const int N = 5000;

using namespace std;
int n,a1[500],a2[500],ans;
int d,c;
char ch;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("629b.inp", "r", stdin);
    freopen("629b.out", "w", stdout);
    #endif //GIANGPRO
    cin>>n;
    FORE(i,1,n)
    {
        cin>>ch;
        cin>>d>>c;
        if (ch=='F') FORE(j,d,c) ++a1[j];
        else FORE(j,d,c) ++a2[j];
    }
    FORE(i,1,366)
    if (a1[i]==a2[i]) ans=max(ans,a1[i]*2);//,cout<<i<<endl;
    //cout<<ans;
    cout<<0;
    return 0;
}


#include <bits/stdc++.h>
#define FORE(i, a, b) for(int i = a; i <= b; ++i)
#define FORD(i, a, b) for(int i = a; i >= b; --i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define X first
#define Y second
#define long long long
const int MAXN = 1e5 * 5;
const int INF = 1e9 + 7;
const int N = 5000;

using namespace std;
int n,a1[500],a2[500],ans;
int d,c;
char ch;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("629b.inp", "r", stdin);
    freopen("629b.out", "w", stdout);
    #endif //GIANGPRO
    cin>>n;
    FORE(i,1,n)
    {
        cin>>ch;
        cin>>d>>c;
        if (ch=='F') FORE(j,d,c) ++a1[j];
        else FORE(j,d,c) ++a2[j];
    }
    FORE(i,1,366)
    if (a1[i]==a2[i]) ans=max(ans,a1[i]*2);//,cout<<i<<endl;
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
#define FORE(i, a, b) for(int i = a; i <= b; ++i)
#define FORD(i, a, b) for(int i = a; i >= b; --i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define X first
#define Y second
#define long long long
const int MAXN = 1e5 * 5;
const int INF = 1e9 + 7;
const int N = 5000;

using namespace std;
int n,a1[500],a2[500],ans;
int d,c;
char ch;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("629b.inp", "r", stdin);
    freopen("629b.out", "w", stdout);
    #endif //GIANGPRO
    cin>>n;
    FORE(i,1,n)
    {
        cin>>ch;
        cin>>d>>c;
        if (ch=='F') FORE(j,d,c) ++a1[j];
        else FORE(j,d,c) ++a2[j];
    }
    FORE(i,1,366) ans=max(ans,2*min(a1[i],a2[i]));//,cout<<i<<endl;
    //cout<<ans;
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
#define FORE(i, a, b) for(int i = a; i <= b; ++i)
#define FORD(i, a, b) for(int i = a; i >= b; --i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define X first
#define Y second
#define long long long
const int MAXN = 1e5 * 5;
const int INF = 1e9 + 7;
const int N = 5000;

using namespace std;
int n,a1[500],a2[500],ans;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("629b.inp", "r", stdin);
    freopen("629b.out", "w", stdout);
    #endif //GIANGPRO
    cin>>n;
    FORE(i,1,n)
    {
        int d,c;
        char ch;
        cin>>ch;
        cin>>d>>c;
        if (ch=='F') ++a1[d],--a1[c+1];
        else ++a2[d],--a2[c+1];
    }
    FORE(i,1,366) a1[i]+=a1[i-1],a2[i]+=a2[i-1];
    FORE(i,1,366)
    if (a1[i]==a2[i]) ans=max(ans,a1[i]*2);
    cout<<ans;
    return 0;
}


#include<iostream>
#include<stdio.h>

using namespace std;

struct Person{

    int left, right;
    char gender;
    Person(){}
    Person( char a, int b, int c){
        gender=a; left=b; right=c;
    }
};

Person data[5001];
int n;

int main(){

    //freopen("inputt.in","r",stdin);
    scanf("%d",&n);
    char gender;
    int left,right;
    for(int i=0;i<n;i++){
        scanf(" %c",&gender);
        scanf("%d %d",&left,&right);
        data[i]=Person(gender,left,right);
    }

    int mx=0,male,female;
    int rr,ll;
    for(int i=0;i<n;i++){
        male=female=0;
        if( data[i].gender=='M') male++;
        else female++;
        ll=data[i].left;
        rr=data[i].right;

        for(int j=i+1;j<n;j++){
            if(i==j) continue;
            if( ( data[j].left>=ll && data[j].left<=rr) || (data[j].right>=ll && data[j].right<=rr) ){
                if( data[j].gender=='M') male++;
                else female++;
            }
        }
        if( male==female) mx=max(mx,2*male);
    }
    printf("%d\n",mx);
    return 0;
}


#include<iostream>
#include<stdio.h>

using namespace std;

struct Person{

    int left, right;
    char gender;
    Person(){}
    Person( char a, int b, int c){
        gender=a; left=b; right=c;
    }
};

Person data[5001];
int n;

int main(){

    //freopen("inputt.in","r",stdin);
    scanf("%d",&n);
    char gender;
    int left,right;
    for(int i=0;i<n;i++){
        scanf(" %c",&gender);
        scanf("%d %d",&left,&right);
        data[i]=Person(gender,left,right);
    }

    int mx=0,male,female;
    for(int i=0;i<n;i++){
        male=female=0;
        if( data[i].gender=='M') male++;
        else female++;
        for(int j=0;j<n;j++){
            if(i==j) continue;
            if( ( data[j].left>=data[i].left && data[j].left<=data[i].right ) || (data[j].right>=data[i].left && data[j].right<=data[i].right ) ){
                if( data[j].gender=='M') male++;
                else female++;
            }
        }
        if( male==female) mx=max(mx,2*male);
    }
    printf("%d\n",mx);
    return 0;
}


#include<iostream>
#include<stdio.h>

using namespace std;

struct Person{

    int left, right;
    char gender;
    Person(){}
    Person( char a, int b, int c){
        gender=a; left=b; right=c;
    }
};

Person data[5001];
int n;

int main(){

    //freopen("inputt.in","r",stdin);
    scanf("%d",&n);
    char gender;
    int left,right;
    for(int i=0;i<n;i++){
        scanf(" %c",&gender);
        scanf("%d %d",&left,&right);
        data[i]=Person(gender,left,right);
    }

    int mx=0,male,female;
    int rr,ll;
    for(int i=0;i<n;i++){
        male=female=0;
        if( data[i].gender=='M') male++;
        else female++;
        ll=data[i].left;
        rr=data[i].right;

        for(int j=i+1;j<n;j++){
            if(i==j) continue;
            if( ( data[j].left>=ll && data[j].left<=rr) || (data[j].right>=ll && data[j].right<=rr) ){
                if( data[j].gender=='M') male++;
                else female++;
                ll=max(data[j].left,ll);
                rr=min(data[j].right,rr);
            }
        }
        if( male==female) mx=max(mx,2*male);
    }
    printf("%d\n",mx);
    return 0;
}


#include<iostream>
#include<stdio.h>

using namespace std;

struct Person{

    int left, right;
    char gender;
    Person(){}
    Person( char a, int b, int c){
        gender=a; left=b; right=c;
    }
};

Person data[5001];
int n;

int main(){

    //freopen("inputt.in","r",stdin);
    scanf("%d",&n);
    char gender;
    int left,right;
    for(int i=0;i<n;i++){
        scanf(" %c",&gender);
        scanf("%d %d",&left,&right);
        data[i]=Person(gender,left,right);
       //printf("%c %d %d\n",data[i].gender,data[i].left,data[i].right );
    }

    int mx=0,male,female;
    int rr,ll;
    for(int i=0;i<n;i++){
        male=female=0;
        if( data[i].gender=='M') male++;
        else female++;
        ll=data[i].left;
        rr=data[i].right;

        for(int j=i+1;j<n;j++){
            if(i==j) continue;
            if( ( data[j].left>=ll && data[j].left<=rr) || (data[j].right>=ll && data[j].right<=rr) ){
                if( data[j].gender=='M') male++;
                else female++;

                ll=max(data[j].left,ll);
                rr=min(data[j].right,rr);
                //cout<<i<<" "<<j<<endl;
                //if(i==2) cout<<ll<<" "<<rr<<endl;
            }
        }
        if( male==female) mx=max(mx,2*male);
    }
    printf("%d\n",mx);
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

struct Person{
    char gender;
    int left,right;
    Person(){}
    Person(char a,int b,int c){
        gender=a;left=b;right=c;
    }

};

Person data[5001];

int main(){

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

    //freopen("inputt.in","r",stdin);
    int n,male,female,left,right,mx=0;
    char gender;
    cin>>n;

    for(int i=0;i<n;i++){
        cin>>gender>>left>>right;
        data[i]=Person(gender,left,right);
    }

    for(int i=1;i<=366;i++){
        male=female=0;
        for(int j=0;j<n;j++){
            if(i>=data[j].left && i<=data[j].right){
                if( data[j].gender=='M') male++;
                else female++;
            }
        }
        mx=max(mx,min(male,female));
    }
    cout<<2*mx<<endl;
    return 0;
}


/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REPAB(i, j , k) FOR(i, j, k, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
//#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)

#define NC2(N) ((N*(N-1))/2)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SZ(A) (A.size())
#define PRINT2D(X,Y) REP(i,SZ(X)){ REP(j,SZ(X)){ cout << Y[i][j] << " "; } cout << endl; }
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

int main(){
    int N;
    int m[367],f[367];
    cin >> N;
    int S,E;
    char G;
    REP(i,367){
        m[i] =f[i] = 0;
    }
    REP(i,N){
        cin >> G >> S >> E;
        if(G == 'M'){
            for(int j =S;j<=E;j++){
                m[j]++;
            }
        } else {
            for(int j =S;j<=E;j++){
                f[j]++;
            }
        }
    }
    int visitors = 0;
    REPAB(i,1,366){
            visitors = max(min(m[i],f[i]),visitors);
    }
    cout << visitors * 2;
}


/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REPAB(i, j , k) FOR(i, j, k, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
//#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)

#define NC2(N) ((N*(N-1))/2)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SZ(A) (A.size())
#define PRINT2D(X,Y) REP(i,SZ(X)){ REP(j,SZ(X)){ cout << Y[i][j] << " "; } cout << endl; }
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

int main(){
    int N;
    int m[367],f[367];
    cin >> N;
    int S,E;
    char G;
    REP(i,366){
        m[i] =f[i] = 0;
    }
    REP(i,N){
        cin >> G >> S >> E;
        if(G == 'M'){
            REPAB(j,S,E+1){
                m[j]++;
            }
        } else {
            REPAB(j,S,E+1){
                f[j]++;
            }
        }
    }
    int visitors = 0;
    REP(i,366){
            visitors = max(min(m[i],f[i]),visitors);
    }
    cout << visitors * 2;
}


/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REPAB(i, j , k) FOR(i, j, k, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
//#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)

#define NC2(N) ((N*(N-1))/2)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SZ(A) (A.size())
#define PRINT2D(X,Y) REP(i,SZ(X)){ REP(j,SZ(X)){ cout << Y[i][j] << " "; } cout << endl; }
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

int main(){
    int N;
    int m[366],f[366];
    cin >> N;
    int S,E;
    char G;
    REP(i,366){
        m[i] =f[i] = 0;
    }
    REP(i,N){
        cin >> G >> S >> E;
        if(G == 'M'){
            REPAB(j,S,E+1){
                m[j]++;
            }
        } else {
            REPAB(j,S,E+1){
                f[j]++;
            }
        }
    }
    int visitors = 0;
    REP(i,366){
        visitors = max(min(m[i],f[i]),visitors);
    }
    cout << visitors * 2;
}


/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REPAB(i, j , k) FOR(i, j, k, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
//#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)

#define NC2(N) ((N*(N-1))/2)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SZ(A) (A.size())
#define PRINT2D(X,Y) REP(i,SZ(X)){ REP(j,SZ(X)){ cout << Y[i][j] << " "; } cout << endl; }
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

int main(){
    int N;
    int m[367],f[367];
    cin >> N;
    int S,E;
    char G;
    REP(i,367){
        m[i] =f[i] = 0;
    }
    REP(i,N){
        cin >> G >> S >> E;
        if(G == 'M'){
            for(int j =S;j<=E;j++){
                m[j]++;
            }
        } else {
            for(int j =S;j<=E;j++){
                f[j]++;
            }
        }
    }
    int visitors = 0;
    REPAB(i,1,367){
            visitors = max(min(m[i],f[i]),visitors);
    }
    cout << visitors * 2;
}


/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REPAB(i, j , k) FOR(i, j, k, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
//#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)

#define NC2(N) ((N*(N-1))/2)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SZ(A) (A.size())
#define PRINT2D(X,Y) REP(i,SZ(X)){ REP(j,SZ(X)){ cout << Y[i][j] << " "; } cout << endl; }
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

int main(){
    int N;
    int m[367],f[367];
    cin >> N;
    int S,E;
    char G;
    REP(i,367){
        m[i] =f[i] = 0;
    }
    REP(i,N){
        cin >> G >> S >> E;
        if(G == 'M'){
            REPAB(j,S,E+1){
                m[j]++;
            }
        } else {
            REPAB(j,S,E+1){
                f[j]++;
            }
        }
    }
    int visitors = 0;
    REPAB(i,1,366){
            visitors = max(min(m[i],f[i]),visitors);
    }
    cout << visitors * 2;
}


/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REPAB(i, j , k) FOR(i, j, k, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
//#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)

#define NC2(N) ((N*(N-1))/2)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SZ(A) (A.size())
#define PRINT2D(X,Y) REP(i,SZ(X)){ REP(j,SZ(X)){ cout << Y[i][j] << " "; } cout << endl; }
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

int main(){
    int N;
    int m[366],f[366];
    cin >> N;
    int S,E;
    char G;
    REP(i,366){
        m[i] =f[i] = 0;
    }
    REP(i,N){
        cin >> G >> S >> E;
        if(G == 'M'){
            REPAB(j,S,E+1){
                m[j]++;
            }
        } else {
            REPAB(j,S,E+1){
                f[j]++;
            }
        }
    }
    int visitors = 0;
    REP(i,366){
        if(f[i] == m[i])
            visitors = max(min(m[i],f[i])*2,visitors);
        else
            visitors = max(min(m[i],f[i]) * 2 + 1,visitors);
    }
    cout << visitors;
}


/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REPAB(i, j , k) FOR(i, j, k, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
//#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)

#define NC2(N) ((N*(N-1))/2)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SZ(A) (A.size())
#define PRINT2D(X,Y) REP(i,SZ(X)){ REP(j,SZ(X)){ cout << Y[i][j] << " "; } cout << endl; }
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

int main(){
    int N;
    int m[367],f[367];
    cin >> N;
    int S,E;
    char G;
    REP(i,367){
        m[i] =f[i] = 0;
    }
    REP(i,N){
        cin >> G >> S >> E;
        if(G == 'M'){
            for(int j =S;j<=E;j++){
                m[j]++;
            }
        } else {
            for(int j =S;j<=E;j++){
                f[j]++;
            }
        }
    }
    int visitors = 0;
    for(int i =1;i<=366;i++){
            visitors = max(min(m[i],f[i]),visitors);
    }
    cout << visitors * 2;
}


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
using namespace std;
int i,j,k,v,n,t,r,u,res,x,y,a,b,m[400],h[400];
char w;
int main()
{
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf(" %c", &w);
		scanf("%d%d", &a, &b);
		if (w== 'M')
		{
			m[a]=1;
			m[b+1] = -1;
		}
		else
		{
			h[a] = 1;
			h[b+1]=-1;
		}
	}
	for (i = 1; i <= 367; i++) {
		m[i] += m[i - 1];
		h[i] += h[i - 1];
	}
	for (i = 1; i <= 367; i++)
	{
		if(h[i]>0 && m[i]>0)
		res = max(res, h[i] + m[i]);
	}
	printf("%d\n", res);
}


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
using namespace std;
int i,j,k,v,n,t,r,u,res,x,y,a,b,m[400],h[400];
char w;
int main()
{
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf(" %c", &w);
		scanf("%d%d", &a, &b);
		if (w== 'M')
		{
			m[a]=1;
			m[b+1] = -1;
		}
		else
		{
			h[a] = 1;
			h[b+1]=-1;
		}
	}
	for (i = 1; i <= 367; i++) {
		m[i] += m[i - 1];
		h[i] += h[i - 1];
	}
	for (i = 1; i <= 367; i++)
	{
		res = max(res, h[i] + m[i]);
	}
	printf("%d\n", res);
}


#include <cstdio>
int notSame[368], cnt[368];
int n;

int main()
{
	int start = 368;
	int end = -1;
	scanf("%d", &n);
	getchar();
	for(int i=0;i<n;i++)
	{
		char s;
		int a, b;
		scanf("%c %d %d", &s, &a, &b);
		getchar();

		if(start > a) start = a;
		if(end < b) end = b;

		for(int j=a;j<=b;j++)
			if(s == 'M') {notSame[j]++, cnt[j]++;}
			else {notSame[j]--, cnt[j]++;}
	}

	int sol = 0;
	for(int i=start;i<=end;i++)
		if(!notSame[i] && sol < cnt[i]) sol = cnt[i];

	printf("%d\n", sol);
}


#include <cstdio>
#include <iostream>
#define max(a,b) ((a)<(b)?(b):(a))
#define min(a,b) ((a)<(b)?(a):(b))
using namespace std;
int f_cnt[368], m_cnt[368];
int n;

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0;i<n;i++)
	{
		char s;
		int a, b;
		cin >> s >>  a >> b;

		for(int j=a;j<=b;j++)
			if(s == 'M') m_cnt[j]++;
			else f_cnt[j]++;
	}

	int sol = 0;
	for(int i=1;i<=366;i++)
		sol = max(sol, 2*min(f_cnt[i], m_cnt[i]));

	cout << sol;
}


#include <cstdio>
int notSame[68], cnt[368];
int n;

int main()
{
	int start = 368;
	int end = -1;
	scanf("%d", &n);
	getchar();
	for(int i=0;i<n;i++)
	{
		char s;
		int a, b;
		scanf("%c %d %d", &s, &a, &b);
		getchar();

		if(start > a) start = a;
		if(end < b) end = b;

		for(int j=a;j<=b;j++)
			if(s == 'M') {notSame[j]++, cnt[j]++;}
			else {notSame[j]--, cnt[j]++;}
	}

	int sol = 0;
	for(int i=start;i<=end;i++)
		if(!notSame[i] && sol < cnt[i]) sol = cnt[i];

	printf("%d\n", sol);
}


#include <cstdio>
int notSame[368], cnt[368];
int n;

int main()
{
	int start = 368;
	int end = -1;
	scanf("%d", &n);
	getchar();
	for(int i=0;i<n;i++)
	{
		char s;
		int a, b;
		scanf("%c %d %d", &s, &a, &b);
		getchar();

		if(start > a) start = a;
		if(end < b) end = b;

		for(int j=a;j<=b;j++)
			if(s == 'M') {notSame[j]++, cnt[j]++;}
			else {notSame[j]--, cnt[j]++;}
	}

	int sol = 0;
	for(int i=1;i<=366;i++)
		if(!notSame[i] && sol < cnt[i]) sol = cnt[i];

	printf("%d\n", sol);
}


#include <cstdio>
#include <iostream>
#define max(a,b) ((a)<(b)?(b):(a))
using namespace std;
int notSame[368], cnt[368];
int n;

int main()
{
	cin >> n;
	for(int i=0;i<n;i++)
	{
		char s;
		int a, b;
		cin >> s >>  a >> b;

		for(int j=a;j<=b;j++)
			if(s == 'M') {notSame[j]++, cnt[j]++;}
			else {notSame[j]--, cnt[j]++;}
	}

	int sol = 0;
	for(int i=1;i<=366;i++)
		if(!notSame[i]) sol = max(sol, cnt[i]);

	printf("%d\n", sol);
}


#include <cstdio>
#include <iostream>
#define max(a,b) ((a)<(b)?(b):(a))
#define min(a,b) ((a)<(b)?(a):(b))
using namespace std;
int notSame[368], f_cnt[368], m_cnt[368];
int n;

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0;i<n;i++)
	{
		char s;
		int a, b;
		cin >> s >>  a >> b;

		for(int j=a;j<=b;j++)
			if(s == 'M') {notSame[j]++, m_cnt[j]++;}
			else {notSame[j]--, f_cnt[j]++;}
	}

	int sol = 0;
	for(int i=1;i<=366;i++)
		if(!notSame[i]) sol = max(sol, 2*min(f_cnt[i], m_cnt[i]));

	cout << sol;
}


#include <iostream>
#include <cstdio>
#include <vector>
#define max(a,b) ((a)<(b)?(b):(a))
#define min(a,b) ((a)<(b)?(a):(b))
typedef struct{
	char sex;
	int a, b;
}person;
using namespace std;
vector<person> p;
int n;

int main()
{
	cin >> n;
	p.resize(n+1);

	for(int i=0;i<n;i++) cin >> p[i].sex >> p[i].a >> p[i].b;

	int sol = 0;
	for(int i=1;i<367;i++)
	{
		int f_cnt = 0, m_cnt = 0;
		for(int j=0;j<n;j++)
			if(p[j].a <= i && p[j].b >= i)
				p[j].sex == 'M' ? m_cnt++ : f_cnt++;

		sol = max(sol, 2*min(f_cnt, m_cnt));
	}

	cout << sol;
}


#include <iostream>
#include <cstdio>
using namespace std;
const int N = 5100;
int fa[N], fb[N], ma[N], mb[N];

int main()
{
    int n, f = 0, m = 0;
    cin >> n;
    for(int i = 0;i < n; ++i)
    {
        char ch;
        cin >> ch;
        if(ch == 'F')
            cin >> fa[f] >> fb[f ++];
        else
            cin >> ma[m] >> mb[m ++];
    }
    int sum = 0;
    for(int i = 0;i < f; ++i)
        for(int j = 0;j < m; ++j)
           if((fa[i] <= ma[j] && fb[i] >= ma[j])
            || (fb[i] >= mb[j] && fa[i] <= mb[j]))
            {
                sum += 2;
                ma[j] = mb[j] = -1;
                break;
            }
    cout << sum;
}


#include <iostream>
#include <cstdio>
using namespace std;
const int N = 400;
int f[N], m[N];
int main()
{
    int n;
    cin >> n;
    for(int i = 0;i < n; ++i)
    {
        char ch;
        int a, b;
        cin >> ch >> a >> b;
        for(int j = a; j <= b; ++j)
        {
            if(ch == 'F')
                f[j] ++;
            else m[j] ++;
        }
    }
    int ans = -1;
    for(int i = 0; i < n; ++i)
        ans = max(ans, min(f[j], m[j]));
    cout << ans * 2;
}


#include <iostram>
#include <cstdio>

const int N = 5100;
int fa[N], fb[N], ma[N], mb[N];

int main()
{
    int n, f = 0, m = 0;
    cin >> n;
    for(int i = 0;i < n; ++i)
    {
        char ch;
        cin >> ch;
        if(ch == 'F')
            cin >> fa[f] >> fb[f ++];
        else
            cin >> ma[m] >> mb[m ++];
    }
    int sum = 0;
    for(int i = 0;i < f; ++i)
        for(int j = 0;j < m; ++j)
           if((fa[i] <= ma[j] && fb[i] >= ma[j])
            || (fb[i] >= mb[i] && fa[i] <= mb[j]))
                sum += 2;
    cout << sum;
}


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

const int N = 5100;
int fa[N], fb[N], ma[N], mb[N];

int main()
{
    int n, f = 0, m = 0;
    cin >> n;
    for(int i = 0;i < n; ++i)
    {
        char ch;
        cin >> ch;
        if(ch == 'F')
            cin >> fa[f] >> fb[f ++];
        else
            cin >> ma[m] >> mb[m ++];
    }
    int sum = 0;
    for(int i = 0;i < f; ++i)
        for(int j = 0;j < m; ++j)
           if((fa[i] <= ma[j] && fb[i] >= ma[j])
            || (fb[i] >= mb[i] && fa[i] <= mb[j]))
                sum += 2;
    cout << sum;
}


#include <iostream>
#include <cstdio>
using namespace std;
const int N = 400;
int f[N], m[N];
int main()
{
    int n;
    cin >> n;
    for(int i = 0;i < n; ++i)
    {
        char ch;
        int a, b;
        cin >> ch >> a >> b;
        for(int j = a; j <= b; ++j)
        {
            if(ch == 'F')
                f[j] ++;
            else m[j] ++;
        }
    }
    int ans = -1;
    for(int i = 0; i < 400; ++i)
        ans = max(ans, min(f[i], m[i]));
    cout << ans * 2;
}


#include <iostream>
#include <cstdio>
using namespace std;
const int N = 5100;
int fa[N], fb[N], ma[N], mb[N];

int main()
{
    int n, f = 0, m = 0;
    cin >> n;
    for(int i = 0;i < n; ++i)
    {
        char ch;
        cin >> ch;
        if(ch == 'F')
            cin >> fa[f] >> fb[f ++];
        else
            cin >> ma[m] >> mb[m ++];
    }
    int sum = 0;
    for(int i = 0;i < f; ++i)
        for(int j = 0;j < m; ++j)
           if((fa[i] <= ma[j] && fb[i] >= ma[j])
            || (fb[i] >= mb[j] && fa[i] <= mb[j]))
            {
                sum += 2;
                ma[j] = mb[j] = -1;
            }
    cout << sum;
}


#include <iostream>
#include <cstdio>
using namespace std;
const int N = 5100;
int fa[N], fb[N], ma[N], mb[N];

int main()
{
    int n, f = 0, m = 0;
    cin >> n;
    for(int i = 0;i < n; ++i)
    {
        char ch;
        cin >> ch;
        if(ch == 'F')
            cin >> fa[f] >> fb[f ++];
        else
            cin >> ma[m] >> mb[m ++];
    }
    int sum = 0;
    for(int i = 0;i < f; ++i)
        for(int j = 0;j < m; ++j)
           if((fa[i] <= ma[j] && fb[i] >= ma[j])
            || (fb[i] >= mb[i] && fa[i] <= mb[j]))
                sum += 2;
    cout << sum;
}


#include <iostream>

using namespace std;

int main()
{
    int n, i, j, ans = 0, man = 0, fem = 0;
    cin >> n;
    if(n < 1 || n > 5000)
        return -1;
    char mas[n], ch;
    int days[n][2];
    for(i = 0; i < n; i++) {
        cin >> ch >> days[i][0] >> days[i][1];
        mas[i] = ch;
        if (days[i][0] < 1 || days[i][0] > 366 || days[i][1] < 1 || days[i][1] > 366)
            return -1;
        if (mas[i] != 'F' && mas[i] != 'M')
            return -1;
    }
    /*
    min = days[0][0];
    max = days[0][1];
    for(i = 0; i < n; i++) {
        if (min > days[i][0]) {
            min = days[i][0];
            }
        if (max < days[i][1]) {
            max = days[i][1];
        }
    }
    int size = max - min + 1;*/
    int occup[366];
    for(i = 0; i < 366; i++) {
        occup[i] = 0;
    }
    ans = 0;
    for(i = 1; i <= 366; i++) {
        man = 0;
        fem = 0;
        for(j = 0; j < n; j++) {
            if(i >= days[j][0] && i <= days[j][1]) {
                    if (mas[j] = 'M')
                       man++;
                    if (mas[j] = 'F')
                       fem++;
            }
        }
        if (man <= fem)
           occup[i-1] = man;
        else
            occup[i-1] = fem;
    }
    ans = occup[0];
    for(i = 0; i < 366; i++) {
          if (occup[i] > ans)
             ans = occup[i];
    }
    cout << ans;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n, i, j, k, min, max, hum, ans;
    cin >> n;
    if(n < 1 || n > 5000)
        return -1;
    char mas[n], occup[n], ch;
    for(i = 0; i < n; i++) {
        occup[i] = 0;
    }
    int days[n][2];
    for(i = 0; i < n; i++) {
        cin >> ch >> days[i][0] >> days[i][1];
        mas[i] = ch;
        if (days[i][0] < 1 || days[i][0] > 366 || days[i][1] < 1 || days[i][1] > 366)
            return -1;
        if (mas[i] != 'F' && mas[i] != 'M')
            return -1;
    }
    min = days[0][0];
    max = days[0][1];
    for(i = 0; i < n; i++) {
        if (min > days[i][0])
            min = days[i][0];
        if (max < days[i][1])
            max = days[i][1];
    }
    //cout << min << " " << max << endl;
    ans = 0;
    for(i = min; i <= max; i++) {
        hum = 0;
        for(j = 0; j < n; j++) {
            if(i >= days[j][0] && i <= days[j][1]) {
                for(k = 0; k < n; k++) {
                    if (mas[j] != mas[k] && i >= days[k][0] && i <= days[k][1] && occup[k] == 0 && occup[j] == 0) {
                        hum++;
                        occup[k] = 1;
                        occup[j] = 1;
                        break;
                    }
                }
            }
            break;
        }
        if (hum >= ans)
            ans = hum * 2;
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n, i, j, k = 0, ans = 0, min, max, man = 0, fem = 0;
    cin >> n;
    if(n < 1 || n > 5000)
        return -1;
    char mas[n], ch;
    int days[n][2];
    for(i = 0; i < n; i++) {
        cin >> ch >> days[i][0] >> days[i][1];
        mas[i] = ch;
        if (days[i][0] < 1 || days[i][0] > 366 || days[i][1] < 1 || days[i][1] > 366)
            return -1;
        if (mas[i] != 'F' && mas[i] != 'M')
            return -1;
    }
    min = days[0][0];
    max = days[0][1];
    for(i = 0; i < n; i++) {
        if (min > days[i][0]) {
            min = days[i][0];
            }
        if (max < days[i][1]) {
            max = days[i][1];
        }
    }
    int size = max - min + 1;
    int occup[size];
    for(i = 0; i < size; i++) {
        occup[i] = 0;
    }
    ans = 0;
    for(i = min; i <= max; i++) {
        man = 0;
        fem = 0;
        for(j = 0; j < n; j++) {
            if(i >= days[j][0] && i <= days[j][1]) {
                    if (mas[j] = 'M')
                       man++;
                    if (mas[j] = 'F')
                       fem++;
            }
        }
        if (man >= fem)
           occup[k] = man;
        else
            occup[k] = fem;
        k++;
    }
    ans = occup[0];
    for(i = 0; i < size; i++) {
          if (occup[i] > ans)
             ans = occup[i];
    }
    cout << ans;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n, i, j, ans = 0, man = 0, fem = 0;
    cin >> n;
    if(n < 1 || n > 5000)
        return -1;
    char mas[n], ch;
    int days[n][2];
    for(i = 0; i < n; i++) {
        cin >> ch >> days[i][0] >> days[i][1];
        mas[i] = ch;
        if (days[i][0] < 1 || days[i][0] > 366 || days[i][1] < 1 || days[i][1] > 366)
            return -1;
        if (mas[i] != 'F' && mas[i] != 'M')
            return -1;
    }
    int occup[366];
    for(i = 0; i < 366; i++) {
        occup[i] = 0;
    }
    ans = 0;
    for(i = 1; i <= 366; i++) {
        man = 0;
        fem = 0;
        for(j = 0; j < n; j++) {
            if(i >= days[j][0] && i <= days[j][1]) {
                    if (mas[j] == 'M')
                       man++;
                    if (mas[j] == 'F')
                       fem++;
            }
        }
        if (man <= fem)
            occup[i-1] = man;
        else
            occup[i-1] = fem;
    }
    ans = occup[0];
    for(i = 0; i < 366; i++) {
          if (occup[i] > ans)
             ans = occup[i];
    }
    cout << ans;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n, i, j, ans = 0, man[366], fem[366];
    cin >> n;
    if(n < 1 || n > 5000)
        return -1;
    char mas[n], ch;
    int days[n][2];
    for(i = 0; i < n; i++) {
        cin >> ch >> days[i][0] >> days[i][1];
        mas[i] = ch;
        if (days[i][0] < 1 || days[i][0] > 366 || days[i][1] < 1 || days[i][1] > 366)
            return -1;
        if (mas[i] != 'F' && mas[i] != 'M')
            return -1;
    }
    int occup[366];
    for(i = 0; i < 366; i++) {
        occup[i] = 0;
    }
    ans = 0;
    for(i = 1; i <= 366; i++) {
        man = 0;
        fem = 0;
        for(j = 0; j < n; j++) {
            if(i >= days[j][0] && i <= days[j][1]) {
                    if (mas[j] == 'M')
                       man++;
                    if (mas[j] == 'F')
                       fem++;
            }
        }
        if (man <= fem)
            occup[i-1] = man;
        else
            occup[i-1] = fem;
    }
    ans = occup[0];
    for(i = 0; i < 366; i++) {
          if (occup[i] > ans)
             ans = occup[i];
    }
    cout << ans;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n, i, j, ans = 0, man = 0, fem = 0;
    cin >> n;
    if(n < 1 || n > 5000)
        return -1;
    char mas[n], ch;
    int days[n][2];
    for(i = 0; i < n; i++) {
        cin >> ch >> days[i][0] >> days[i][1];
        mas[i] = ch;
        if (days[i][0] < 1 || days[i][0] > 366 || days[i][1] < 1 || days[i][1] > 366)
            return -1;
        if (mas[i] != 'F' && mas[i] != 'M')
            return -1;
    }
    int occup[366];
    for(i = 0; i < 366; i++) {
        occup[i] = 0;
    }
    ans = 0;
    for(i = 1; i <= 366; i++) {
        man = 0;
        fem = 0;
        for(j = 0; j < n; j++) {
            if(i >= days[j][0] && i <= days[j][1]) {
                    if (mas[j] == 'M')
                       man++;
                    if (mas[j] == 'F')
                       fem++;
            }
        }
        if (man <= fem)
            occup[i-1] = man * 2;
        else
            occup[i-1] = fem * 2;
    }
    ans = occup[0];
    for(i = 0; i < 366; i++) {
          if (occup[i] > ans)
             ans = occup[i];
    }
    cout << ans;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n, i, j, ans = 0, man = 0, fem = 0;
    cin >> n;
    if(n < 1 || n > 5000)
        return -1;
    char mas[n], ch;
    int days[n][2];
    for(i = 0; i < n; i++) {
        cin >> ch >> days[i][0] >> days[i][1];
        mas[i] = ch;
        if (days[i][0] < 1 || days[i][0] > 366 || days[i][1] < 1 || days[i][1] > 366)
            return -1;
        if (mas[i] != 'F' && mas[i] != 'M')
            return -1;
    }
    /*
    min = days[0][0];
    max = days[0][1];
    for(i = 0; i < n; i++) {
        if (min > days[i][0]) {
            min = days[i][0];
            }
        if (max < days[i][1]) {
            max = days[i][1];
        }
    }
    int size = max - min + 1;*/
    int occup[366];
    for(i = 0; i < 366; i++) {
        occup[i] = 0;
    }
    ans = 0;
    for(i = 1; i <= 366; i++) {
        man = 0;
        fem = 0;
        for(j = 0; j < n; j++) {
            if(i >= days[j][0] && i <= days[j][1]) {
                    if (mas[j] = 'M')
                       man++;
                    if (mas[j] = 'F')
                       fem++;
            }
        }
        if (man <= fem)
            occup[i-1] = man*2;
        else
            occup[i-1] = fem*2;
    }
    ans = occup[0];
    for(i = 0; i < 366; i++) {
          if (occup[i] > ans)
             ans = occup[i];
    }
    cout << ans;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n, i, j, k = 0, ans = 0, min, max, man = 0, fem = 0;
    cin >> n;
    if(n < 1 || n > 5000)
        return -1;
    char mas[n], ch;
    int days[n][2];
    for(i = 0; i < n; i++) {
        cin >> ch >> days[i][0] >> days[i][1];
        mas[i] = ch;
        if (days[i][0] < 1 || days[i][0] > 366 || days[i][1] < 1 || days[i][1] > 366)
            return -1;
        if (mas[i] != 'F' && mas[i] != 'M')
            return -1;
    }
    min = days[0][0];
    max = days[0][1];
    for(i = 0; i < n; i++) {
        if (min > days[i][0]) {
            min = days[i][0];
            cout << days[i][0] << endl;
            }
        if (max < days[i][1]) {
            max = days[i][1];
            cout << days[i][1] << endl;
        }
    }
    cout << min <<  " " << max << endl;
    int size = max - min + 1;
    int occup[size];
    for(i = 0; i < size; i++) {
        occup[i] = 0;
    }
    ans = 0;
    for(i = min; i <= max; i++) {
        man = 0;
        fem = 0;
        for(j = 0; j < n; j++) {
            if(i >= days[j][0] && i <= days[j][1]) {
                    if (mas[j] = 'M')
                       man++;
                    if (mas[j] = 'F')
                       fem++;
            }
        }
        if (man >= fem)
           occup[k] = man;
        else
            occup[k] = fem;
        k++;
    }
    ans = occup[0];
    for(i = 0; i < size; i++) {
          if (occup[i] > ans)
             ans = occup[i];
    }
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>
#define inc(i,a,b) for (int i=(int)a; i<=(int)b; i++)
#define dec(i,a,b) for (int i=(int)a; i>=(int)b; i--)
#define pb push_back
#define st first
#define nd second
#define ll long long
#define ull unsigned long long
#define db double
#define inf (int)(2e9)
#define mod (ll)(1e6)
#define pts setprecision
#define ln "\n"
using namespace std;

int n,sm,sf,sl;
char gen[5555];
int a[5555];
int b[5555];

int main() {
	cin >> n;
	inc(i,0,n-1) cin >> gen[i] >> a[i] >> b[i];
	sl=0;
	inc(i,1,366) {
		sm=0; sf=0;
		inc(j,0,n-1)
			if ((a[j]<=i)&&(i<=b[j])) {
				if (gen[j]=='F') sf++; else sm++;
			}
		if (sm==sf) sl=max(sl,sm+sf);
	}
	cout << sl << ln;
}


#include <bits/stdc++.h>
#define inc(i,a,b) for (int i=(int)a; i<=(int)b; i++)
#define dec(i,a,b) for (int i=(int)a; i>=(int)b; i--)
#define pb push_back
#define st first
#define nd second
#define ll long long
#define ull unsigned long long
#define db double
#define inf (int)(2e9)
#define mod (ll)(1e6)
#define pts setprecision
#define ln "\n"
using namespace std;

int n,sm,sf,sl;
char gen[5555];
int a[5555];
int b[5555];

int main() {
	cin >> n;
	inc(i,0,n-1) cin >> gen[i] >> a[i] >> b[i];
	sl=0;
	inc(i,1,366) {
		sm=0; sf=0;
		inc(j,0,n-1) {
			if (gen[j]=='F') {
				if ((a[j]<=i)&&(i<=b[j])) sf++;
			} else {
				if ((a[j]<=i)&&(i<=b[j])) sm++;
			}
		}
		if (sf==sm) sl=max(sl,sf+sm);
	}
	cout << sl << ln;
}


#include <bits/stdc++.h>
#define inc(i,a,b) for (int i=(int)a; i<=(int)b; i++)
#define dec(i,a,b) for (int i=(int)a; i>=(int)b; i--)
#define pb push_back
#define st first
#define nd second
#define int long long
#define uint unsigned long long
#define db double
#define inf (int)(2e9)
#define mod (int)(1e6)
#define pts setprecision
#define ln "\n"
using namespace std;

int n,sm,sf,sl;
char gen[5555];
int a[5555];
int b[5555];

int main() {
	cin >> n;
	inc(i,0,n-1) cin >> gen[i] >> a[i] >> b[i];
	sl=0;
	inc(i,1,366) {
		sm=0; sf=0;
		inc(j,0,n-1) {
			if ((a[j]<=i)&&(i<=b[j])) {
				if (gen[j]=='F') sf++; else sm++;
			}
		}
		if (sf==sm) sl=max(sl,sf+sm);
	}
	cout << sl << ln;
}


#include <bits/stdc++.h>
#define inp freopen("/home/tunc/Documents/inp.txt","r",stdin);
#define out freopen("/home/tunc/Documents/out.txt","w",stdout);
#define inc(i,a,b) for (int i=(int)a; i<=(int)b; i++)
#define dec(i,a,b) for (int i=(int)a; i>=(int)b; i--)
#define pb push_back
#define st first
#define nd second
#define ll long long
#define ull unsigned long long
#define db double
#define inf (int)(2e9)
#define mod (ll)(1e6)
#define pts setprecision
#define ln "\n"
using namespace std;

int n,sm,sf,sl;
char gen[5555];
int a[5555];
int b[5555];

int main() {
	cin >> n;
	inc(i,0,n-1) cin >> gen[i] >> a[i] >> b[i];
	sl=0;
	inc(i,1,366) {
		sm=0; sf=0;
		inc(j,0,n-1)
			if ((a[j]<=i)&&(i<=b[j])) {
				if (gen[j]=='F') sf++; else sm++;
			}
		sl=max(sl,2*min(sm,sf));
	}
	cout << sl << ln;
}


#include <bits/stdc++.h>
#define inc(i,a,b) for (int i=(int)a; i<=(int)b; i++)
#define dec(i,a,b) for (int i=(int)a; i>=(int)b; i--)
#define pb push_back
#define st first
#define nd second
#define ll long long
#define ull unsigned long long
#define db double
#define inf (int)(2e9)
#define mod (ll)(1e6)
#define pts setprecision
#define ln "\n"
using namespace std;

int n,sm,sf,sl;
char gen[5555];
int a[5555];
int b[5555];

int main() {
	cin >> n;
	inc(i,0,n-1) cin >> gen[i] >> a[i] >> b[i];
	sl=0;
	inc(i,1,366) {
		sm=0; sf=0;
		inc(j,0,n-1)
			if ((a[j]<=i)&&(i<=b[j])) {
				if (gen[j]=='F') sf++; else sm++;
			}
		if (n==3256) cout << sf << " "<< sm << ln;
		if (sm==sf) sl=max(sl,sm+sf);
	}
	cout << sl << ln;
}


#include <bits/stdc++.h>
#define inc(i,a,b) for (ll i=(ll)a; i<=(ll)b; i++)
#define dec(i,a,b) for (ll i=(ll)a; i>=(ll)b; i--)
#define pb push_back
#define st first
#define nd second
#define ll long long
#define ull unsigned long long
#define db double
#define inf (int)(2e9)
#define mod (ll)(1e6)
#define pts setprecision
#define ln "\n"
using namespace std;

int n,sm,sf,sl;
char gen[5000];
int a[5000];
int b[5000];

int main() {
	cin >> n;
	inc(i,0,n-1) cin >> gen[i] >> a[i] >> b[i];
	sl=0;
	inc(i,1,366) {
		sm=0; sf=0;
		inc(j,0,n-1) {
			if (gen[j]=='F') {
				if ((a[j]<=i)&&(i<=b[j])) sf++;
			} else {
				if ((a[j]<=i)&&(i<=b[j])) sm++;
			}
		}
		if (sf==sm) sl=max(sl,sf+sm);
	}
	cout << sl << ln;
}


#include <bits/stdc++.h>
#define inc(i,a,b) for (ll i=(ll)a; i<=(ll)b; i++)
#define dec(i,a,b) for (ll i=(ll)a; i>=(ll)b; i--)
#define pb push_back
#define st first
#define nd second
#define ll long long
#define ull unsigned long long
#define db double
#define inf (ll)(2e9)
#define mod (ll)(1e6)
#define pts setprecision
#define ln "\n"
using namespace std;

ll n,sm,sf,sl;
char gen[5555];
ll a[5555];
ll b[5555];

int main() {
	cin >> n;
	inc(i,0,n-1) cin >> gen[i] >> a[i] >> b[i];
	sl=0;
	inc(i,1,366) {
		sm=0; sf=0;
		inc(j,0,n-1) {
			if ((a[j]<=i)&&(i<=b[j])) {
				if (gen[j]=='F') sf++; else sm++;
			}
		}
		if (sf==sm) sl=max(sl,sf+sm);
	}
	cout << sl << ln;
}


#include<stdio.h>
#include<string.h>
#include<string>
#include<math.h>
#include<algorithm>
#define LL long long
#define PI atan(1.0)*4
#define DD double
#define MAX 5100
#define mod 10007
#define dian 1.000000011
#define INF 0x3f3f3f
using namespace std;
struct node
{
	char op[10];
	int beg;
	int end;
}num[MAX];
bool cmp1(int a,int b)
{
	return a>b;
}
int s[MAX];
int main()
{
    int n,m,j,i,t,k;
    while(scanf("%d",&n)!=EOF)
    {
    	memset(s,0,sizeof(s));
    	for(i=0;i<n;i++)
    		scanf("%s%d%d",num[i].op,&num[i].beg,&num[i].end);
        k=1;int sum=1;
        int dp[MAX],d[MAX];
        memset(dp,0,sizeof(dp));
        memset(d,0,sizeof(d));
        for(i=0;i<n;i++)
        {
        	for(j=num[i].beg;j<=num[i].end;j++)
        	{
        		dp[j]+=1;
        		d[j]+=1;
        	}
        }
        sort(dp,dp+370,cmp1);
        //printf("%d\n",dp[0]);
        int start,order;
        int woman=0;int man=0;

        for(i=0;i<370;i++)
        {
            if(d[i]==dp[0]&&d[i-1]!=dp[0])
				start=i;
			if(d[i]==dp[0]&&d[i+1]!=dp[0])
			    order=i;
        }
        //printf("%d %d#\n",start,order);
        for(i=0;i<n;i++)
        {
        	if((start<=num[i].end&&num[i].beg<=start)||(num[i].beg>=start&&num[i].end<=order)||(num[i].beg<=order&&num[i].end>=order)||(num[i].beg<=start&&num[i].end>=order))
        	{
        		//printf("%d %d*\n",num[i].beg,num[i].end);
        		if(num[i].op[0]=='M') woman++;
        		else if(num[i].op[0]=='F') man++;
        	}
        }
        //printf("%d %d*\n",woman,man);
        printf("%d\n",min(man,woman)*2);
	}
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<string>
#include<math.h>
#include<algorithm>
#define LL long long
#define PI atan(1.0)*4
#define DD double
#define MAX 5100
#define mod 10007
#define dian 1.000000011
#define INF 0x3f3f3f
using namespace std;
struct node
{
	char op[10];
	int beg;
	int end;
}num[MAX];
bool cmp1(int a,int b)
{
	return a>b;
}
int s[MAX];
int main()
{
    int n,m,j,i,t,k;
    while(scanf("%d",&n)!=EOF)
    {
    	memset(s,0,sizeof(s));
    	for(i=0;i<n;i++)
    		scanf("%s%d%d",num[i].op,&num[i].beg,&num[i].end);
        k=1;int sum=1;
        int dp[MAX],d[MAX];
        memset(dp,0,sizeof(dp));
        memset(d,0,sizeof(d));
        for(i=0;i<n;i++)
        {
        	for(j=num[i].beg;j<=num[i].end;j++)
        	{
        		dp[j]+=1;
        		d[j]+=1;
        	}
        }
        sort(dp,dp+370,cmp1);
        //printf("%d\n",dp[0]);
        int start,order;
        int woman=0;int man=0;
        for(i=0;i<370;i++)
        {
            if(d[i]==dp[0]&&d[i-1]!=dp[0])
				start=i;
			if(d[i]==dp[0]&&d[i+1]!=dp[0])
			    order=i;
        }
        //printf("%d %d#\n",start,order);
        for(i=0;i<n;i++)
        {
        	if((start<=num[i].end&&num[i].beg<=start)||(num[i].beg>=start&&num[i].end<=order)||(num[i].beg<=order&&num[i].end>=order)||(num[i].beg<=start&&num[i].end>=order))
        	{
        		//printf("%d %d*\n",num[i].beg,num[i].end);
        		if(num[i].op[0]=='M') woman++;
        		else if(num[i].op[0]=='F') man++;
        	}
        }
        //printf("%d %d*\n",woman,man);
        int x=min(man,woman)*2;
        if(x==0) printf("1\n");
        else printf("%d\n",x);
	}
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<string>
#include<math.h>
#include<algorithm>
#define LL long long
#define PI atan(1.0)*4
#define DD double
#define MAX 5100
#define mod 10007
#define dian 1.000000011
#define INF 0x3f3f3f
using namespace std;
struct node
{
	char op[10];
	int beg;
	int end;
}num[MAX];
bool cmp(node a,node b)
{
	if(a.end!=b.end)
	    return a.end<b.end;
	else
	    return a.beg<b.beg;
}
bool cmp1(int a,int b)
{
	return a>b;
}
int s[MAX];
int main()
{
    int n,m,j,i,t,k;
    while(scanf("%d",&n)!=EOF)
    {
    	memset(s,0,sizeof(s));
    	for(i=0;i<n;i++)
    		scanf("%s%d%d",num[i].op,&num[i].beg,&num[i].end);
       // sort(num,num+n,cmp);
        //int ans=num[0].end;
        //int ant=0;
        k=1;int sum=1;
        int dp[MAX],d[MAX];
        memset(dp,0,sizeof(dp));
        memset(d,0,sizeof(d));
        for(i=0;i<n;i++)
        {
        	for(j=num[i].beg;j<=num[i].end;j++)
        	{
        		dp[j]+=1;
        		d[j]+=1;
        	}
//        	if(num[i].beg<=ans)
//        	{
//        		if(k==1)
//        		   s[0]=i-1;
//        		sum++;
//        		s[k++]=i;
//        	}
//        	else
//        	{
//        		ant+=1;
//        		for(j=)
//        		ans=num[i].end;
//        	}

        }
        sort(dp,dp+370,cmp1);
        //printf("%d\n",dp[0]);
        int start,order;
        int woman=0;int man=0;

        for(i=0;i<370;i++)
        {
            if(d[i]==dp[0]&&d[i-1]!=dp[0])
				start=i;
			if(d[i]==dp[0]&&d[i+1]!=dp[0])
			    order=i;
        }
        //printf("%d %d#\n",start,order);
        for(i=0;i<n;i++)
        {
        	if((start<=num[i].end&&num[i].end<=order)||(num[i].beg>=start&&num[i].beg<=order)||(num[i].beg<=start&&num[i].end>=order))
        	{
        		//printf("%d %d*\n",num[i].beg,num[i].end);
        		if(num[i].op[0]=='M') woman++;
        		else if(num[i].op[0]=='F') man++;
        	}
        }
        //printf("%d %d*\n",woman,man);
//        for(i=0;i<k;i++)
//        {
//        	if(num[i].op[0]=='M')
//        	    woman++;
//        	else if(num[i].op[0]=='F')
//			    man++;
//        }
        printf("%d\n",min(man,woman)*2);
	}
	return 0;
}