#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
constexpr int INF = 1e9, MOD = 1e9 + 7;
constexpr int64_t LINF = 5e18, LMOD = 998244353;
// #include <atcoder/all>
// using namespace atcoder;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

// BEGIN CUT HERE
/**
 * @brief セグメント木
 * @tparam S 要素モノイド
 */
template<class S>
struct SegmentTree {
public:
	/**
	 * @brief 単位元で初期化
	 * @param N サイズ
	 * @param F 二項演算 (S, S) -> S 
 	 * @param e 要素モノイドの単位元
	 */
	SegmentTree(const size_t N, const function<S(S, S)>& F, const S& e) : SegmentTree(vector<S>(N, e), F, e) {}
	/**
	 * @brief 与配列で初期化
	 * @param v 配列
	 * @param F 二項演算 (S, S) -> S 
 	 * @param e 要素モノイドの単位元
	 */
	SegmentTree(const vector<S>& v, const function<S(S, S)>& F, const S& e) : F(F), e(e) {
		N = 1 << pow2(v.size());
		val = vector<S>(N << 1, e);
		for(size_t i = 0; i < v.size(); ++i) {
			val[N + i] = v[i];
		}
		for(size_t i = N - 1; i >= 1; --i) {
			update(i);
		}
	}
	/**
	 * @brief 1点更新
	 */
	void set(size_t idx, const S& _val) {
		assert(idx < N);
		idx += N;
		val[idx] = _val;
		while(idx > 1) {
			idx >>= 1;
			update(idx);
		}
	}
	/**
	 * @brief 区間取得[l, r)
	 */
	S get(size_t l, size_t r) {
		assert(l < r and r <= N);
		S valL = e;
		S valR = e;
		for(l += N, r += N; l < r; l >>= 1, r >>= 1) {
			if(l & 1) {
				valL = F(valL, val[l++]);
			}
			if(r & 1) {
				valR = F(val[--r], valR);
			}
		}
		return F(valL, valR);
	}
	/**
	 * @brief 1点取得
	 */
	S get(const size_t idx) {
		assert(idx < N);
		return val[N + idx];
	}
	/**
	 * @brief 1点取得
	 */
	S operator[](const size_t idx) {
		assert(idx < N);
		return val[N + idx];
	}
private:
	const function<S(S, S)> F;
	const S e;
	size_t N;
	vector<S> val;
	/**
	 * @return n <= 2^k なる最小の k
	 */
	size_t pow2(const size_t n) {
		size_t k = 0;
		while((1 << k) < n) {
			++k;
		}
		return k;
	}
	/**
	 * @brief v[idx]の更新
	 */
	void update(size_t idx) {
		val[idx] = F(val[idx << 1], val[(idx << 1) | 1]);
	}
};
// END CUT HERE

int main() {
	int n, m, q; cin >> n >> m >> q;
	vector<tuple<int, int, int>> query;
	vector<int> val;
	rep(i,q) {
		int t, x, y; cin >> t >> x >> y;
		query.emplace_back(t, x - 1, y);
		val.emplace_back(y);
	}
	val.emplace_back(0);
	sort(val.begin(), val.end());
	val.erase(unique(val.begin(), val.end()), val.end());
	int vn = val.size();
	SegmentTree<int64_t> seg_a(vn, [](int64_t l, int64_t r) {
		return l + r;
	}, 0);
	SegmentTree<int64_t> seg_b(vn, [](int64_t l, int64_t r) {
		return l + r;
	}, 0);
	SegmentTree<int64_t> seg_a_cnt(vn, [](int64_t l, int64_t r) {
		return l + r;
	}, 0);
	SegmentTree<int64_t> seg_b_cnt(vn, [](int64_t l, int64_t r) {
		return l + r;
	}, 0);
	int64_t ans = 0;
	int a[n] = {};
	int b[m] = {};
	seg_a_cnt.set(0, n);
	seg_b_cnt.set(0, m);
	for(auto [t, x, y] : query) {
		if(t == 1) {
			ans -= seg_b.get(a[x], vn);
			if(0 < a[x]) ans -= seg_b_cnt.get(0, a[x]) * val[a[x]];

			seg_a.set(a[x], seg_a[a[x]] - val[a[x]]);
			seg_a_cnt.set(a[x], seg_a_cnt[a[x]] - 1);
			a[x] = lower_bound(val.begin(), val.end(), y) - val.begin();
			seg_a.set(a[x], seg_a[a[x]] + val[a[x]]);
			seg_a_cnt.set(a[x], seg_a_cnt[a[x]] + 1);

			ans += seg_b.get(a[x], vn);
			if(0 < a[x]) ans += seg_b_cnt.get(0, a[x]) * val[a[x]];
		} else {
			ans -= seg_a.get(b[x], vn);
			if(0 < b[x]) ans -= seg_a_cnt.get(0, b[x]) * val[b[x]];

			seg_b.set(b[x], seg_b[b[x]] - val[b[x]]);
			seg_b_cnt.set(b[x], seg_b_cnt[b[x]] - 1);
			b[x] = lower_bound(val.begin(), val.end(), y) - val.begin();
			seg_b.set(b[x], seg_b[b[x]] + val[b[x]]);
			seg_b_cnt.set(b[x], seg_b_cnt[b[x]] + 1);

			ans += seg_a.get(b[x], vn);
			if(0 < b[x]) ans += seg_a_cnt.get(0, b[x]) * val[b[x]];
		}
		cout << ans << '\n';
	}
	return 0;
}

