/*
* Author:Jai
* Created:Sunday, 07.12.2025 04:08 PM (GMT+5:30)
*/
#include<bits/stdc++.h>
#ifdef JAI
#include "algo/debug.cpp"
#else
#define debug(...)
#endif
using namespace std;
#define help ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define all(v) v.begin(), v.end()
// #define peace
const int tt=0;
int MOD=1e9+7;
// i have to code a fucking trie
//how can i do that??
int trie[2][2000000][26];
int node_count=0;
bool stop[2000000];
void insert(int type,string str){
//i have to insert a string into my trie
int node=0;
for(int i=0;i<str.length();i++){
if(trie[type][node][str[i]-'a']==0){
trie[type][node][str[i]-'a']=++node_count;
}
node=trie[type][node][str[i]-'a'];
}
}
int check(int u,int v,int turn){
if(turn==0){
for(int i=0;i<26;i++){
if(trie[0][u][i]!=0&&trie[1][v][i]==0){
return 0;
}
}
for(int i=0;i<26;i++){
if(trie[0][u][i]!=0){
if(check(trie[0][u][i],trie[1][v][i],1)==0){
return 0;
}
}
}
return 1;
}else{
for(int i=0;i<26;i++){
if(trie[0][u][i]==0&&trie[1][v][i]!=0){
return 1;
}
}
for(int i=0;i<26;i++){
if(trie[1][v][i]!=0){
if(check(trie[0][u][i],trie[1][v][i],0)==1){
return 1;
}
}
}
return 0;
}
}
void solve(int tc){
int n;cin>>n;
vector<string> arr(n);
for(int i=0;i<n;i++){
cin>>arr[i];
insert(0,arr[i]);
}
int m;cin>>m;
for(int i=0;i<m;i++){
string str;cin>>str;
insert(1,str);
}
if(check(0,0,0)==0){
cout<<"Nina"<<endl;
}else{
cout<<"Emilija"<<endl;
}
}
signed main() {
#if defined(JAI) && defined(peace)
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
clock_t T = clock();
#endif
help;
int t=1;
if(tt){
cin>>t;
}
for(int i=1;i<=t;i++){
solve(i);
}
#if defined(JAI) && defined(peace)
cout << "\nTime : " << ((float)(clock() - T)*1000) / CLOCKS_PER_SEC << " ms";
#endif
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |