#include using namespace std; int main(){ int n; cin>>n; // number of items total int k; cin>>k; // number of colours total int p; cin>>p; // period of non-repetition int m; cin>>m; // number of items given vector prev(k,-p); // last occurrence of each colour vector freq(k,0); // total occurrences of each colour vector v(n); // assignments of colours to knitting // validate the initial colours from the input saving the last // time each one occurred for (int i=0; i>v[i]; --v[i]; if (prev[v[i]]+p>i){ cout<<"impossible"<> todo; for (int i=0; i=m and prev[v[i-p]]==i-p){ todo.emplace_back(freq[v[i-p]],v[i-p]); } if (todo.empty()){ cout<<"impossible"<