import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) class UF_tree: def __init__(self, n): """ 0-indexed """ self.root = [-1] * n self.components = n def find(self, x): if self.root[x] < 0: return x self.root[x] = self.find(self.root[x]) return self.root[x] def same(self, x, y): return self.find(x) == self.find(y) def merge(self, x, y): x = self.find(x) y = self.find(y) if x == y: return False if -self.root[x] > -self.root[y]: x, y = y, x self.root[y] += self.root[x] self.root[x] = y self.components -= 1 return True def size(self, x): return -self.root[self.find(x)] N, M, Q = map(int, input().split()) uf = UF_tree(7 * N) S = [sum(1 << i for i, s in enumerate(input().rstrip()) if s == "1") for _ in range(N)] for i, s in enumerate(S): i *= 7 for j in range(7): k = (j + 1) % 7 if (s >> j) & 1 and (s >> k) & 1: uf.merge(i + j, i + k) edge = [[] for _ in range(N)] for _ in range(M): a, b = map(int, input().split()) a -= 1 b -= 1 edge[a].append(b) edge[b].append(a) for i in range(7): if (S[a] >> i) & 1 and (S[b] >> i) & 1: uf.merge(7 * a + i, 7 * b + i) for _ in range(Q): f, x, y = map(int, input().split()) x -= 1 y -= 1 if f == 1: S[x] |= (1 << y) l = (y - 1) % 7 if (S[x] >> l) & 1: uf.merge(7 * x + y, 7 * x + l) r = (y + 1) % 7 if (S[x] >> r) & 1: uf.merge(7 * x + y, 7 * x + r) for z in edge[x]: if (S[z] >> y) & 1: uf.merge(7 * x + y, 7 * z + y) else: print(uf.size(7 * x))