import java.util.*;
import java.util.Map.Entry;

import ru.ifmo.testlib.*;
import ru.ifmo.testlib.Outcome.Type;

public class Check implements Checker {

	TreeMap<Integer, Integer>[] G;
	
	TreeMap<Pair, Integer> dist = new TreeMap<Pair, Integer>();
	
	class Pair implements Comparable<Pair> {
		int a, b;
		
		Pair(int aa, int bb) {
			a = Math.min(aa, bb);
			b = Math.max(aa, bb);
		}

		@Override
		public int compareTo(Pair o) {
			if (a != o.a) return a - o.a;
			return b - o.b;
		}
	}
	
	int dist(int a, int b) {
		Pair p = new Pair(a, b);
		if (dist.containsKey(p)) {
			return dist.get(p);
		}
		int d = Integer.MAX_VALUE;
		if (G[a].containsKey(b)) {
			d = G[a].get(b);
		}
		if (G[a].size() < G[b].size()) {
			for (Entry<Integer, Integer> e : G[a].entrySet()) {
				if (G[e.getKey()].containsKey(b)) {
					d = Math.min(d, e.getValue() + G[e.getKey()].get(b));
				}
			}
		} else {
			for (Entry<Integer, Integer> e : G[b].entrySet()) {
				if (G[e.getKey()].containsKey(a)) {
					d = Math.min(d, e.getValue() + G[e.getKey()].get(a));
				}
			}
		}
		dist.put(p, d);
		return d;
	}

	@Override
    public Outcome test(InStream inf, InStream ouf, InStream ans) {
    	int n = inf.nextInt();
    	int m = inf.nextInt();
    	int k = inf.nextInt();
		int[] s = new int[n];
		String situation = inf.nextToken();
		G = new TreeMap[n];
		for (int i = 0; i < n; i++) {
			s[i] = situation.charAt(i) == 'L' ? 0 : 1;
			G[i] = new TreeMap<Integer, Integer>();
		}
		for (int i = 0; i < m; i++) {
			int a = inf.nextInt() - 1;
			int b = inf.nextInt() - 1;
			int c = inf.nextInt();
			G[a].put(b, c);
			G[b].put(a, c);
		}
		for (int i = 0; i <= k; i++) {
			int jd = ans.nextInt();
			int ja = ans.nextInt() - 1;
			int jb = ans.nextInt() - 1;
			int pd = ouf.nextInt();
			int pa = ouf.nextInt() - 1;
			int pb = ouf.nextInt() - 1;
			if (pa < 0 || pa >= n) return new Outcome(Type.WA, "Wrong number of vertex: " + (pa + 1));
			if (pb < 0 || pb >= n) return new Outcome(Type.WA, "Wrong number of vertex: " + (pb + 1));
			if (pd > jd) {
				return new Outcome(Type.WA, "Contestant found non-optimal solution on step " + i);
			}
			if (s[pa] != s[pb]) {
				return new Outcome(Type.WA, "Vertices have different parties on step " + i);
			}
			int dist = dist(pa, pb);
			if (dist != pd) {
				return new Outcome(Type.WA, "Contestant found wrong distance: " + pd + ", instead of " + dist);
			}
			if (pd < jd) {
				return new Outcome(Type.FAIL, "Contestant found better solution on step " + i);
			}
			if (i < k) {
				int x = inf.nextInt() - 1;
				s[x] = 1 - s[x];
			}
		}
        return new Outcome(Type.OK, "OK");
    }
}
