//* Problem  : 1220 - From Dusk till Dawn
//* Contest  : acm.tju.edu.cn
//* Origin   : University of Ulm Local Contest 1999
//* Type     : Solution
//* Date     : 2008.06.06
//* Author   : alt
//* Language : C++
//* Compiler : Microsoft Visual C++ 8.0

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <iostream>
using namespace std;
#define int64 long long
#define INF 1000000000
#define EPS 1E-8

#define ALL(a) a.begin(), a.end()
#define PB(a, v) a.push_back(v)
#define MP(a,b) make_pair(a, b)
#define FOR(i, n) for (int i = 0; i < (int)(n); i++)
#define FORO(i, obj) for (int i = 0; i < (int)(obj.size); i++)

int d[128][32];

int main()
{
#ifdef _DEBUG
	freopen("1166.in", "r", stdin);
#endif
	int nt; scanf("%d", &nt);
	for (int it = 1; it <= nt; it++)
	{
		printf("Test Case %d.\n", it);
		int m, n = 0, a[1024][4]; string s1, s2; int t1, t2, k1, k2, res = INF;
		map <string, int> mp;
		scanf("%d", &m);
		for (int i = 0; i < m; i++)
		{
			cin >> s1; cin >> s2; cin >> t1; cin >> t2;
			t1 = (t1 + 6) % 24;
			t2 += t1;
			k1 = mp[s1] ? mp[s1] : mp[s1] = ++n;
			k2 = mp[s2] ? mp[s2] : mp[s2] = ++n;
			a[i][0] = k1; a[i][1] = k2;
			a[i][2] = t1; a[i][3] = t2;
		}
		cin >> s1 >> s2; k1 = mp[s1]; k2 = mp[s2];
		
		memset(d, 0, sizeof(d));
		queue <pair<int, int> > q;
		vector <vector <pair<int, pair<int, int> > > > aa(n + 1);
		for (int i = 0; i < m; i++)
		{
			pair <int, pair<int, int> > p;
			p.first = a[i][1];
			p.second.first = a[i][2];
			p.second.second = a[i][3];
			//if (a[i][2] >= a[i][3]) continue;
			if (a[i][2] > 12) continue;
			if (a[i][3] > 12) continue;
			aa[a[i][0]].push_back(p);
		}
		for (int i = 0; i <= 12; i++)
			{
				d[k1][i] = 1; q.push(MP(k1, i));
			}
		res = 0;
		while (!q.empty())
		{
			pair <int, int> p = q.front(); q.pop();
			int v = p.first, t = p.second, dd = d[v][t];
			for (int i = 0; i < aa[v].size(); i++)
			{
				pair <int, pair<int, int> > p = aa[v][i];
				int vt = p.first, t0 = p.second.first, t1 = p.second.second;
				if (t0 >= t)
				{
					if (!d[vt][t1] || d[vt][t1] > dd)
					{
						//printf("From %d To %d By %d-%d\n", v, vt, t0, t1);
						d[vt][t1] = dd;
						q.push(MP(vt, t1));
					}
				}
				else
				{
					if (!d[vt][t1] || d[vt][t1] > dd + 1)
					{
						//printf("From %d To %d By %d-%d\n", v, vt, t0, t1);
						d[vt][t1] = dd + 1;
						q.push(MP(vt, t1));
					}
				}
			}
		}
		res = INF;
		for (int i = 0; i < 24; i++)
			if (d[k2][i] && d[k2][i] < res)
				res = d[k2][i];
		if (res != INF)

			printf("Vladimir needs %d litre(s) of blood.\n", res - 1);
		else
			printf("There is no route Vladimir can take.\n");

	}

map <string, int> mp;

	return 0;
}
