#include using namespace std; using ll = long long; struct Trie{ struct Node { std::array child; int sz; Node(void) :sz(0) { child.fill(-1); } const int& operator[](int k) const { return child[k]; } int& operator[](int k) { return child[k]; } }; int num; vector tree; Trie() : num(0) { tree.push_back(Node()); } void insert(const string &s){ int cur = 0; for(auto c : s){ if(tree[cur][c - 'a'] == -1){ tree[cur][c - 'a'] = ++num; tree.push_back(Node()); } cur = tree[cur][c - 'a']; tree[cur].sz++; } } void erase(const string &s){ int cur = 0; for(auto c : s){ cur = tree[cur][c - 'a']; tree[cur].sz--; } } int size(const string &s){ int cur = 0; for(auto c:s){ if(tree[cur][c - 'a'] == -1) return 0; cur = tree[cur][c - 'a']; } return tree[cur].sz; } int size(int node_num){ return (node_num==-1?0:tree[node_num].sz); } int search(string &s){ int cur=0,ans=0; array t; t.fill(0); for(auto c:s)t[c-'a']++; for(auto c:s){ for(int j=0;j<26;j++){ if(t[j])ans+=size(tree[cur][j]); } if(tree[cur][c-'a']==-1)return ans; cur=tree[cur][c-'a']; t[c-'a']--; } return ans; } }; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, l, q; cin >> n >> l >> q; vector s(n); Trie trie; for(auto &&ss : s){ cin >> ss; trie.insert(ss); } while(q--){ int cmd; cin >> cmd; if(cmd == 1){ int k; char c1, c2; cin >> k >> c1 >> c2; k--; for(auto &&ss : s){ if(ss[k] == c1){ trie.erase(ss); ss[k] = c2; trie.insert(ss); } } }else{ string s; cin >> s; cout << trie.size(s) << '\n'; } } }