这题纯暴力竟然能过……
//minamoto
#include<cstdio>
#include<iostream>
#define mul(a,b) (1ll*a*b%P)
using namespace std;
#define getc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
char buf[<<],*p1=buf,*p2=buf;
int read(){
#define num ch-'0'
char ch;bool flag=;int res;
while(!isdigit(ch=getc()))
(ch=='-')&&(flag=true);
for(res=num;isdigit(ch=getc());res=res*+num);
(flag)&&(res=-res);
#undef num
return res;
}
char sr[<<],z[];int C=-,Z;
inline void Ot(){fwrite(sr,,C+,stdout),C=-;}
void print(int x){
if(C><<)Ot();if(x<)sr[++C]=,x=-x;
while(z[++Z]=x%+,x/=);
while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
const int N=2e5+,P=1e9+;
int n,m,a[N],b[N],c[N],ans=;
int ksm(int a,int b){
int res=;
while(b){
if(b&) res=mul(res,a);
a=mul(a,a),b>>=;
}
return res;
}
int main(){
// freopen("testdata.in","r",stdin);
n=read(),m=read();
for(int i=;i<=n;++i)
a[i]=read(),c[i]=max(c[i-],a[i]);
for(int i=;i<=n;++i)
b[i]=read(),ans=mul(min(b[i],c[i]),ans);
while(m--){
int op=read(),x=read(),y=read();
if(op==){
if(b[x]<c[x]){
ans=mul(ans,ksm(b[x],P-));
ans=mul(ans,min(y,c[x]));
}
b[x]=y;
}else{
a[x]=y;
while(c[x]<y&&x<=n){
if(c[x]<b[x]){
ans=mul(ans,ksm(c[x],P-));
ans=mul(ans,min(y,b[x]));
}c[x++]=y;
}
}
print(ans);
}
return Ot(),;
}