#include <bits/stdc++.h>
using namespace std;
#define LOCAL
#define L(i, j, n) for (int i = (j); i < (int)n; i ++)
#define LI(i, j, n) for (int i = (j); i <= (int)n; i ++)
#define R(i, j, n) for (int i = (j); i > (int)n; i --)
#define RI(i, j, n) for (int i = (j); i >= (int)n; i --)
#define SZ(x) int((x).size())
#define ALL(x) begin(x),end(x)
#define IS_IN(x, v) ((x).find(v) != (x).end())
#define vec vector
#define pb push_back
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int N = (int)2e5+5;
const int MOD = (int)1e9 + 7;
const int oo = (int)1e9;
struct trie {
    trie * ch[26];
    bool eee;
    bool hc;
    trie(){
        eee=0;
        hc=0;
        L(i,0,26){
            ch[i]=0;
        }
    }
    void insert(string &s, int i){
        if (i == SZ(s)){
            eee=1;
            return;
        }
        int id=s[i]-'a';
        if(ch[id]==0)ch[id]=new trie;
        hc = hc || ((SZ(s) - 1) > i);
        // cout << s[i] << " " << hc << "\n";
        ch[id]->insert(s, i + 1);
    }
} *nina, *emi;
bool go(trie * n, trie * e, bool t = 0){
    if (t == 0){
        if (n == 0) return false;
        // if (!n->hc) return false;
        L(id,0,26) if (n->ch[id] != 0){
            // cout << "NT: " << char('a'+id) << "\n"; 
            if (!go(n->ch[id], e->ch[id], !t)){
                // cout <<"N: " << char('a'+id) << "\n";
                return true;
            };
        }
        return false;
    } else {
        if (e == 0) return false;
        // if (!e->hc) return false;
        L(id,0,26) if (e->ch[id] != 0){
            // cout <<"ET: " << char('a'+id) << "\n";
            if (!go(n->ch[id], e->ch[id], !t)){
                return true;
            };
        }
        return false;
    }
}
void solve()
{
    int n; cin >> n;
    int m;
    nina = new trie;
    L(i,0,n) {
        string s; cin >> s;
        nina->insert(s, 0);
    }
    cin >> m;
    emi = new trie;
    L(i,0,m){
        string s; cin >> s;
        emi->insert(s, 0);
    }
    bool r = go(nina, emi, 0);
    cout << (r ? "Nina":"Emilija") << "\n";
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int TT = 1;
    //cin >> TT;
    while (TT--)
    {
        solve();
    }
}
| # | 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... |