#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//#define int ll
using P = pair<int, int>;
#define all(x) x.begin(), x.end()
#define rep(i, l, n) for (int i = l; i < (n); ++i)
#define sz(x) (int)x.size()
const char nl = '\n';
const ll mod = 1e9+7;
//const ll inf = 1e9+1;
int n;
vector<int> x, y;
vector<ll> p;
int init(int N, int X[], int Y[]) {
n = N;
rep(i, 0, n)
x.push_back(X[i]),
y.push_back(Y[i]);
p.resize(n);
rep(i, 0, n) {
p[i] = x[i];
if (i)p[i] = p[i-1]*p[i]%mod;
}
ll res = 0, yp = Y[0], pr = 1;
rep(i, 1, n) {
pr = min(mod, pr*x[i]);
if (pr*y[i] > yp) {
res = i, yp = y[i];
pr = 1;
}
}
ll ans = 1;
rep(i, 0, res+1)
ans = ans*x[i]%mod;
return ans*y[res]%mod;
}
int updateX(int pos, int val) {
x[pos] = val;
ll res = 0, yp = 0, pr = 1;
rep(i, max(n-30, 0), n) {
pr = min(mod, pr*x[i]);
if (pr*y[i] > yp) {
res = i, yp = y[i];
pr = 1;
}
}
ll ans = p[res];
return ans*y[res]%mod;
}
int updateY(int pos, int val) {
y[pos] = val;
ll res = 0, yp = 0, pr = 1;
rep(i, max(n-30, 0), n) {
pr = min(mod, pr*x[i]);
if (pr*y[i] > yp) {
res = i, yp = y[i];
pr = 1;
}
}
ll ans = p[res];
return ans*y[res]%mod;
}