#include using namespace std; class unionfind { vector par, s; public: unionfind(int n) { for (int i = 0; i < n; i++) { par.push_back(i); s.push_back(1); } } int find(int n) { if (par.at(n) == n) return n; return find(par.at(n)); } void merge(int m, int n) { m = find(m); n = find(n); if (m == n) return; if (s.at(m) > s.at(n)) swap(m, n); par.at(m) = n; s.at(n) += s.at(m); } int size(int n) { return s.at(find(n)); } }; int main() { int n, m, q; cin >> n >> m >> q; vector s(n); for (int i = 0; i < n; i++) { cin >> s.at(i); } unionfind t(7 * n); for (int i = 0; i < n; i++) { for (int j = 0; j < 7; j++) { if (s.at(i).at(j) == '1' and s.at(i).at((j + 1) % 7) == '1') { t.merge(7 * i + j, 7 * i + (j + 1) % 7); } } } vector> to(n); for (int i = 0; i < m; i++) { int u, v; cin >> u >> v; u--; v--; to.at(u).push_back(v); to.at(v).push_back(u); for (int j = 0; j < 7; j++) { if (s.at(u).at(j) == '1' and s.at(v).at(j) == '1') { t.merge(7 * u + j, 7 * v + j); } } } for (int i = 0; i < q; i++) { int w, x, y; cin >> w >> x >> y; x--; y--; if (w == 1) { assert(s.at(x).at(y) == '0'); s.at(x).at(y) = '1'; if (s.at(x).at((y + 1) % 7) == '1') { t.merge(7 * x + y, 7 * x + (y + 1) % 7); } if (s.at(x).at((y + 6) % 7) == '1') { t.merge(7 * x + y, 7 * x + (y + 6) % 7); } for (auto next : to.at(x)) { if (s.at(next).at(y) == '1') { t.merge(7 * x + y, 7 * next + y); } } } else { cout << t.size(7 * x) << endl; } } }