Mahmoud wants to write a new dictionary that contains n words and relations between them. There are two types of relations: synonymy (i. e. the two words mean the same) and antonymy (i. e. the two words mean the opposite). From time to time he discovers a new relation between two words.

He know that if two words have a relation between them, then each of them has relations with the words that has relations with the other. For example, if like means love and love is the opposite of hate, then like is also the opposite of hate. One more example: if love is the opposite of hate and hate is the opposite of like, then love means like, and so on.

Sometimes Mahmoud discovers a wrong relation. A wrong relation is a relation that makes two words equal and opposite at the same time. For example if he knows that love means like and like is the opposite of hate, and then he figures out that hate means like, the last relation is absolutely wrong because it makes hate and like opposite and have the same meaning at the same time.

After Mahmoud figured out many relations, he was worried that some of them were wrong so that they will make other relations also wrong, so he decided to tell every relation he figured out to his coder friend Ehab and for every relation he wanted to know is it correct or wrong, basing on the previously discovered relations. If it is wrong he ignores it, and doesn't check with following relations.

After adding all relations, Mahmoud asked Ehab about relations between some words based on the information he had given to him. Ehab is busy making a Codeforces round so he asked you for help.

Input

The first line of input contains three integers n, m and q (2 ≤ n ≤ 105, 1 ≤ m, q ≤ 105) where n is the number of words in the dictionary, m is the number of relations Mahmoud figured out and q is the number of questions Mahmoud asked after telling all relations.

The second line contains n distinct words a1, a2, ..., an consisting of small English letters with length not exceeding 20, which are the words in the dictionary.

Then m lines follow, each of them contains an integer t (1 ≤ t ≤ 2) followed by two different words xi and yi which has appeared in the dictionary words. If t = 1, that means xi has a synonymy relation with yi, otherwise xi has an antonymy relation with yi.

Then q lines follow, each of them contains two different words which has appeared in the dictionary. That are the pairs of words Mahmoud wants to know the relation between basing on the relations he had discovered.

All words in input contain only lowercase English letters and their lengths don't exceed 20 characters. In all relations and in all questions the two words are different.

Output

First, print m lines, one per each relation. If some relation is wrong (makes two words opposite and have the same meaning at the same time) you should print "NO" (without quotes) and ignore it, otherwise print "YES" (without quotes).

After that print q lines, one per each question. If the two words have the same meaning, output 1. If they are opposites, output 2. If there is no relation between them, output 3.

See the samples for better understanding.

Examples

Input

3 3 4
hate love like
1 love like
2 love hate
1 hate like
love like
love hate
like hate
hate like


Output

YES
YES
NO
1
2
2
2


Input

8 6 5
hi welcome hello ihateyou goaway dog cat rat
1 hi welcome
1 ihateyou goaway
2 hello ihateyou
2 hi goaway
2 hi hello
1 hi hello
dog cat
dog hi
hi hello
ihateyou goaway
welcome ihateyou


Output

