#include using namespace std; using ll=long long; int main() { ll N,M,Q,C,K,D,S=0; cin>>N>>M; vector A(M); for(ll i=0;i>A[i]; S+=A[i]*A[i]; } cin>>Q; for(ll q=0;q>C>>K>>D; C--;D--; S-=A[C]*A[C]+A[D]*A[D]; A[C]-=K; A[D]+=K; S+=A[C]*A[C]+A[D]*A[D]; cout<