#include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int N,M; cin >> N >> M; vector> Graph(N),Graph2(N); for(int i=0; i> u >> v; u--; v--; Graph.at(u).insert(v); Graph.at(v).insert(u); } vector A(N); for(auto &a : A) cin >> a; int B = 550; unordered_set Big; vector answer(N); for(int i=0; i= B){ Big.insert(i); for(auto &to : Graph.at(i)) if(Graph.at(to).size() >= B) Graph2.at(i).insert(to); } else for(auto &to : Graph.at(i)) if(Graph.at(to).size() >= B) answer.at(to) += A.at(i); } int Q; cin >> Q; while(Q--){ int t; cin >> t; if(t == 1){ int u,v; cin >> u >> v; u--; v--; if(Graph.at(u).count(v)){ Graph.at(u).erase(v); Graph.at(v).erase(u); if(Graph2.at(u).count(v)) Graph2.at(u).erase(v),Graph2.at(v).erase(u); if(Graph.at(u).size()+1 == B){ for(auto &to : Graph.at(u)) if(Graph.at(to).size() >= B){ answer.at(to) += A.at(u); Graph2.at(u).erase(to); Graph2.at(to).erase(u); } answer.at(u) = 0; Big.erase(u); } if(Graph.at(v).size()+1 == B){ for(auto &to : Graph.at(v)) if(Graph.at(to).size() >= B){ answer.at(to) += A.at(v); Graph2.at(v).erase(to); Graph2.at(to).erase(v); } answer.at(v) = 0; Big.erase(v); } } else{ Graph.at(u).insert(v); Graph.at(v).insert(u); if(Graph.at(u).size() >= B && Graph.at(v).size() >= B){ Graph2.at(u).insert(v); Graph2.at(v).insert(u); } if(Graph.at(u).size() == B){ for(auto &to : Graph.at(u)){ if(Graph.at(to).size() < B) answer.at(u) += A.at(to); else if(to != v){ Graph2.at(u).insert(to),Graph2.at(to).insert(u); answer.at(to) -= A.at(u); } } Big.insert(u); } if(Graph.at(v).size() == B){ for(auto &to : Graph.at(v)){ if(Graph.at(to).size() < B) answer.at(v) += A.at(to); else if(to != u){ Graph2.at(v).insert(to),Graph2.at(to).insert(v); answer.at(to) -= A.at(v); } } Big.insert(v); } } } if(t == 2){ int p,a; cin >> p >> a; p--; int diff = a-A.at(p); A.at(p) = a; if(Graph.at(p).size() < B) for(auto &to : Graph.at(p)) if(Graph.at(to).size() >= B) answer.at(to) += diff; } if(t == 3){ int v; cin >> v; v--; if(Big.count(v)){ long long ans = answer.at(v); for(auto &to : Graph2.at(v)) ans += A.at(to); cout << ans << "\n"; } else{ long long ans = 0; for(auto &to : Graph.at(v)) ans += A.at(to); cout << ans << "\n"; } } } }