#include using namespace std; int main() { int n, k, p, m; scanf("%d%d%d%d", &n, &k, &p, &m); vector a(m); for (int &x : a) scanf("%d", &x); bool ok = 1; vector cnt(k + 1); vector last(k + 1, -1e9); set> st; for (int i = 1; i <= k; i++) { st.insert({cnt[i], i}); } for (int i = 0; i < n; i++) { if (i >= p) { int x = a[i - p]; st.insert({cnt[x], x}); } if (i >= m) { if (st.empty()) { ok = 0; break; } a.push_back(st.begin()->second); } int x = a[i]; if (i - last[x] < p) { ok = 0; break; } last[x] = i; st.erase({cnt[x], x}); cnt[x]++; } if (!ok) { printf("impossible\n"); } else { for (int i = 0; i < n; i++) printf("%d%c", a[i], " \n"[i + 1 == n]); } }