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

//import java.math.*;

public class parties_sp_n3 implements Runnable {
	public static void main(String[] args) {
		new Thread(new parties_sp_n3()).start();
	}

	@Override
	public void run() {
		try {
			br = new BufferedReader(new FileReader(FNAME + ".in"));
			out = new PrintWriter(FNAME + ".out");
			solve();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	boolean eof = false;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return "0";
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	private final String FNAME = "parties";

	void solve() {
		int n = nextInt();
		int m = nextInt();
		int k = nextInt();
		long[][] tab = new long[n][n];
		int[] s = new int[n];
		String situation = nextToken();
		for (int i = 0; i < n; i++) {
			Arrays.fill(tab[i], Integer.MAX_VALUE / 2);
			s[i] = situation.charAt(i) == 'L' ? 0 : 1;
		}
		for (int i = 0; i < m; i++) {
			int a = nextInt() - 1;
			int b = nextInt() - 1;
			int c = nextInt();
			tab[a][b] = c;
			tab[b][a] = c;
		}
		for (int kk = 0; kk < n; kk++) {
			System.err.println(kk);
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					tab[i][j] = Math.min(tab[i][j], tab[i][kk] + tab[kk][j]);
				}
			}
		}
		int[] ans = findBest(tab, s);
		out.println(ans[2] + " " + (ans[0] + 1) + " " + (ans[1] + 1));
		for (int i = 0; i < k; i++) {
			System.err.println(k);
			int x = nextInt() - 1;
			s[x] = 1 - s[x];
			ans = findBest(tab, s);
			out.println(ans[2] + " " + (ans[0] + 1) + " " + (ans[1] + 1));
		}
	}
	
	int[] findBest(long[][] tab, int[] s) {
		int n = s.length;
		int[] ret = new int[3];
		ret[2] = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (s[i] == s[j] && tab[i][j] < ret[2]) {
					ret[2] = (int) tab[i][j];
					ret[0] = i;
					ret[1] = j;
				}
			}
		}
		return ret;
	}
}
