/** author: shobonvip created: 2025.02.14 22:06:02 **/ #include<bits/stdc++.h> using namespace std; //* ATCODER #include<atcoder/all> using namespace atcoder; typedef modint998244353 mint; //*/ /* BOOST MULTIPRECISION #include<boost/multiprecision/cpp_int.hpp> using namespace boost::multiprecision; //*/ typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) #define all(v) v.begin(), v.end() template <typename T> bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template <typename T> bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } template <typename T> T max(vector<T> &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]); return ret; } template <typename T> T min(vector<T> &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]); return ret; } template <typename T> T sum(vector<T> &a){ T ret = 0; for (int i=0; i<(int)a.size(); i++) ret += a[i]; return ret; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; map<pair<int,int>,int> edge; vector<int> x(m), y(m); rep(i,0,m) { cin >> x[i] >> y[i]; x[i]--; y[i]--; } vector<ll> a(n); rep(i,0,n) cin >> a[i]; int q; cin >> q; vector<int> t(q); vector<int> p(q); vector<ll> c(q); rep(i,0,q) { cin >> t[i]; if (t[i] == 1) { int u, v; cin >> u >> v; u--; v--; x.push_back(u); y.push_back(v); }else if(t[i] == 2){ cin >> p[i]; p[i]--; cin >> c[i]; }else{ cin >> p[i]; p[i]--; } } int k = x.size(); vector<bool> alive(k); rep(i,0,m) { alive[i] = 1; edge[pair(x[i],y[i])] = i; } vector<int> deg(n); vector<vector<int>> ikeru(n, vector<int>(0)); rep(i,0,k){ deg[x[i]]++; deg[y[i]]++; ikeru[x[i]].push_back(i); ikeru[y[i]].push_back(i); } // nonvip ... 変更時に寄与を与える. // vip ... 何も与えない. const int BORDER = 300; vector<int> vip; vector<int> is_vip(n, -1); rep(i,0,n) { if (deg[i] >= BORDER) { is_vip[i] = (int)vip.size(); vip.push_back(i); } } int nvip = (int)vip.size(); vector vip_set(n, vector<bool>(nvip)); rep(i,0,n) { for (int t: ikeru[i]) { if (alive[t]) { int j = i^x[t]^y[t]; if (is_vip[j] >= 0) { vip_set[i][is_vip[j]] = 1; } } } } vector<ll> kiyo(n); rep(i,0,n) { if (is_vip[i] == -1) { for (int t: ikeru[i]){ if (alive[t]) { int j = i^x[t]^y[t]; kiyo[j] += a[i]; } } } } int cnt = m; rep(i,0,q) { if (t[i] == 1) { if (edge.find(pair(x[cnt],y[cnt]))==edge.end()){ edge[pair(x[cnt],y[cnt])] = cnt; if (is_vip[x[cnt]] == -1) { kiyo[y[cnt]] += a[x[cnt]]; }else{ vip_set[y[cnt]][is_vip[x[cnt]]] = 1; } if (is_vip[y[cnt]] == -1) { kiyo[x[cnt]] += a[y[cnt]]; }else{ vip_set[x[cnt]][is_vip[y[cnt]]] = 1; } alive[cnt] = 1; }else{ alive[edge[pair(x[cnt],y[cnt])]] = 0; edge.erase(pair(x[cnt],y[cnt])); if (is_vip[x[cnt]] == -1) { kiyo[y[cnt]] -= a[x[cnt]]; }else{ vip_set[y[cnt]][is_vip[x[cnt]]] = 0; } if (is_vip[y[cnt]] == -1) { kiyo[x[cnt]] -= a[y[cnt]]; }else{ vip_set[x[cnt]][is_vip[y[cnt]]] = 0; } } cnt++; }else if(t[i] == 2){ if (is_vip[p[i]] == -1) { for (int t: ikeru[p[i]]){ if (alive[t]) { int j = p[i]^x[t]^y[t]; kiyo[j] -= a[p[i]]; } } } a[p[i]] = c[i]; if (is_vip[p[i]] == -1) { for (int t: ikeru[p[i]]){ if (alive[t]) { int j = p[i]^x[t]^y[t]; kiyo[j] += a[p[i]]; } } } }else{ ll ans = kiyo[p[i]]; rep(j,0,nvip) { if (vip_set[p[i]][j]) { ans += a[vip[j]]; } } cout << ans << '\n'; } } }