#include<bits/stdc++.h>

typedef   long long  int ll;
typedef  long double ld;
typedef std::vector<ll> vi;
typedef std::vector<std::vector<ll> > vv;
typedef std::vector<std::pair<ll,ll> > pii;

#define mod 1000000007
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,b) for(i=a;i<b;i++)
#define forr(i,a,b) for(i=a;i>=b;i--)
#define mp make_pair
#define pb(x) push_back(x)
#define fi first
#define se second
#define print(vec,a,b) for(ll i=a;i<b;i++) cout<<vec[i]<<" ";cout<<endl;
#define all(a) a.begin(),a.end()
#define input(vec,a,b) for(ll i = a;i<b;i++) cin>>vec[i];
#define ms(a,val) memset(a,val,sizeof(a))
using namespace std;

const int N = 2e5+ 5;



ll expo_pow(ll x, ll y) {
	if (y == 0)
		return 1;
	y = y % (mod - 1);
	x %= mod;
	if (y == 0)
		y = mod - 1;
	ll res = 1;
	while (y) {
		if (y & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		y >>= 1;
	}
	return res;
}
 
ll modInverse(ll a, ll m = mod) {
	return expo_pow(a, m - 2);
}
	

using matrix = vector<vector<ll>>;
 
matrix matMul(matrix A, matrix B) {
	//assert((int)A[0].size() == (int)B.size());
	matrix res((ll)A.size(), vector<ll>((ll)B[0].size(), 0));
	for (int i = 0; i < (int)A.size(); ++i) {
		for (int j = 0; j < (int)B[0].size(); ++j) {
			for (int k = 0; k < (int)A[0].size(); ++k) {
				res[i][j] += (A[i][k] * B[k][j]) % mod;
				res[i][j] %= mod;
			}
		}
	}
	return res;
}
 
matrix matPow(matrix M, int p) {
	if (p == 1) return M;
	if (p % 2) return matMul(M, matPow(M, p - 1));
	matrix X = matPow(M, p / 2);
	return matMul(X, X);
}

void solve(){
            ll i,j,n,m,k;
            cin>>n>>m>>k;
            
            vv a(1,vi(n,0));
            input(a[0],0,n);
            vv adj(n,vector<ll>(n,0));
            
            vi deg(n,0);
            fo(i,0,m)
            {
				ll x,y;
				cin>>x>>y;
				x--,y--;
				adj[x][y] = 1;
				adj[y][x] = 1;
				deg[x]++;
				deg[y]++;
			}
			
			ll inv = modInverse(2*m,mod);
			
			vv M(n,vi(n,0));
			
			
			
			if(k == 0)
			{
				print(a[0],0,n);
				return ;
			}
			fo(i,0,n)
			{
				fo(j,0,n)
				{
					if(i == j)
					{
						M[i][j] = (1 - (deg[i]*inv)%mod + mod)%mod;
					}
					else
					{
						M[i][j] = inv*adj[i][j];
					}
				}
			}
			M = matPow(M, k);
			a = matMul(a,M);
			fo(i,0,n)
			{
				cout<<a[0][i]<<endl;
			}
}



int main()
{
     IO;
      ll t=1,i;
      //cin>>t;

		
      while(t--)
      {

          solve();
      }
    return 0;
}
