1.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, WS09
* Problem: 10048 - Audiophobia
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=12&page=show_problem&problem=989
*
* @author Dennis Wilfert
* @version 1.0, 10/30/2009
*
* Method : Floyd Warshall
* Status : Accepted
* Runtime: 0.356
*/
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class Main {

public static void main(String[] args) throws IOException {

BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
PrintWriter writer = new PrintWriter(new BufferedOutputStream(System.out));
StringTokenizer token;

int[][] intensities;

int C, S, Q, c1, c2, d, i, j, k;
int max;
int cases = 1;

final int MAX = 100000;
token = new StringTokenizer(reader.readLine());

C = Integer.parseInt(token.nextToken());
S = Integer.parseInt(token.nextToken());
Q = Integer.parseInt(token.nextToken());

while (C != 0) {

intensities = new int[C][C];

// Array mit einer hohen Lautstärke vorbelegen
for (i = 0; i < C; i++) {
for (j = 0; j < C; j++) {
intensities[i][j] = MAX;
}
}

// Lautstärken eintragen
for (i = 0; i < S; i++) {
token = new StringTokenizer(reader.readLine());
c1 = Integer.parseInt(token.nextToken()) - 1;
c2 = Integer.parseInt(token.nextToken()) - 1;
d = Integer.parseInt(token.nextToken());
intensities[c1][c2] = intensities[c2][c1] = d;
}

for (k = 0; k < C; k++) {
for (i = 0; i < C; i++) {
for (j = 0; j < C; j++) {
// Den kürzesten Wege suchen
max = intensities[i][k] > intensities[k][j] ? intensities[i][k] : intensities[k][j];

if (max < intensities[i][j]) {
intensities[i][j] = max;
}
}
}
}

// Ausgabe erstellen
if (cases > 1) {
writer.println();
}
writer.println("Case #" + cases);


for (i = 0; i < Q; i++) {
token = new StringTokenizer(reader.readLine());
c1 = Integer.parseInt(token.nextToken()) - 1;
c2 = Integer.parseInt(token.nextToken()) - 1;
writer.println(intensities[c1][c2] == MAX ? "no path" : intensities[c1][c2]);
}
cases++;

token = new StringTokenizer(reader.readLine());

C = Integer.parseInt(token.nextToken());
S = Integer.parseInt(token.nextToken());
Q = Integer.parseInt(token.nextToken());

}
writer.flush();
}
}