#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
using namespace std;


string oppo(string s) {
    string res = s;
    for (char &c : res) {
        if (c == 'N') 
            c = 'Y';
        else 
            c = 'N';
    }
    return res;
}


string next_string(string s, int m) {
    string res = s;
    int i = m - 1;
    while (i >= 0 && res[i] == 'Y') {
        res[i] = 'N';
        i--;
    }
    if (i >= 0) {
        res[i] = 'Y';
        return res;
    } else {
        return ""; 
    }
}

int main() {
    std::iostream::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    int n, m, a, b;
    cin >> n >> m >> a >> b;
    vector<string> inputs(n);
    for (int i = 0; i < n; i++) {
        cin >> inputs[i];
    }

    
    map<string, int> freq;
    for (string s : inputs) {
        freq[s]++;
    }

    if (a > 0 || b > 0) {
        set<string> candidates;

        
        if (a > 0) {
            for (auto &p : freq) {
                string s = p.first;
                int cnt = p.second;
                if (cnt == a) {
                    string opp = oppo(s);
                    if (b > 0) {
                        
                        if (freq.count(opp) && freq[opp] == b) {
                            candidates.insert(s);
                        }
                    } else {
                        
                        if (!freq.count(opp)) {
                            candidates.insert(s);
                        }
                    }
                }
            }
        }

        
        if (b > 0 && a == 0) {
            for (auto &p : freq) {
                string t = p.first;
                int cnt = p.second;
                if (cnt == b) {
                    string s_candidate = oppo(t);
                    
                    if (!freq.count(s_candidate)) {
                        candidates.insert(s_candidate);
                    }
                }
            }
        }

        
        if (candidates.empty()) {
            cout << "-1" << endl;
        } else {
            cout << *candidates.begin() << endl;
        }
    } else {
        
        set<string> forbidden_set;
        for (auto &p : freq) {
            string s = p.first;
            forbidden_set.insert(s);
            string opp = oppo(s);
            forbidden_set.insert(opp);
        }

        
        vector<string> forbidden_vec(forbidden_set.begin(), forbidden_set.end());
        sort(forbidden_vec.begin(), forbidden_vec.end());

        string candidate = string(m, 'N'); 
        bool valid = true;
        int i = 0;
        while (i < forbidden_vec.size()) {
            if (candidate < forbidden_vec[i]) {
                break; 
            } else if (candidate > forbidden_vec[i]) {
                i++; 
            } else {
                candidate = next_string(candidate, m); 
                if (candidate == "") {
                    valid = false; 
                    break;
                }
                i++;
            }
        }

        if (!valid) {
            cout << "-1" << endl;
        } else {
            cout << candidate << endl;
        }
    }

    return 0;
}