#include <bits/stdc++.h>   using namespace std;   int n, m, t;   set<pair<int, int> > s;   string s1;   vector<int> v, v1;   int kek[100000];   int main() {     cin >> n >> m >> t;     for (int i = 1; i <= n; i++) {       cin >> s1;       int cur = 0;       cur += 60 * 60 * 10 * (s1[0] -  0 );       cur += 60 * 60 * (s1[1] -  0 );       cur += 60 * 10 * (s1[3] -  0 );       cur += 60 * (s1[4] -  0 );       cur += 10 * (s1[6] -  0 );       cur += (s1[7] -  0 );       v.push_back(cur);     }     s.clear();     int cur = 0;     int ans = 0;     int mx = 0;     for (int i = 0; i < v.size(); i++) {       while (!s.empty()) {         set<pair<int, int> >::iterator it = (--s.end());         if (-(*it).first < v[i])           s.erase(it);         else           break;         cur--;       }       if (cur < m) {         ans++;         kek[i] = ans;         cur++;         s.insert(make_pair(-(v[i] + t - 1), ans));       } else {         kek[i] = (*s.begin()).second;         s.erase(s.begin());         s.insert(make_pair(-(v[i] + t - 1), kek[i]));       }       mx = max(mx, cur);     }     if (mx != m) {       cout <<  No solution ;       return 0;     }     cout << ans <<   n ;     for (int i = 0; i < v.size(); i++) cout << kek[i] <<   n ;   }   