#include #include #include #include using namespace std; long long ten[] = {1, 10, 100, 1000, 10000, 100000, 1000000}; long long TEN(int n) { return ten[n]; } int main() { long long n, k, m, t; cin >> n >> k >> m >> t; // assert(10 <= m and m <= 15); vector a(n); for (auto& x : a) { cin >> x; // assert(0 <= x and x < TEN(k)); } if(log(n) * m > 8) exit(1); auto sm = [&](int i, int j) { int res = 0; for (int d = 0; d < k; d++) { if (d < t) { if (i % 10 + j % 10 >= 10) return -1; res += (i + j) % 10 * TEN(d); } else { res += (i + j) % 10 * TEN(d); } i /= 10, j /= 10; } return res; }; vector ans(TEN(k)); auto dfs = [&](auto rc, int depth, int s) -> void { // cerr<