#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define endl "\n"
bool local(const string&s)
{
    if(s.empty()||s.size()>64||s.front()=='.'||s.back()=='.')return false;
    for(char c:s)
    {
        if(!isalnum(c)&&c!='.')return false;
    }
    return true;
}
bool domain(const string &s)
{
    if(s.empty()||s.size()>255||s.front()=='.'||s.back()=='.'||s.front()=='-'||s.back()=='-')return false;
    for(char c:s)
    {
        if(!isalnum(c)&&c!='.'&&c!='-')return false;
    }
    return true;
}
signed main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int t;
    cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        stringstream ss(s);
        string l,d;
        getline(ss,l,'@');
        getline(ss,d);
        if(local(l)&&domain(d))
        {
            cout<<"Yes"<<endl;
        }
        else cout<<"No"<<endl;
    }
    return 0;
}