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.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {
       ConsoleIO io = new ConsoleIO(new InputStreamReader(System.in), new PrintWriter(System.out));
        //ConsoleIO io = new ConsoleIO(new FileReader("D:\\fbhc\\fighting_all_the_zombies_example_input.txt"), new PrintWriter(new File("D:\\fbhc\\out.txt")));
        new Main(io).solve();
        io.close();
    }
    ConsoleIO io;
    Main(ConsoleIO io) {
        this.io = io;
    }

    long MOD = 1_000_000_007;
    int N, M, W, K, Q;
    List<List<Integer>> gr = new ArrayList<>();

    HashMap<String, Integer> map = new HashMap<>();
    int[] all;
    int[] height;
    int[] anti;

    public void solve() {
        int[] l = io.readIntArray();
        N = l[0];M = l[1]; Q = l[2];
        String[] words = io.readLine().trim().split(" ");
        all = new int[N];
        height = new int[N];
        anti = new int[N];
        for(int i = 0;i<N;i++){
            all[i] = i;
            anti[i] = -1;
        }
        for(int i = 0;i<words.length;i++)map.put(words[i], i);
        StringBuilder res=  new StringBuilder();
        for(int i = 0;i<M;i++) {
            String[] rel = io.readLine().trim().split(" ");
            int g1 = getGroup(rel[1]);
            int g2 = getGroup(rel[2]);
            if (rel[0].charAt(0) == '1') {
                if(anti[g1] != g2) {
                    int a1 = anti[g1], a2 = anti[g2];
                    int p1 = join(g1, g2);
                    if (a1 != -1 && a2 != -1) {
                        int p2 = join(a1, a2);
                        anti[p1] = p2;
                        anti[p2] = p1;
                    } else if(a1 != -1){
                        anti[p1] = a1;
                        anti[a1] = p1;
                    }else if(a2 != -1){
                        anti[p1] = a2;
                        anti[a2] = p1;
                    }
                    res.append("YES");
                }else {
                    res.append("NO");
                }
            } else {
                if (g1 != g2) {
                    if (anti[g1] == -1) anti[g1] = g2;
                    if (anti[g2] == -1) anti[g2] = g1;
                    int p1 = join(anti[g1], g2);
                    int p2 = join(anti[g2], g1);
                    anti[p1] = p2;
                    anti[p2] = p1;
                    res.append("YES");
                } else {
                    res.append("NO");
                }
            }
            res.append(System.lineSeparator());
        }
        for(int i = 0;i<Q;i++){
            String[] p = io.readLine().trim().split(" ");
            int g1 = getGroup(p[0]);
            int g2 = getGroup(p[1]);
            if(g1==g2)res.append("1");
            else if(anti[g1]!=-1 && getGroup(anti[g1]) == g2) res.append("2");
            else res.append("3");
            res.append(System.lineSeparator());
        }
        io.writeLine(res.toString());
    }

    int getGroup(String s){
        int k = map.get(s);
        return getGroup(k);
    }

    int getGroup(int k){
        while(all[k]!=k){
            k = all[k];
        }
        return k;
    }

    int join(int k1, int k2){
        int g1 = getGroup(k1);
        int g2 = getGroup(k2);
        if(g1!=g2) {
            int h1 = height[g1];
            int h2 = height[g2];
            if (h1 < h2) {
                all[g1] = g2;
                height[g2] = Math.max(h2, h1 + 1);
                return g2;
            } else {
                all[g2] = g1;
                height[g1] = Math.max(h1, h2 + 1);
                return g1;
            }
        }
        return g1;
    }

}

class ConsoleIO {
    BufferedReader br;
    PrintWriter out;
    public ConsoleIO(Reader reader, PrintWriter writer){br = new BufferedReader(reader);out = writer;}
    public void flush(){this.out.flush();}
    public void close(){this.out.close();}
    public void writeLine(String s) {this.out.println(s);}
    public void writeInt(int a) {this.out.print(a);this.out.print(' ');}
    public void writeWord(String s){
        this.out.print(s);
    }
    public void writeIntArray(int[] a, int k, String separator) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < k; i++) {
            if (i > 0) sb.append(separator);
            sb.append(a[i]);
        }
        this.writeLine(sb.toString());
    }
    public int read(char[] buf, int len){try {return br.read(buf,0,len);}catch (Exception ex){ return -1; }}
    public String readLine() {try {return br.readLine();}catch (Exception ex){ return "";}}
    public long[] readLongArray() {
        String[]n=this.readLine().trim().split("\\s+");long[]r=new long[n.length];
        for(int i=0;i<n.length;i++)r[i]=Long.parseLong(n[i]);
        return r;
    }
    public int[] readIntArray() {
        String[]n=this.readLine().trim().split("\\s+");int[]r=new int[n.length];
        for(int i=0;i<n.length;i++)r[i]=Integer.parseInt(n[i]);
        return r;
    }
    public int[] readIntArray(int n) {
        int[] res = new int[n];
        char[] all = this.readLine().toCharArray();
        int cur = 0;boolean have = false;
        int k = 0;
        boolean neg = false;
        for(int i = 0;i<all.length;i++){
            if(all[i]>='0' && all[i]<='9'){
                cur = cur*10+all[i]-'0';
                have = true;
            }else if(all[i]=='-') {
                neg = true;
            }
            else if(have){
                res[k++] = neg?-cur:cur;
                cur = 0;
                have = false;
                neg = false;
            }
        }
        if(have)res[k++] = neg?-cur:cur;
        return res;
    }
    public int ri() {
        try {
            int r = 0;
            boolean start = false;
            boolean neg = false;
            while (true) {
                int c = br.read();
                if (c >= '0' && c <= '9') {
                    r = r * 10 + c - '0';
                    start = true;
                } else if (!start && c == '-') {
                    start = true;
                    neg = true;
                } else if (start || c == -1) return neg ? -r : r;
            }
        } catch (Exception ex) {
            return -1;
        }
    }
    public long readLong() {
        try {
            long r = 0;
            boolean start = false;
            boolean neg = false;
            while (true) {
                int c = br.read();
                if (c >= '0' && c <= '9') {
                    r = r * 10 + c - '0';
                    start = true;
                } else if (!start && c == '-') {
                    start = true;
                    neg = true;
                } else if (start || c == -1) return neg ? -r : r;
            }
        } catch (Exception ex) {
            return -1;
        }
    }
    public String readWord() {
        try {
            boolean start = false;
            StringBuilder sb = new StringBuilder();
            while (true) {
                int c = br.read();
                if (c!= ' ' && c!= '\r' && c!='\n' && c!='\t') {
                    sb.append((char)c);
                    start = true;
                } else if (start || c == -1) return sb.toString();
            }
        } catch (Exception ex) {
            return "";
        }
    }
    public char readSymbol() {
        try {
            while (true) {
                int c = br.read();
                if (c != ' ' && c != '\r' && c != '\n' && c != '\t') {
                    return (char) c;
                }
            }
        } catch (Exception ex) {
            return 0;
        }
    }
    //public char readChar(){try {return (char)br.read();}catch (Exception ex){ return 0; }}
}