#include <bits/stdc++.h>   using namespace std;   const int N = 2e4;   const int T = 24 * 60 * 60;   int was, n, M, add, cnt, ans[N];   vector<int> ind[T];   int main() {     scanf( %d%d%d , &n, &M, &add);     for (int i = 0; i < (int)(n); i++) {       int h, m, s;       scanf( %d:%d:%d , &h, &m, &s);       ind[s + 60 * (m + 60 * h)].push_back(i);     }     set<pair<int, int> > s;     for (int i = 0; i < (int)(T); i++) {       while ((int)(s).size() && s.begin()->first <= i) s.erase(s.begin());       for (int j : ind[i]) {         if ((int)(s).size() < M)           ans[j] = ++cnt;         else {           ans[j] = s.rbegin()->second;           s.erase(*s.rbegin());         }         s.insert(pair<int, int>(i + add, ans[j]));       }       was |= (int)(s).size() == M;     }     if (!was)       puts( No solution );     else {       printf( %d n , cnt);       for (int i = 0; i < (int)(n); i++) printf( %d n , ans[i]);     }     return 0;   }   