YES
YES
YES
YES
NO
YES
3
3
1
1
2
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.Map;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyBufferedReader in = new MyBufferedReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, MyBufferedReader in, PrintWriter out) {

            int[] data = in.getALineOfInts(3);

            int n = data[0];
            int m = data[1];
            int q = data[2];

            Map<String, Integer> wordToId = new HashMap<>();
            String words = in.readLine();
            StringTokenizer st = new StringTokenizer(words);
            int id = 0;
            while (st.hasMoreTokens()) {
                wordToId.put(st.nextToken(), id);
                id++;
            }

            ArrayList<ArrayList<TaskD.Edge>> neigh = new ArrayList<>(n);
            for (int i = 0; i < n; i++) {
                neigh.add(new ArrayList<>());
            }

            UnionFind inGraph = new UnionFind(n);
            TaskD.Edge[] edges = new TaskD.Edge[m];
            for (int i = 0; i < m; i++) {
                String d = in.readLine();
                st = new StringTokenizer(d);
                int type = Integer.parseInt(st.nextToken());
                String w1 = st.nextToken();
                String w2 = st.nextToken();
                int w1Id = wordToId.get(w1);
                int w2Id = wordToId.get(w2);
                TaskD.Edge ne = new TaskD.Edge(w1Id, w2Id, type - 1);
                edges[i] = ne;
                if (!inGraph.find(w1Id, w2Id)) {
                    ne.delayDecision = false;
                    neigh.get(w1Id).add(ne);
                    neigh.get(w2Id).add(new TaskD.Edge(w2Id, w1Id, type - 1));
                    inGraph.unite(w1Id, w2Id);
                }
            }

            int[] xors = computeXors(neigh, n);
            for (TaskD.Edge e : edges) {
                if (e.delayDecision) {
                    int n1 = e.src;
                    int n2 = e.nbr;
                    int parityOfPathBetweenNodes = xors[n1] ^ xors[n2];
                    if (e.weight == parityOfPathBetweenNodes) {
                        out.println("YES");
                    } else {
                        out.println("NO");
                    }
                } else {
                    out.println("YES");
                }
            }

            for (int i = 0; i < q; i++) {
                String d = in.readLine();
                st = new StringTokenizer(d);
                String w1 = st.nextToken();
                String w2 = st.nextToken();
                int w1Id = wordToId.get(w1);
                int w2Id = wordToId.get(w2);

                if (inGraph.find(w1Id, w2Id)) {
                    int parityOfPathBetweenNodes = (xors[w1Id] ^ xors[w2Id]) + 1;
                    out.println(parityOfPathBetweenNodes);
                } else {
                    out.println(3);
                }
            }

        }

        private int[] computeXors(ArrayList<ArrayList<TaskD.Edge>> neigh, int n) {
            int[] xors = new int[n];
            boolean[] visited = new boolean[n];
            for (int i = 0; i < n; i++) {
                if (!visited[i]) {
                    visit(i, neigh, visited, 0, xors);
                }
            }

            return xors;
        }

        private void visit(int curr, ArrayList<ArrayList<TaskD.Edge>> neigh, boolean[] visited,
                           int xorAcc, int[] xors) {
            xors[curr] = xorAcc;
            visited[curr] = true;

            ArrayList<TaskD.Edge> ns = neigh.get(curr);
            for (TaskD.Edge e : ns) {
                int node = e.nbr;
                if (!visited[node]) {
                    visit(node, neigh, visited, xorAcc ^ e.weight, xors);
                }
            }
        }

        static class Edge {
            int src;
            int nbr;
            int weight;
            boolean delayDecision;

            public Edge(int src, int nbr, int weight) {
                this.src = src;
                this.nbr = nbr;
                this.weight = weight;
                delayDecision = true;
            }

        }

    }

    static class MyBufferedReader {
        BufferedReader in;

        public MyBufferedReader(InputStream s) {
            this.in = new BufferedReader(new InputStreamReader(s));
        }

        public String readLine() {
            String res = null;

            try {
                res = in.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return res;
        }

        public int[] getALineOfInts(int numExpected) {
            int[] res = new int[numExpected];
            StringTokenizer st = null;
            try {
                st = new StringTokenizer(in.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
            for (int i = 0; i < numExpected; i++)
                res[i] = Integer.parseInt(st.nextToken());
            return res;
        }

    }

    static class UnionFind {
        private final int[] treeSize;
        private final int[] parents;

        public UnionFind(int size) {
            treeSize = new int[size];
            parents = new int[size];
            Arrays.fill(treeSize, 1);
            for (int i = 0; i < size; i++) {
                parents[i] = i;
            }
        }

        public void unite(int p, int q) {
            int rp = root(p);
            int rq = root(q);

            if (rp == rq) {
                return;
            }

            if (treeSize[rp] <= treeSize[rq]) {
                parents[rp] = rq;
                treeSize[rq] += treeSize[rp];
            } else {
                parents[rq] = rp;
                treeSize[rp] += treeSize[rq];
            }

        }

        public boolean find(int p, int q) {
            return root(p) == root(q);
        }

        public int root(int p) {
            int root = p;
            while (root != parents[root]) {
                root = parents[root];
            }

            while (p != root) {
                int parent = parents[p];
                //The following is correct but not necessary, as the tree sizes of non-root nodes
                // will not be used: if(parent != root) treeSize[parent] -= treeSize[p];
                parents[p] = root;
                p = parent;
            }

            return p;
        }

    }
}

