#include <bits/stdc++.h>   using namespace std;   const int maxn = 200007;   string s;   int fa[maxn << 1];   map<string, int> aa;   int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }   string read() {     cin >> s;     return s;   }   int main() {     int n, m, q;     scanf( %d%d%d , &n, &m, &q);     for (int i = 1; i <= 2 * n; i++) fa[i] = i;     for (int i = 1; i <= n; i++) aa[read()] = i;     for (int i = 1; i <= m; i++) {       int t;       scanf( %d , &t);       int x = aa[read()], y = aa[read()];       if (t == 1) {         if (find(x) != find(y + n) && find(x + n) != find(y))           fa[find(x)] = find(y), fa[find(x + n)] = find(y + n), printf( YES n );         else           printf( NO n );       } else {         if (find(x) != find(y) && find(x + n) != find(y + n))           fa[find(x)] = find(y + n), fa[find(x + n)] = find(y), printf( YES n );         else           printf( NO n );       }     }     for (int i = 1; i <= q; i++) {       int x = aa[read()], y = aa[read()];       if (find(x) == find(y))         printf( 1 n );       else if (find(x) == find(y + n))         printf( 2 n );       else         printf( 3 n );     }     return 0;   }   