#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define AC "test"
#define foru(i, l, r) for (int i = (l); i <= (r); i++)
#define ford(i, l, r) for (int i = (l); i >= (r); i--)
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vii;
typedef vector<ll> vll;
const ll inf = 1e9 + 7;
const ll linf = 1e18 + 7;
const int mod = 1e4 + 7;
const int maxn = 1e5 + 1;
const int base = 31;
void fastIO(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
}
ll mul(ll a, ll b){
return ((a % mod) * (b % mod)) % mod;
}
ll Pow(ll a, ll b){
ll ans = 1;
while (b){
if (b % 2) ans = mul(ans, a);
a = mul(a, a);
b/=2;
}
return ans;
}
struct node{
int al, li[20];
};
node st[4 * maxn];
int n, q, c, a[maxn], b[maxn], x, y, clsf, sum;
void update(int id, int l, int r, int pos, int nx, int ny){
if (l > pos || r < pos) return;
if (l == r){
st[id].li[0] = ny % mod;
st[id].li[1] = nx % mod;
st[id].al = (nx + ny) % mod;
return;
}
int m = (l + r) >> 1;
update(id * 2, l, m, pos, nx, ny);
update(id * 2 + 1, m + 1, r, pos, nx, ny);
st[id].al = mul(st[id*2].al, st[id*2+1].al);
ford(i, c - 1, 0){
st[id].li[i] = 0;
foru(j, 0, i){
st[id].li[i] = (st[id].li[i] + mul(st[id * 2].li[j], st[id * 2 + 1].li[i - j])) % mod;
}
}
}
void solve(){
cin >> n >> c;
foru(i, 1, n){
cin >> a[i];
}
foru(i, 1, n){
cin >> b[i];
}
cin >> q;
foru(i, 1, n){
update(1, 1, n, i, a[i] % mod, b[i] % mod);
}
while (q--){
cin >> clsf >> x >> y;
update(1, 1, n, clsf, x % mod, y % mod);
sum = 0;
foru(i, 0, c - 1){
sum = (sum + st[1].li[i]) % mod;
}
cout << (st[1].al - sum + 3 * mod) % mod << "\n";
}
}
int main(){
fastIO();
if (fopen(AC".inp", "r")){
freopen(AC".inp", "r", stdin);
freopen(AC".out", "w", stdout);
}
solve();
}