#include //#include //using namespace atcoder; #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") const double pi = 3.141592653589793238462643383279; using namespace std; //typedef //------------------------------------------ typedef vector VI; typedef vector VVI; typedef vector VS; typedef pair PII; typedef pair PLL; typedef pair TIII; typedef long long LL; typedef unsigned long long ULL; typedef vector VLL; typedef vector VVLL; //container util //------------------------------------------ #define ALL(a) (a).begin(), (a).endf() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define MP make_pair #define SZ(a) int((a).size()) #define SQ(a) ((a) * (a)) #define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).endf(); ++i) #define EXIST(s, e) ((s).find(e) != (s).endf()) #define SORT(c) sort((c).begin(), (c).endf()) //repetition //------------------------------------------ #define FOR(i, s, n) for (int i = s; i < (int)n; ++i) #define REP(i, n) FOR(i, 0, n) #define MOD 1000000007 #define rep(i, a, b) for (int i = a; i < (b); ++i) #define trav(a, x) for (auto &a : x) #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() typedef long long ll; typedef pair pii; typedef vector vi; #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) const double EPS = 1e-4, PI = acos(-1); //ここから編集 typedef string::const_iterator State; struct UnionFind{ vector par; vector siz; UnionFind(int sz_): par(sz_), siz(sz_) { for(int i=0; i> N >> M >> Q; vector s(N); UnionFind uf(N*8); REP(i,N){ cin >> s[i]; int mask = 0; for(int j=0; j<7; j++){ if(s[i][j] == '1' && s[i][(j+1)%7] == '1'){ uf.merge(i*7+j, i*7+(j+1)%7); } } } vector> g(N); REP(i,M){ int u, v; cin >> u >> v; u--; v--; g[u].push_back(v); g[v].push_back(u); } REP(v,N){ for(auto u: g[v]){ for(int i=0; i<7; i++){ if(s[v][i] == '1' && s[u][i] == '1'){ uf.merge(v*7+i, u*7+i); } } } } REP(i,Q){ int q; cin >> q; if(q == 1){ int x, y; cin >> x >> y; x--; y--; s[x][y] = '1'; for(auto u: g[x]){ for(int j=0; j<7; j++){ if(s[x][j]=='1' && s[u][j]=='1'){ uf.merge(x*7+j, u*7+j); } } } for(int j=0; j<7; j++){ if(s[x][j]=='1' && s[x][(j+1)%7]=='1'){ uf.merge(x*7+j, x*7+(j+1)%7); } } }else{ int x, t; cin >> x >> t; x--; cout << uf.size(x*7) << endl; } } return 0; }