#include namespace { #pragma GCC diagnostic ignored "-Wunused-function" #include #pragma GCC diagnostic warning "-Wunused-function" using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; } template bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; } using ll = long long; using P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector>> to(n); vector

xy(m); for (auto& [x, y] : xy) cin >> x >> y, x--, y--, to[x].emplace_back(y, false), to[y].emplace_back(x, false); VI a(n); rep(i, n) cin >> a[i]; int q; cin >> q; vector> qs(q); for (auto& [t, x, y] : qs) { cin >> t; if (t == 1) { cin >> x >> y; x--, y--, to[x].emplace_back(y, false), to[y].emplace_back(x, false); } else if (t == 2) { cin >> x >> y; x--; } else { cin >> x; x--; } } rep(u, n) { sort(all(to[u])); to[u].erase(unique(all(to[u])), to[u].end()); } VI deg(n); rep(u, n) deg[u] = to[u].size(); vector

es; rep(u, n) for (auto [v, _] : to[u]) if (u < v) es.emplace_back(u, v); rep(u, n) to[u].clear(); for (auto [u, v] : es) { if (pair(deg[u], u) < pair(deg[v], v)) to[u].emplace_back(v, false); else to[v].emplace_back(u, false); } for (auto [x, y] : xy) { if (pair(deg[x], x) >= pair(deg[y], y)) swap(x, y); ranges::lower_bound(to[x], y, {}, &pair::first)->second = true; } VL s(n); rep(u, n) for (auto [v, used] : to[u]) if (used) { s[v] += a[u]; } for (auto [t, x, y] : qs) { if (t == 1) { if (pair(deg[x], x) >= pair(deg[y], y)) swap(x, y); bool& used = ranges::lower_bound(to[x], y, {}, &pair::first)->second; if (used) s[y] -= a[x]; else s[y] += a[x]; used ^= 1; } else if (t == 2) { int diff = y - a[x]; a[x] = y; for (auto [v, used] : to[x]) if (used) s[v] += diff; } else { ll ans = s[x]; for (auto [v, used] : to[x]) if (used) ans += a[v]; cout << ans << '\n'; } } }