#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
template<class V> struct BIT {
    BIT() {}  // [L, R)
    int NV;vector<V> bit;
    BIT(int n){ init(n); }
    void init(int n) { NV = 1; while (NV < n)NV *= 2; bit.resize(NV); clear(); }
    V operator[](int e) { V s = 0; e++; while (e) s += bit[e - 1], e -= e&-e; return s; }
    void add(int e, V v) { e++; while (e <= NV) bit[e - 1] += v, e += e&-e; }
    int lower_bound(V val) { 
        V tv = 0; int i, ent = 0; for (i = NV - 1; i >= 0; i--)
        if(tv+bit[ent+(1<<i)-1]<=val)tv+=bit[ent+(1<<i)-1],ent += (1 << i);return ent;
    }
    V get(int L, int R) {
        assert(0 <= L); assert(R <= NV); assert(L <= R);
        V res = 0; if(R) res += operator[](R - 1); if (L) res -= operator[](L - 1);return res;
    }
    void clear() { rep(i, 0, NV) bit[i] = 0; }
	void update(int e, V v) { add(e, v - get(e, e + 1)); }
};
vector<int> compress1(int *v, int n) {
    vector<int> dic;
    rep(i, 0, n) dic.push_back(v[i]);
    sort(all(dic));
    dic.erase(unique(all(dic)), dic.end());
    rep(i, 0, n) v[i] = lower_bound(all(dic), v[i]) - dic.begin();
    return dic;
}
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, M, Q, T[201010], X[201010], Y[201010];
int A[201010], B[201010];
BIT<ll> Acnt(201010), Bcnt(201010);
BIT<ll> Atot(201010), Btot(201010);
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M >> Q;
    rep(i, 0, Q) cin >> T[i] >> X[i] >> Y[i];

    auto ZY = compress1(Y, Q + 1);
    Acnt.add(0, N);
    Bcnt.add(0, M);

    ll ans = 0;
    rep(q, 0, Q) {
        if (T[q] == 1) {
            int x = X[q] - 1;
            int y = Y[q];
            ans -= Bcnt.get(0, A[x] + 1) * ZY[A[x]];
            ans -= Btot.get(A[x] + 1, 201010);

            Acnt.add(A[x], -1);
            Atot.add(A[x], -ZY[A[x]]);

            A[x] = y;

            ans += Bcnt.get(0, A[x] + 1) * ZY[A[x]];
            ans += Btot.get(A[x] + 1, 201010);

            Acnt.add(A[x], 1);
            Atot.add(A[x], ZY[A[x]]);
        }
        else {

            int x = X[q] - 1;
            int y = Y[q];
            ans -= Acnt.get(0, B[x] + 1) * ZY[B[x]];
            ans -= Atot.get(B[x] + 1, 201010);

            Bcnt.add(B[x], -1);
            Btot.add(B[x], -ZY[B[x]]);

            B[x] = y;

            ans += Acnt.get(0, B[x] + 1) * ZY[B[x]];
            ans += Atot.get(B[x] + 1, 201010);

            Bcnt.add(B[x], 1);
            Btot.add(B[x], ZY[B[x]]);
        }
        printf("%lld\n", ans);
    }
}






#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll A[51];
ll X;
ll ret;
map<ll,ll> memo[55];

ll dfs(int cur,ll lef) {
	if(cur==N-1) {
		return 1;
	}
	
	if(memo[cur].count(lef)) return memo[cur][lef];
	ll ret=0;
	
	ll step=A[cur+1]/A[cur];
	ll a=lef%step;
	
	if(a==0) {
		ret+=dfs(cur+1,lef/step);
	}
	else {
		ret+=dfs(cur+1,lef/step);
		ret+=dfs(cur+1,lef/step+1);
	}
	return memo[cur][lef]=ret;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>X;
	FOR(i,N) cin>>A[i];
	
	cout<<dfs(0,X)<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
