#include <iostream>
#include <cstdio>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()
typedef complex<double> P;
typedef vector<P> VP;

//ループにおいてcが区間[a,b]に入るか
bool in_range(double a, double b, double c){
    if(a < b) return a<=c && c<=b;
    return c<b || a<c;
}

const double vn = 80.0/60.0; //velocity of natsume (m/s)
const double vc = 50.0/60.0; //velocity of cat (m/s)

//出発座標と現在時刻、巡回ルートと累積和を与え、
//捕まえる座標と時刻を返す
pair<P, double> fastest_catch(P s, double time, VP &route, vector<double> &sumtime){
    int n = route.size();
    //前・後の切れ目になる時刻
    double divtime = time +abs(s -route[0])/vn +sumtime.back()/2;
    divtime = fmod(divtime, sumtime.back());
    
    //二分探索でどの頂点間かを求める
    int sidx, lb=0, ub;
    auto itr = lower_bound(sumtime.begin(), sumtime.end(), divtime);
    if(EQ(*itr, divtime)){
        sidx = itr -sumtime.begin();
        ub = n;
    }else{
        sidx = (itr -sumtime.begin() +n-1) %n;
        ub = n+1;
    }
    int count = 0;
    while(ub -lb > 1){
        if(count++ >10) break;
        int mid = (ub +lb)/2;
        int mididx = (sidx +mid) %n;
        double t = time +abs(s -route[mididx])/vn;
        t = fmod(t, sumtime.back());
        if(in_range(divtime, sumtime[mididx], t)){
            ub = mid;
        }else{
            lb = mid;
        }
    }

    P a=route[(sidx+lb)%n], b=route[(sidx+ub)%n];
    P ab = (b-a)/abs(b-a);
    double dlb=0, dub=abs(a-b);
    for(int rep=0; rep<40; rep++){
        double mid = (dlb +dub) /2.0;
        P midP = a +mid*ab;
        double t = time +abs(s -midP)/vn;
        t = fmod(t, sumtime.back());
        if(in_range(divtime, fmod(sumtime[(sidx+lb)%n] +mid/vc, sumtime.back()), t)){
            dub = mid;
        }else{
            dlb = mid;
        }
    }
    P midP = a +dlb*ab;
    return make_pair(midP, time +abs(s -midP)/vn);
}

int bitcount(int n){
    n = (n & 0x55555555) + (n >> 1 & 0x55555555);
    n = (n & 0x33333333) + (n >> 2 & 0x33333333);
    n = (n & 0x0f0f0f0f) + (n >> 4 & 0x0f0f0f0f);
    n = (n & 0x00ff00ff) + (n >> 8 & 0x00ff00ff);
    return (n & 0x0000ffff) + (n >>16 & 0x0000ffff);
}

int main(){
    int dataset;
    cin >> dataset;
    for(int rep=0; rep<dataset; rep++){
        P s,g;
        {
            int sx,sy,gx,gy;
            cin >> sx >> sy >> gx >> gy;
            s = P(sx, sy);
            g = P(gx, gy);
        }
        int begintime,endtime;
        {
            int hh,mm,ss;
            scanf("%d:%d:%d", &hh, &mm, &ss);
            begintime = hh*3600 +mm*60 +ss;
            scanf("%d:%d:%d", &hh, &mm, &ss);
            endtime = hh*3600 +mm*60 +ss;
        }
        double tlimit = endtime -begintime;

        int n;
        cin >> n;
        //巡回ルート
        vector<VP> route(n);
        for(int i=0; i<n; i++){
            int size;
            cin >> size;
            route[i].resize(size);
            for(int j=0; j<size; j++){
                int x,y;
                cin >> x >> y;
                route[i][j] = P(x, y);
            }
        }
        //各頂点までにかかる時間の累積和
        vector<vector<double> > sumtime(n);
        for(int i=0; i<n; i++){
            int size = route[i].size();
            sumtime[i].resize(size +1);
            sumtime[i][0] = 0;
            for(int j=0; j<size; j++){
                sumtime[i][j+1] = sumtime[i][j] + abs(route[i][j] -route[i][(j+1)%size]) /vc;
            }
        }

        //dp[i][j] = (集合iを確保,最後にjをとったときの最短時刻)
        vector<vector<double> > dp(1<<n, vector<double>(n, INF));
        vector<vector<P> > pos(1<<n, vector<P>(n));
        for(int i=0; i<n; i++){
            auto ret = fastest_catch(s, 0, route[i], sumtime[i]);
            pos[1<<i][i] = ret.first;
            dp[1<<i][i] = ret.second;
        }

        int maxnum = 0;
        double mintime = abs(s -g) /vn;
        for(int i=1; i<(1<<n); i++){
            for(int j=0; j<n; j++){
                if(dp[i][j] == INF) continue;
                //ここから出口に直行しても間に合わないなら打ち切り
                double time = dp[i][j] +abs(pos[i][j] -g)/vn;
                if(time > tlimit) continue;
                //スコア更新(なるべく多く、なるべく早く)
                if(bitcount(i) == maxnum && time < mintime){
                    mintime = time;
                }else if(bitcount(i) > maxnum){
                    maxnum = bitcount(i);
                    mintime = time;
                }
                
                for(int k=0; k<n; k++){
                    if(i>>k & 1) continue;
                    auto ret = fastest_catch(pos[i][j], dp[i][j], route[k], sumtime[k]);
                    if(ret.second < dp[i|(1<<k)][k]){
                        pos[i|(1<<k)][k] = ret.first;
                        dp[i|(1<<k)][k] = ret.second;
                    }
                }
            }
        }

        int integer_part = begintime +mintime +EPS;
        double fractional_part = begintime +mintime -integer_part;
        int hh = integer_part /3600;
        integer_part %= 3600;
        int mm = integer_part /60;
        double ss = integer_part %60 +fractional_part;
        printf("%d\n", maxnum);
        printf("%02d %02d %09.6f\n", hh, mm, ss);
    }
    return 0;
}



Measured memory_bytes: 10132