1. 

/*
* @Lesson: ACM
* @Problem: 10048 Audiophobia
* @Status: AC
* @Time: 0.416
* @Method: Floyd-Warshall, (Minimax), cash Output
* @Author: Christoph Miesel
*/

import java.util.*;
import java.io.*;

public class Audiophobia
{
static int C, S, Q, counter = 0;
static int[][] adj = new int[101][101];

static int min(int i1, int i2)
{
return i1 < i2 ? i1 : i2;
}

static int max(int i1, int i2)
{
return i1 > i2 ? i1 : i2;
}

static void clear()
{
for(int i = 0; i < 101; i++)
for(int j = 0; j < 101; j++)
adj[i][j] = Integer.MAX_VALUE;
for(int i = 0; i < 101; i++)
adj[i][i] = 0;
}

static void floydW()
{
for(int k = 1; k <= C; k++)
for(int i = 1; i <= C; i++)
{
for(int j = 1; j <= C; j++)
{
//System.out.println("from "+i+" to "+j+" "+min(max(adj[i][k], adj[k][j]), adj[i][j]));
adj[i][j] = min(max(adj[i][k], adj[k][j]), adj[i][j]);
}
}
}

public static void main(String... args) throws IOException
{
boolean first = true;
int from, to, weight;
StringBuilder sb = new StringBuilder();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer token;

while(true)
{
counter++;

token = new StringTokenizer(reader.readLine());
C = Integer.parseInt(token.nextToken());
S = Integer.parseInt(token.nextToken());
Q = Integer.parseInt(token.nextToken());

if(C==0 && S==0 && Q==0)
break;

if(!first)
{
sb.append("\n\n");
}
first = false;

if(Q != 0)
sb.append("Case #"+counter+"\n");
else sb.append("Case #"+counter);

clear();
for(int i = 0; i < S; i++)
{
token = new StringTokenizer(reader.readLine());
from = Integer.parseInt(token.nextToken());
to = Integer.parseInt(token.nextToken());
weight = Integer.parseInt(token.nextToken());
adj[from][to] = weight;
adj[to][from] = weight;
}

floydW();
for(int i = 0; i < Q; i++)
{
token = new StringTokenizer(reader.readLine());
from = Integer.parseInt(token.nextToken());
to = Integer.parseInt(token.nextToken());
if(adj[to][from] == Integer.MAX_VALUE)
{
if(Q-1 != i)
sb.append("no path\n");
else sb.append("no path");
}
else if(Q-1 != i)
sb.append(adj[to][from]+"\n");
else sb.append(adj[to][from]);
}
}
System.out.println(sb);
}
}