#include <bits/stdc++.h>   using namespace std;   const int maxn = 100 + 10;   int n, m, k;   string l[maxn];   int t[maxn], T;   int w[5][3];   vector<pair<int, int> > v;   pair<pair<int, int>, pair<int, int> > a[maxn];   int vis[24 * 30 * 60 + 10];   int cor[24 * 30 * 60 + 10];   int dp[maxn][24 * 30 * 60 + 10];   int par[maxn][24 * 30 * 60 + 10];   inline bool cmp(pair<pair<int, int>, pair<int, int> > fi,                   pair<pair<int, int>, pair<int, int> > se) {     return fi.first.second < se.first.second;   }   inline int solve(int work, int time) {     time++;     int &ret = dp[work][time];     if (ret > -1) return ret;     if (work == 0) return ret = 0;     int need = t[a[work].first.first];     if (need <= time) {       int Max = solve(work - 1, min(time - 1 - need, a[work - 1].first.second)) +                 a[work].second.first;       int Max_ = solve(work - 1, min(time - 1, a[work - 1].first.second));       if (Max > Max_) par[work][time] = 1;       return ret = max(Max, Max_);     } else       return ret = solve(work - 1, min(time - 1, a[work - 1].first.second));   }   inline void Out_(int Time) {     int t = cor[Time];     cout << t / 1440 + 1 <<    ;     int p, q;     t %= 1440;     p = t / 60;     q = t % 60;     if (p < 10)       cout <<  0  << p <<  : ;     else       cout << p <<  : ;     if (q < 10)       cout <<  0  << q;     else       cout << q;   }   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> m >> k;     for (int i = 1; i <= n; ++i) cin >> l[i];     for (int i = 1; i <= n; ++i) cin >> t[i];     for (int i = 1; i <= 4; ++i) {       int p, q;       int p_, q_;       char g, g_;       cin >> p >> g >> q >> g_ >> p_ >> g >> q_;       w[i][1] = p * 60 + q;       w[i][2] = p_ * 60 + q_;     }     for (int i = 1; i <= k; ++i)       for (int j = 1; j <= 4; ++j)         v.push_back(pair<int, int>(24 * 60 * (i - 1) + w[j][1],                                    24 * 60 * (i - 1) + w[j][2]));     for (int i = 0; i < v.size(); ++i)       for (int j = v[i].first; j <= v[i].second; ++j) vis[j] = 1;     int cp = m;     for (int i = 1, cur = 1; i <= m; ++i, cur++) {       string hlp;       cin >> hlp;       for (int j = 1; j <= n; ++j)         if (hlp == l[j]) a[i].first.first = j;       int day;       cin >> day;       int p, q;       char g;       cin >> p >> g >> q;       a[i].first.second = (day - 1) * 24 * 60 + p * 60 + q;       cin >> a[i].second.first;       a[i].second.second = cur;       if (a[i].first.first == 0) {         a[m] = a[i];         i--;         m--;       }     }     for (int i = 1; i <= m; ++i) {       int q = 0;       bool flag = false;       for (int j = 0; j < v.size(); ++j)         if (a[i].first.second >= v[j].first)           if (a[i].first.second > v[j].second)             q += v[j].second - v[j].first + 1;           else {             q += a[i].first.second - v[j].first + 1;             flag = true;           }       a[i].first.second -= q;       if (flag == false) a[i].first.second--;     }     sort(a + 1, a + 1 + m, cmp);     int cur = 0;     for (int i = 0; i < k * 24 * 60; ++i)       if (vis[i] == 0) {         cor[cur++] = i;         T++;       }     T--;     memset(dp, -1, sizeof dp);     cout << solve(m, min(a[m].first.second, T)) << endl;     vector<int> ans;     int ind, time;     time = min(a[m].first.second, T);     ind = m;     for (; ind > 0;) {       time++;       int need = t[a[ind].first.first];       int nex = par[ind][time];       if (nex == 1) {         ans.push_back(ind);         time = min(time - 1 - need, a[ind - 1].first.second);         ind--;       } else {         time = min(time - 1, a[ind - 1].first.second);         ind--;       }     }     cout << ans.size() << endl;     int Min = 0;     for (int i = ans.size() - 1; i >= 0; --i) {       cout << a[ans[i]].second.second <<    ;       Out_(Min);       cout <<    ;       Out_(Min + t[a[ans[i]].first.first] - 1);       cout << endl;       Min += t[a[ans[i]].first.first];     }     return 0;   }   