#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
using P = pair<int, int>;
#define all(x) x.begin(), x.end()
#define rep(x,s,e) for (auto x=(s)-((s)>(e));x!=(e)-((s)>(e));((s)<(e)?x++:x--))
#define sz(x) (int)x.size()
const char nl = '\n';
int n, d, m;
vector<P> a;
bool ok = false;
bool check(int x) {
int l = 0, r = 1, i = 1;
while (l < m) {
while (r < sz(a)&& r-l+1 <= x && a[r].first <= i) {
if (a[r].first+d < i)return false;
r += 1;
}
if (ok) {
rep(j, l, r)cout << a[j].second << " ";
cout << 0 << nl;
}
//if (x == 3) {
//cout << i << ":";
//rep(j, l, r)cout << a[j].first << " ";
//cout << nl;
//}
l = r, r = l+1, i += 1;
}
i -= 1;
//if (x == 3)cout << i<< nl;
if(ok && i <= n)rep(j, i+1, n+1)cout << 0 << nl;
return (i<=n);
}
void solve() {
cin >> n >> d >> m;
a.resize(m);
rep(i, 0, m) {
cin >> a[i].first;
a[i].second = i+1;
}
sort(all(a));
int l = 0, r = max(m, n)+10;
while (r-l>1) {
int mid = l+r>>1;
//cout << mid << nl;
if (check(mid))r = mid;
else l = mid;
}
cout << r << endl;
ok = true;
check(r);
//rep(i, 0, n)cout << 0 << nl;
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
solve();
return 0;
}