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

void readFile(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int main(){
    readFile();
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    float v, t, s, d;
    cin >> v >> t >> s >> d;
    float time = d / v;
    // cout << time << '\n';
    if(!(time >= t && time <= s)) {
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}

// speed = distance / time

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x, y, a, b; cin >> x >> y >> a >> b;
  ll tmp = 0;
  ll ans = 0;
  while(x < y) {
    chmax(ans, (y-x-1)/b+tmp);
    if(y/x < a) break;
    x *= a;
    tmp++;
  }
  cout << ans << endk;
  return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    using ll = long long;
    ll n, t, ans = 0;
    cin >> n >> t;
    vector<ll> a(n);
    for (auto&& i : a) cin >> i;
    set<ll> s1, s2;
    s1.insert(0), s2.insert(0);
    for (int i = 0; i < n / 2; ++i) for (const auto& sum : s1) if (sum - a.at(i) >= -t) s1.insert(sum - a.at(i));
    for (int i = n / 2; i < n; ++i) for (const auto& sum : s2) if (sum - a.at(i) >= -t) s2.insert(sum - a.at(i));
    for (const auto& sum : s1) ans = min(ans, sum + *s2.lower_bound(-t - sum));
    cout << -ans << '\n';
    return 0;
}

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<random>
#include<iomanip>
#include<queue>
#include<stack>
#include<assert.h>
#include<time.h>
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
//combination(Nが小さい時はこれを使う
const int MAX = 2330000;
int fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight(int n) {
	int ans = 1;
	while (n >= 10) {
		n /= 10;
		ans++;
	}
	return ans;
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int n, t;
int a[44];
int memo1[1050000], memo2[1050000];
signed main() {
	cin >> n >> t;
	rep(i, n)cin >> a[i];
	rep(i, 1 << (n / 2)) {
		int cnt = 0;
		rep(j, n / 2) {
			if ((i >> j) & 1)cnt += a[j];
		}
		memo1[i] = cnt;
	}
	rep(i, 1 << (n - n / 2)) {
		int cnt = 0;
		rep(j, n - n / 2) {
			if ((i >> j) & 1)cnt += a[j + n / 2];
		}
		memo2[i] = cnt;
	}
	sort(memo1, memo1 + (1 << (n / 2)));
	sort(memo2, memo2 + (1 << (n - n / 2)));
	int ans = 0;
	rep(i, 1 << (n / 2)) {
		int p = upper_bound(memo2, memo2 + (1 << (n - n / 2)), t - memo1[i]) - memo2;
		if (p == 0)ans = ans;
		else ans = max(ans, memo1[i] + memo2[p - 1]);
	}
	cout << ans << endl;
	ggr
}


#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    double n;
    cin >> n;
    double ans = 0;
    for (int i = 1; i <= n - 1; i++)
    {
        ans += (n / (n - i));
    }
    cout << std::fixed << std::setprecision(15) << ans << endl;
}

using namespace std;
#include<string>
#include<cmath>
#include<list>
#include <map>
#include <unordered_map>
#include <set>
#define ll long long
#define ld long double
#define ull unsigned long long
#define ml map<ll,ll>
#define pb push_back
#define mp make_pair
#define ppl pair<ll,ll>
#define F first
#define S second
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

#define fr(i,a,b) for(ll i=a;i<b;i++)
#define ffr(i,a,b) for(ll i=a;i>=b;i--)
#include<bits/stdc++.h>
#include<vector>
#define vl vector<ll>
#define PI 3.141592654
const ll N = 1e9 + 7;
#include<iterator>
#define EPSILON numeric_limits<double>::epsilon()

// vector<vl> v;
// vector<bool> visited;

// void dfs(ll pnt, ll &edge, ll &pt) {
// 	visited[pnt] = 1;
// 	pt++;
// 	fr(i, 0, v[pnt].size()) {
// 		edge++;
// 		if (!visited[pnt])dfs(v[pnt][i], edge, pt);
// 	}
// }

int gcd(int a, int b) {
	if (a == b)return a;
	if (a % b == 0)return b;
	if (b % a == 0)return a;
	if (b > a)return gcd(a, b % a);
	if (a > b)return gcd(a % b, b);
	return 0;
}

void solve() {
	ll n; cin >> n;
	ll b = log2(n) / log2(5);
	b++;
	fr(i, 1, b) {
		ll f = 1, q = 1;
		fr(j, 0, i)f *= 5;
		if (f < n) {
			f = n - f;
			ll g = log2(f) / log2(3);
			fr(l, 0, g)q *= 3;
			if (q == f && g > 0) {cout << g << " " << i; return;}
		}
	}
	cout << -1;
}

int main() {
	fio;
#ifndef ONLINE_JUDGE
	// for getting input
	freopen("input.txt", "r", stdin);//298023223876953125
	//for writing output
	freopen("jout.txt", "w", stdout);
#endif
	//prime();
	ll t;
	if (1)
		t = 1;
	else
		cin >> t;
	while (t--) {
		//cout << "Case #" << h << ": ";
		solve();
		//h++;
		cout << '\n';
	}
	return 0;
}


#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
using namespace std;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#ifdef LOCAL
void debug_out() { cerr << endl; }
template <class Head, class... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }
#define debug(...) cerr << 'L' << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << 'L' << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
template<class T> using V = vector<T>;
template<class T> using P = pair<T, T>;
using ll = long long;
using ld = long double;
using Vi = V<int>;  using VVi = V<Vi>;
using Vl = V<ll>;   using VVl = V<Vl>;
using Vd = V<ld>;   using VVd = V<Vd>;
using Vb = V<bool>; using VVb = V<Vb>;
using Pi = P<int>;
using Pl = P<ll>;
using Pd = P<ld>;
template<class T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
template<class T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<class T> inline int sz(const T &x) { return size(x); }
template<class T> inline bool chmin(T &a, const T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, const T b) { if (a < b) { a = b; return true; } return false; }
template<class T1, class T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<class T, size_t n> istream &operator>>(istream &is, array<T, n> &v) { for (auto &e : v) is >> e; return is; }
template<class T, size_t n> ostream &operator<<(ostream &os, const  array<T, n> &v) { for (auto &e : v) os << e << ' '; return os; }
template<class T> inline void deduplicate(vector<T> &a) { sort(all(a)); a.erase(unique(all(a)), a.end()); }
template<class T> inline int count_between(const vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline ll cDiv(const ll x, const ll y) { return (x+y-1) / y; } // ceil(x/y)
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); } // floor(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); } // ceil(log2(x))
inline int popcount(const ll x) { return __builtin_popcountll(x); }
inline void fail() { cout << -1 << '\n'; exit(0); }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
// const int INF  = (1<<30) - 1;
// const ll INFll = (1ll<<60) - 1;
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);

bool solve(){
  int n; cin >> n;
  Vi a(n); cin >> a;
  if (n % 2 == 1) return false;

  map<int, int> cnt;
  rep(i, n) cnt[a[i]] ^= 1;

  for (auto [x, y] : cnt) if (y) return true;

  return false;
}

int main() {
  int t; cin >> t;
  rep(i, t) cout << (solve() ? "First" : "Second") << '\n';
}

#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
// string __fname = "";
// ifstream in (__fname + ".in");
// ofstream out (__fname + ".out");
// #define cin in
// #define cout out
#define pii pair <int, int>
#define pii64 pair <int64, int64>
#define ss cout << " ";
#define nn cout << "\n";
#define ct(x) cout << x;
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define qr queries();
void solve(int);
void queries(){int n;cin >> n;for (int i = 1; i <= n; i++) solve(i);}
int64 ceildiv(int64 a, int64 b) {return a / b + !!(a % b);}
template<class T>T gcd (T a, T b){return (b ? gcd(b, a % b): a);}
template<class T>T lcm (T a, T b){return a * b / gcd(a, b);}
// // // // // // // // // // // // // // // // // // // // // //
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
const int maxn = 200200;
const int64 mod = 1000000007;
const double pi = 3.14159265359;
const int ddx[] = {-1, -1, 0, 1, 1, 1, 0, -1};
const int ddy[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

void solve(int id){
    vec a (3);
    for (int i = 0; i < 3; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    ctn(a[2] + a[1]);
    return;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    solve(0);
    return 0;
}


#include <vector>
#include <iostream>

#define int         long long
#define double      long double
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

signed main() {
    tezz

    vector<int> primes;
    for (int i = 2; i < 72; i++) {
        bool flag = true;
        for (int j = 2; j < i; j++) {
            if (i % j == 0) flag = false;
        }
        if (flag) primes.emplace_back(i);
    }

    int A, B;
    cin >> A >> B;
    vector<int> v(B - A + 1);
    for (int i = A; i <= B; i++) {
        int mask = 0;
        for (int j = 0; j < primes.size(); j++) {
            if (i % primes[j] == 0) {
                mask |= (1 << j);
            }
        }
        v[i - A] = mask;
    }

    vector<int> dp(1<<primes.size());
    dp[0] = 1;
    for (int x: v) {
        for (int mask = 0; mask < (1 << primes.size()); mask++) {
            if (dp[mask]) {
                int tmp = mask & x;
                if (tmp == 0) dp[mask | x] += dp[mask];
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < (1 << primes.size()); i++) ans += dp[i];
    cout << ans;
}

#include<cstdio>
#define N 300001
using namespace std;
long long m2[N],m3[N],m5[N],m7[N],go[N],used[N];
long long s[101][101];
long long n,m,ans=0;
long long gcd(long long x,long long y)
{
	if (x==1||y==1) return 1;
	return s[x-n+1][y-n+1];
}
long long gcd1(long long x,long long y)
{
	if (y==0) return x;
	return gcd1(y,x%y);
}
void dfs(int k)
{
	if (k>used[0])
	{
		ans++;
		return;
	}//ans++;
	dfs(k+1);
	bool bo=true;
	for (int i=1;i<=go[0];i++)
		if (gcd(go[i],used[k])!=1)
		{
			bo=false;break;
		}
	if (bo)
	{
		go[++go[0]]=used[k];
		dfs(k+1);
		go[0]--;
	}
}
int main()
{
	scanf("%lld%lld\n",&n,&m);
	m2[0]=1;m3[0]=1;m5[0]=1;m7[0]=1;
	m2[1]=1;m3[1]=1;m5[1]=1;m7[1]=1;
	for (long long i=n;i<=m;i++)
		for (long long j=n;j<=m;j++)
			s[i-n+1][j-n+1]=gcd1(i,j);
	long long pans=1;
	for (long long i=n;i<=m;i++)
	{
		if (i%2==0)
			m2[++m2[0]]=i;
		else
			if (i%3==0) m3[++m3[0]]=i;
			else if (i%5==0) m5[++m5[0]]=i;
			else if (i%7==0) m7[++m7[0]]=i;
			else
			{
				bool bo=true;
				for (long long j=n;j<=m;j++)
				{
					if (i==j) continue;
					if (s[i-n+1][j-n+1]!=1)
					{
						bo=false;break;
					}
				}
				if (!bo||(i*2<=m))
					used[++used[0]]=i;
				else	pans*=2;
			}
	}
	ans=0;
	for (int i=1;i<=m2[0];i++)
	{
		for (int j=1;j<=m3[0];j++)
		{
			if (gcd(m2[i],m3[j])!=1) continue;
			for (int k=1;k<=m5[0];k++)
			{
				if (gcd(m2[i],m5[k])!=1) continue;
				if (gcd(m3[j],m5[k])!=1) continue;
				for (int p=1;p<=m7[0];p++)
				{
					if (gcd(m2[i],m7[p])!=1) continue;
					if (gcd(m3[j],m7[p])!=1) continue;
					if (gcd(m5[k],m7[p])!=1) continue;
					go[0]=4;
					go[1]=m2[i];go[2]=m3[j];go[3]=m5[k];go[4]=m7[p];
					dfs(1);
				//	printf("%d %d %d %d\n",m2[i],m3[j],m5[k],m7[p]);
				//	printf("%lld\n",ans);
				}
			}
		}
	}
	printf("%lld\n",ans*pans);
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a.at(i);

    vector<ll> counter(200, 0);
    rep(i, n)
    {
        counter.at(a.at(i) % 200)++;
    }

    ll ans = 0;
    rep(i, counter.size())
    {
        ll cnt = counter.at(i);
        ans += cnt * (cnt - 1) / 2;
    }

    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0; i<(n); ++i)
#define fixed_setprecision(n) fixed << setprecision((n))
#define execution_time(ti) printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
#define pai 3.1415926535897932384
#define NUM_MAX 2e18
#define NUM_MIN -1e9

using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }

void solve(ll N, map<int, int> m){
    ll res=0;
    for(int i=0; i<200; i++){
        for(int j=i; j<200; j++){
            if(m[i]==0 || m[j]==0) continue;
            if((j-i)%200==0){
                if(i==j){
                    rep(k, m[i]){
                        res += (m[i]-k-1);
                    }
                }
            }
        }
    }
    cout << res << endl;
}

int main() {
    ll N;
    cin >> N;
    //N = 200000;

    //vector<ll> A(N);
    map<int, int> m;
    rep(i, N){
        ll t;
        cin >> t;
        m[t%200]++;
    }
    //rep(i, N) cin >> A[i];
    //rep(i, N) A[i]=400;

    solve(N, m);

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define np next_permutation
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define vii vector<vi>
#define vb vector<bool>
#define pr pair<int,int>
#define vl vector<ll>
#define vs vector<string>
#define us unordered_map<int,int>
#define Mpq priority_queue<int>
#define mpq priority_queue<int,vi,greater<int>>
#define eb emplace_back
#define pr pair<int,int>
#define prl pair<ll,ll>
#define vp vector<pr>
#define vpl vector<prl>
#define mkp make_pair
#define ld long double
#define vii vector<vi>
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
#define ull unsigned long long
#define prr pair<ll,int>

// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>

// using namespace __gnu_pbds;
using namespace std;
using vi=vector<int>;

// typedef  tree<prl, null_type,less<prl>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// ordered_set s;

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
template<class T> using pqg = priority_queue<T,vector<T>,greater<T>>;

double epsilon=(double)1e-9;
const int N=(int)1e6+12;
int t;

const ll MX=(ll)1e18+123;
const int inf=0x3fffffff;

vi g[21];
vi par,color;
vb vis;

void dfs(int u){
   vis[u]=1;
   par.eb(u);
   for(auto &v:g[u]){
      if(!vis[v]) dfs(v);
   }
}

ll cal(int i){
   if(i==(int)par.size()){
      return 1;
   }
   int u=par[i];
   ll ans=0;
   lp(c,3){
      color[u]=c;
      bool valid=1;
      for(int v:g[u]){
         if(color[u]==color[v]){
            valid=0;
            break;
         }
      }
      if(valid) ans+=cal(i+1);
      color[u]=-1;
   }
   return ans;
}

void solve(){
   int n,m,u,v;
   ll ans=1;
   cin>>n>>m;
   vis.resize(n);
   color.resize(n,-1);

   lp(i,m){
      cin>>u>>v;
      u--,v--;
      g[u].eb(v);
      g[v].eb(u);
   }

   lp(i,n){
      if(vis[i]) continue;
      par.resize(0);
      dfs(i);
      color[i]=0;
      ans*=3*cal(1);
      // color[i]=-1;
   }
   cout<<ans<<"\n";
}

int main(){
   ios_base::sync_with_stdio(0);
   cin.tie(nullptr);

   solve();
   return 0;
}

#include <bits/stdc++.h>
#define ll long long
#define ls (v << 1)
#define rs ((v << 1)|1)
#define ll long long
#define free fajeiof
#define right fjewiofjaewoi
#define move afjoiejwioaf
int gcd(int a, int b){
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
using namespace std;

const int nmax = 300001;
const int inf = 1e9 + 7;
const int mod = 998244353;

int tt, timer;
int n, m, color[nmax], cur, x, y;
bool used[nmax];
vector<int> g[nmax], comp;

void dfs1(int v){
    comp.push_back(v);
    used[v] = true;
    for (int to: g[v]){
        if (!used[to])
            dfs1(to);
    }
}

bool check(int v, int col){
    for (int to : g[v]){
        if (color[to] == col)
            return false;
    }
    return true;
}

void dfs2(int idx){

    //cout << idx << " vert: " << endl;
    if (idx == comp.size()){
        cur++;
        return;
    }
    int v = comp[idx];
    for (int c = 1; c <= 3; c++){
        if (!check(v, c))
            continue;
        color[v] = c;
        dfs2(idx + 1);
    }
    color[v] = -1;
}

void solve(){
    cin >> n >> m;
    while (m--){
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    ll ans = 1;
    for (int i = 1; i <= n; i++){
        if (!used[i]){
            comp.clear();
            dfs1(i);
            cur = 0;
            dfs2(0);
            ans *= cur;
        }
    }
    cout << ans << endl;
}

int main()
{
	srand(time(0));
	std::ios::sync_with_stdio(false);

    //cin >> tt;
    tt = 1;
	while (tt--){
	    solve();
	}

	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll x, y; cin >> x >> y;
	if (x == y) cout << x << "\n";
	else cout << 3 - x - y << "\n";
}

#include <iostream>

using namespace std;

int a, b, ans;

int main() {
  cin >> a >> b;
  for (int i = 1; i <= 2e5; i++) {
    if (b / i - (a - 1) / i > 1) {
      ans = i;
    }
  }
  cout << ans;
  return 0;
}


#include<bits/stdc++.h>

 #define f first
 #define s second
 #define pb push_back

using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

ll n;
ll m;
vector<ll> a;
vector<ll> b;
ll memo [2000][2000];

ll lcs (ll x, ll y)
{

    if(x==n){return m-y;}
    if(y==m){return n-x;}
    if(memo[x][y]!=-1){return memo[x][y];}
    if(a[x]==b[y]){return memo[x][y]=lcs(x+1,y+1);}

    return memo[x][y]=min(1+lcs(x+1,y+1),min(1+lcs(x+1,y),1+lcs(x,y+1)));
}

int main ()
{
    ios::sync_with_stdio(0);
cin.tie(0);

cin>>n>>m;
for(int i=0;i<n;i++)
{
    ll c;
    cin>>c;
    a.pb(c);
}
for(int i=0;i<m;i++)
{
    ll c;
    cin>>c;
    b.pb(c);
}
memset(memo,-1,sizeof(memo));
cout<<lcs(0,0)<<endl;
return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define V vector
#define debug(v) for(auto i: v) cout << i << " "; cout << endl;
#define vcin(v) rep(i, v.size()) cin >> v[i]
#define wcin(v, w) rep(i, v.size()) cin >>v[i] >>w[i]
#define r0 return 0;

int main(){
    ll n,m;
    cin >>n >>m;
    V<ll> a(n),b(m);
    vcin(a);
    vcin(b);

    unordered_set<ll> num;
    for(ll i:a)num.insert(i);
    for(ll i:b)num.insert(i);
    unordered_set<ll> numa=num;
    unordered_set<ll> numb=num;
    for(ll i:a)numa.erase(i);
    for(ll i:b)numb.erase(i);
    V<ll> ans;
    for(ll i:numa)ans.push_back(i);
    for(ll i:numb)ans.push_back(i);
    sort(all(ans));
    for(ll i:ans)cout <<i <<" ";
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<math.h>
#include<unordered_set>
#include<unordered_map>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rrep(i,l,r) for(int i=l;i<=r;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
#define unq(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define mod 1000000007
//#define mod 998244353
#define ad(a,b) a=(a+b)%mod;
#define mul(a,b) a=a*b%mod;
void readv(vector<ll> &a,ll n){
	rep(i,n){
		ll x;
		cin>>x;
		a.push_back(x);
	}
}
void outv(vector<ll> &a,ll n){
	rep(i,n){
		if(i>0)cout<<" ";
		cout<<a[i];
	}
	cout<<"\n";
}
ll po(ll x,ll y){
	ll res=1;
	for(;y;y>>=1){
		if(y&1)res=res*x%mod;
		x=x*x%mod;
	}
	return res;
}
ll gcd(ll a,ll b){
	return (b?gcd(b,a%b):a);
}
#define FACMAX 200010
ll fac[FACMAX],inv[FACMAX],ivf[FACMAX];
void initfac(){
	fac[0]=ivf[0]=inv[1]=1;
	for(ll i=1;i<FACMAX;i++)fac[i]=fac[i-1]*i%mod;
	for(ll i=1;i<FACMAX;i++){
		if(i>1)inv[i]=(mod-mod/i*inv[mod%i]%mod)%mod;
		ivf[i]=po(fac[i],mod-2);
	}
}
ll P(ll n,ll k){
	if(n<0||n<k)return 0;
	return fac[n]*ivf[n-k]%mod;
}
ll C(ll n,ll k){
	if(k<0||n<k)return 0;
	return fac[n]*ivf[n-k]%mod*ivf[k]%mod;
}
ll H(ll n,ll k){
	return C(n+k-1,k);
}

#define D 100010
bool e[D];
int main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	ll n;
	cin>>n;
	ll ans=n;
	rep(i,D)e[i]=0;
	for(ll i=2;i<D;i++){
		if(e[i])continue;
		for(ll j=i*i;j<=n;j*=i){
			if(j<D)e[j]=1;
			ans--;
		}
	}
	cout<<ans<<endl;
}

#include<bits/stdc++.h>
#define forn(i, n) for(int i=0;i<(int)(n);i++)
#define for1(i, n) for(int i=1;i<=(int)(n);i++)
#define fore(i, l, r) for(int i=(int)(l);i<=(int)(r);i++)
#define ford(i, n) for(int i=(int)(n)-1;i>=0;i--)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define MAX 1000000007
using namespace std;
typedef int64_t ll;
typedef vector<int> vi;
typedef vector<int64_t> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	int n;
	cin>>n;
	if(n%2==0)
		cout<<"White";
	else
		cout<<"Black";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
  int h,w;
  cin >> h >> w;
  vector<int> a(h*w);
  for(int i=0;i<h*w;i++){
    cin >> a.at(i);
  }
  int b;
  b=*min_element(a.begin(),a.end());
  int c;
  c=0;
  for(int i=0;i<h*w;i++){
    c += a.at(i)-b;
  }
  cout << c << endl;
}

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

// string->num
//   stoll(str)
// num->string
//   to_string(i)

int main() {
  ll H, W;
  cin >> H >> W;
  vector<vector<ll>> A(H, vector<ll>(W - 1));
  vector<vector<ll>> B(H - 1, vector<ll>(W));
  for (ll i = 0; i < H; i++) {
    for (ll j = 0; j < W - 1; j++) {
      cin >> A[i][j];
    }
  }
  for (ll i = 0; i < H - 1; i++) {
    for (ll j = 0; j < W; j++) {
      cin >> B[i][j];
    }
  }
  const ll INF = 1e10;
  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<>> q;
  vector<ll> dist(H * W, INF);

  auto push = [&](ll i, ll j, ll cost) {
    ll node = i * W + j;
    if (dist[node] > cost) {
      dist[node] = cost;
      q.emplace(cost, node);
    }
  };
  push(0, 0, 0);
  while (!q.empty()) {
    auto [cost, node] = q.top();
    q.pop();
    if (dist[node] != cost) continue;
    ll i = node / W;
    ll j = node % W;
    if (j + 1 < W) push(i, j + 1, cost + A[i][j]);
    if (j - 1 >= 0) push(i, j - 1, cost + A[i][j - 1]);
    if (i + 1 < H) push(i + 1, j, cost + B[i][j]);
    for (ll k = 0; k < i; k++) {
      push(k, j, cost + (i - k) + 1);
    }
  }
  cout << dist.back() << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define V vector
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define sz(x) int(x.size())
#define pcnt __builtin_popcountll
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
template <typename T> void print(T a) {cout << a << ' ';}
template <typename T> void printe(T a) {cout << a << endl;}
template <typename T> void printv(T a) {rep(i, sz(a))print(a[i]); cout<<endl;}
template <typename T> void printp(pair<T, T> a) {print(a.first); cout<<a.second<<endl;}
template <typename A, size_t N, typename T> void Fill (A (&array)[N], const T & val) {fill ((T*)array, (T*)(array+N), val);}
template <typename T> using vc = vector<T>;
template <typename T> using vv = vc<vc<T>>;
template <typename T> using vvv = vc<vv<T>>;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using vi = vc<int>;
using vvi = vv<int>;
using vl = vc<ll>;
using vvl = vv<ll>;
vi di = {-1, 1,  0, 0, -1, -1,  1, 1};
vi dj = { 0, 0, -1, 1, -1,  1, -1, 1};

int main () {
    int n, D, H; cin >> n >> D >> H;
    double ans = 0;
    rep(i, n) {
        int d, h; cin >> d >> h;
        chmax(ans, (double) (D*h - d*H) / (D - d));
    }
    printf("%.10lf\n", ans);
    return 0;
}

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
using namespace std;

int main(){
  int n,D,H,j;
  cin >> n >> D >> H;
  vector<int> d(n);
  vector<int> h(n);
  for(int i=0;i<n;i++) cin >> d.at(i) >> h.at(i);

  double min;
  vector<double> tan(n);
  for(int i=0;i<n;i++){
    tan.at(i) = (double)(H-h.at(i))/(D-d.at(i));
    if(i==0) min = tan.at(0);
    else if(tan.at(i)<min){
      min = tan.at(i);
      j = i;
    }
  }

  double answer;
  answer = (double)D*tan.at(j);
  if(tan.at(j)>=(double)H/D) cout << 0.00 << endl;

  else cout << H-answer << endl;

}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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; }
const ll MOD = 1e9+7;

long long power(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}
int chromatic_number(const vector<vector<int> > &G) {
    int n = (int)G.size();
    vector<int> neighbor(n, 0);
    for (int i = 0; i < n; ++i) {
        int S = (1<<i);
        for (int j = 0; j < n; ++j)
            if (G[i][j])
                S |= (1<<j);
        neighbor[i] = S;
    }

    // I[S] := #. of inndepndet subset of S
    vector<int> I(1<<n);
    I[0] = 1;
    for (int S = 1; S < (1<<n); ++S) {
        int v = __builtin_ctz(S);
        I[S] = I[S & ~(1<<v)] + I[S & ~neighbor[v]];
    }
    int low = 0, high = n;
    while (high - low > 1) {
        int mid = (low + high) >> 1;

        // g[S] := #. of "k independent sets" which cover S just
        // f[S] := #. of "k independent sets" which consist of subseta of S
        // then
        //   f[S] = sum_{T in S} g(T)
        //   g[S] = sum_{T in S} (-1)^(|S|-|T|)f[T]
        long long g = 0;
        for (int S = 0; S < (1<<n); ++S) {
            if ((n - __builtin_popcount(S)) & 1) g -= power(I[S], mid);
            else g += power(I[S], mid);
            g = (g % MOD + MOD) % MOD;
        }
        if (g != 0) high = mid;
        else low = mid;
    }
    return high;
}

int main(){
    ll N, M;
    cin >> N >> M;
    vector<vector<int>> G(N, vector<int>(N, 0));

    set<pair<int, int>> AB;
    REP(i,M){
        ll a, b;
        cin >> a >> b;
        a--, b--;
        AB.insert(make_pair(a, b));
        AB.insert(make_pair(b, a));
        //G[a][b] = 1;
        //G[b][a] = 1;
    }

    REP(i,N){
        REP(j,N){
            if(AB.find(make_pair(i, j)) == AB.end()){
                G[i][j] = 1;
                G[j][i] = 1;
            }
        }
    }

    ll ans = 0;
    //ans = N - chromatic_number(G);
    ans = chromatic_number(G);
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
constexpr auto ctz(int x) { return __builtin_ctz(x);      } constexpr auto ctz(ll x) { return __builtin_ctzll(x);      }
constexpr auto clz(int x) { return __builtin_clz(x);      } constexpr auto clz(ll x) { return __builtin_clzll(x);      }
constexpr auto pop(int x) { return __builtin_popcount(x); } constexpr auto pop(ll x) { return __builtin_popcountll(x); }
template <typename F> void for_each_subset(int mask, F&& f) {
    static_assert(is_convertible<decltype(f), function<void(int)>>::value, "can must be void(int)");
    for(int x = mask; x > 0; x = (x - 1) & mask) {
        f(x);
    }
}
const int N = 18;
int adj[N][N], mem[1 << N], is_clique[1 << N];
int opt(int mask) {
    int& ans = mem[mask];
    if(ans == -1) {
        if(is_clique[mask]) {
            ans = 1;
        } else {
            ans = lim<int>::max();
            for_each_subset(mask, [&](int submask) {
                if(submask != mask) {
                    if(is_clique[submask]) {
                        ans = min(ans, 1 + opt(mask ^ submask));
                    }
                }
            });
        }
    }
    return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        adj[u - 1][v - 1] = adj[v - 1][u - 1] = 1;
    }
    for(int i = 0; i < n; i++) {
        adj[i][i] = 1;
    }
    for(int mask = 0; mask < (1 << n); mask++) {
        is_clique[mask] = true;
        for(int ii = mask, i = ctz(ii); ii > 0; ii &= ~(ii & -ii), i = ctz(ii)) {
            for(int jj = mask, j = ctz(jj); jj > 0; jj &= ~(jj & -jj), j = ctz(jj)) {
                is_clique[mask] &= adj[i][j];
            }
        }
    }
    memset(mem, -1, sizeof mem);
    cout << opt((1 << n) - 1) << endl;
    return 0;
}


#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b,ll mod=MOD){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % mod;
      x = x * x % mod;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    cin >> res;
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

template< typename T >
T extgcd(T a, T b, T &x, T &y) {
    T d = a;
    if(b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

ll gcd(ll a,ll b){
    if(b)return gcd(b,a%b);
    return a;
}

ll func(){
    ll n = in();
    ll s = in();
    ll k = in();
    set<ll> used;
    ll x;
    ll y;
    if(s % gcd(n,k))return -1;
    y %= k / gcd(n,k);
    y += k / gcd(n,k);
    y %= k / gcd(n,k);
    extgcd(k,n,x,y);
    ll res = s / gcd(n,k) * ((y * n - gcd(n,k)) / k);
    res %= n / gcd(n,k);
    res += n / gcd(n,k);
    res %= n / gcd(n,k);
    return res;
}

int main(){
    int t = in();
    rep(i,t){
        cout << func() << endl;
    }
  return 0;
}

#include <iostream>

int64_t gcd(int64_t a,int64_t b,int64_t &x,int64_t &y)
{
  if(b==0){x=1;y=0;return a;}
  int64_t d=gcd(b,a%b,y,x);
  y-=a/b*x;
  return d;
}

int main()
{
  int T;
  std::cin>>T;

  for(int i=0;i<T;i++)
  {
    int64_t N,S,K;
    std::cin>>N>>S>>K;

    int64_t result=0;

    int64_t x,y;
    int64_t d=gcd(K,-N,x,y);
    if(S%d==0)
    {
      x*=-S/d;
      x%=N/d;if(x<0)x+=N/d;
      result=x;
    }
    else
    {
      result=-1;
    }

    std::cout<<result<<std::endl;
  }

  return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define MAX 1000006
using namespace std;
int main()
{

    ll t;
     ll n,m,x,a,b,c,flag=0;

    //vector<ll>v(n+5);

    vector<pair<int,int>>vp;
    vector<ll>v;
    vector<ll>v1;

    map<ll ,vector<ll>>mpp;

    set<ll>se;

    string s,s1,s2;

    ll ans=0,ans1=0,ans2=0,temp=0;

    double m1;

  cin>>n;

  for(ll i=0;i<n;i++)
  {
      cin>>a;
      v.push_back(a);
  }

   for(ll i=0;i<n;i++)
  {
      ll minn=INT_MAX;
       for(ll j=i;j<n;j++)
          {

              minn= min(v[j],minn);

                  ans=minn*(j-i+1);

              ans1=max(ans1,ans);
          }
  }

  cout<<ans1<<endl;

    return 0;

}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define endl '\n'
#define y1 holyshit
#define all(x) x.begin(),x.end()
const int inf=0x3f3f3f3f;

int N;
ll A[100010],B[100010];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>N;
	for(int i=0;i<N;i++) cin>>A[i];
	for(int i=0;i<N;i++) cin>>B[i];
	ll ans=0;
	for(int i=0;i<N;i++) ans+=A[i]*B[i];
	if(ans) cout<<"No";
	else cout<<"Yes";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
#define pow(n,m) powl(n,m)
#define sqrt(n) sqrtl(n)
const ll MAX = 5000000000000000000;
const ll MOD = 0;
random_device rd;
mt19937 mt(rd());
int main(){
    ll N,M;
    cin >> N >> M;
    vector<string> S(M),ans(N),T;
    set<string> ss;
    ll m = MAX;
    for(ll i = 0;i < M;i++) cin >> S[i];
    for(ll i = 0;i < M;i++) ss.insert(S[i]);
    for(ll i = 0;i < M;i++) m = min(m,(ll)S[i].size());
    for(ll t = 0;t < 36000;t++){
        string a = S[mt() % M];
        for(ll i = 0;i < 10;i++){
            string b = S[mt() % M];
            if(a.size() + b.size() <= N){
                a += b;
            }
        }
        while(a.size() < N) a += (char)('A' + (mt() % 8));
        T.emplace_back(a);
    }
    vector<ll> aaaa;
    do{
        for(ll j = 0;j < T.size();j++){
            set<string> c;
            for(ll k = 0;k < N;k++){
                string p = "";
                for(ll l = 0;l < m;l++){
                    p += T[j][(k + l) % N];
                }
                for(ll l = m;l < m + 5;l++){
                    p += T[j][(k + l) % N];
                    if(ss.count(p) != 0) c.insert(p);
                }
            }
            aaaa.emplace_back(c.size());
        }
    } while(false);
    sort(aaaa.begin(),aaaa.end(),greater<ll>());
    for(ll i = 0;i < N;i++){
        ll C = 0;
        string A = "____________________";
        for(ll j = 0;j < T.size();j++){
            set<string> c;
            for(ll k = 0;k < N;k++){
                string p = "";
                for(ll l = 0;l < m;l++){
                    p += T[j][(k + l) % N];
                }
                for(ll l = m;l < m + 5;l++){
                    p += T[j][(k + l) % N];
                    if(ss.count(p) != 0) c.insert(p);
                }
            }
            if(C < c.size()){
                C = c.size();
                A = T[j];
            }
            if(i == 0 && aaaa[900] > c.size()){
                T.erase(T.begin() + j);
                j--;
            }
        }
        for(ll k = 0;k < N;k++){
            string p = "";
            for(ll l = 0;l < m;l++){
                p += A[(k + l) % N];
            }
            for(ll l = m;l < m + 5;l++){
                p += A[(k + l) % N];
                if(ss.count(p) != 0) ss.erase(p);
            }
        }
        ans[i] = A;
    }
    ll C = 0;
    vector<string> ansans = ans,ansansans = ans;
    if(m < 5){
        for(ll t = 0;t < 1000;t++){
            swap(ans[mt() % N],ans[mt() % N]);
            for(ll i = 0;i < N;i++){
                ll qqq = mt() % N;
                for(ll j = 0;j < N;j++) ansans[j][i] = ans[i][(j + qqq) % N];
            }
            set<string> c;
            for(ll i = 0;i < N;i++){
                for(ll k = 0;k < N;k++){
                    string p = "";
                    for(ll l = 0;l < m;l++){
                        p += ansans[i][(k + l) % N];
                    }
                    for(ll l = m;l < m + 5;l++){
                        p += ansans[i][(k + l) % N];
                        if(ss.count(p) != 0) c.insert(p);
                    }
                }
            }
            if(C < c.size()){
                C = c.size();
                ansansans = ansans;
            }
        }
    }
    //cout<<C<<endl;
    for(ll i = 0;i < N;i++) cout << ansansans[i] << endl;
}

#include <bits/stdc++.h>
using namespace std;

const int N = 20;

mt19937 mt;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    mt.seed(time(nullptr));
    int n, m;
    cin >> n >> m;
    vector<string> v(m);
    for (auto& i : v) {
        cin >> i;
    }
    //sort(v.begin(), v.end(), [](string a, string b){return a.size() < b.size();});
    shuffle(v.begin(), v.end(), mt);
    char a[N][N];
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            a[i][j] = '.';
        }
    }
    int i = 0, j = 0;
    for (auto s : v) {
        if (j + s.size() >= n) {
            j = 0;
            ++i;
        }
        if (i >= n) {
            break;
        }
        for (int k = 0; k < s.size(); ++k, ++j) {
            a[i][j] = s[k];
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cout << a[i][j];
        }
        cout << '\n';
    }
	return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1010000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}

int N;
ve<pii> G;
ve<ve<pair<int,ll>>> Q;
vl c;
ve<ve<pair<int,ll>>> QQ;

ll dfs(int u, int v, ll d){

    c[v] += d;
    ll res = 0;
    ll rr = 0;

    ve<pair<ll,int>> aa;

    for (pair<int,ll> p : Q[v]) {
        if(p.fi == u){
            res += p.se;
        }else{
            ll dd = dfs(v, p.fi, d+p.se);
            aa.pb({dd, p.fi});
            c[v] += dd;
            res += dd;
            rr += dd;
        }
    }

    for (auto p : aa) {
        QQ[v].pb({p.se,rr-p.fi});
    }

    return res;

}

void dfs1(int u, int v, ll d){

    c[v] += d;

    for (pair<int,ll> p : QQ[v]) {
        if(p.fi == u){
            continue;
        }else{
            dfs1(v, p.fi, d+p.se);
        }
    }

    return;

}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> N;
    rep(i,N-1) {
        int a,b;
        cin >> a >> b;
        a--,b--;
        G.pb({a,b});
    }

    Q.resize(N);
    c.resize(N,0LL);
    QQ.resize(N);

    ve<pll> aaa(N-1,{0,0});

    int T;
    cin >> T;
    rep(i,T){
        int t,e; ll x;
        cin >> t >> e >> x;
        e--;
        if(t == 1) aaa[e].se += x;
        else aaa[e].fi += x;
    }

    rep(i,N-1){
        Q[G[i].fi].pb({G[i].se, aaa[i].fi});
        Q[G[i].se].pb({G[i].fi, aaa[i].se});
    }

    dfs(-1, 0, 0);
    dfs1(-1,0,0);
    rep(i,N) cout << c[i] << endl;

    return 0;
}

// Created by ash_98

#include<bits/stdc++.h>
using namespace std;

#define mx 200005
#define ll long long
#define mod 1000000007

char ch[mx];
int n,m,ii,k;
pair<int,int>ar[mx];

namespace Segment_Tree
{
	const int N=200005;
	ll Tree[N*4];
	ll Lazy[N*4];

	void Relax(int node,int be,int en)
	{
		if(!Lazy[node])return;

		Tree[node]+=Lazy[node];
		if(be!=en)
		{
			Lazy[node*2]+=Lazy[node];
			Lazy[node*2+1]+=Lazy[node];
		}
		Lazy[node]=0;
	}

	void init(int node,int be,int en)
	{
		Lazy[node]=0;
        if(be==en)
        {
        	//Tree[node]=ar[be];
        	return;
        }
        int mid=(be+en)/2;
        init(node*2,be,mid);
        init(node*2+1,mid+1,en);
        Tree[node]=Tree[node*2]+Tree[node*2+1];
	}

	void update(int node,int be,int en,int pos,int val)
	{
		Relax(node,be,en);
		if(be> pos || en<pos)return;
		if(be==en)
		{
			Tree[node]+=val;
			return;
		}
		int mid=(be+en)/2;
		update(node*2,be,mid,pos,val);
		update(node*2+1,mid+1,en,pos,val);
		Tree[node]=max(Tree[node*2],Tree[node*2+1]);
	}

	void Rupdate(int node,int be,int en,int i,int j,int val)
	{
		Relax(node,be,en);
		if(be>j || en<i)return ;
		if(be>=i && en<=j)
		{
			Lazy[node]+=val;
			Relax(node,be,en);
			return;
		}
		int mid=(be+en)/2;
		Rupdate(node*2,be,mid,i,j,val);
		Rupdate(node*2+1,mid+1,en,i,j,val);
		Tree[node]=Tree[node*2]+Tree[node*2+1];
	}

	ll query(int node,int be,int en,int i,int j)
	{
		Relax(node,be,en);
		if(be>j || en<i)return 0;
		if(be>=i && en<=j)return Tree[node];
		int mid=(be+en)/2;
		return query(node*2,be,mid,i,j)+query(node*2+1,mid+1,en,i,j);
	}

	void dbg_test(int node,int be,int en)
	{
		if(be==en)return;
		int mid=(be+en)/2;
		dbg_test(node*2,be,mid);
		dbg_test(node*2+1,mid+1,en);
	}
}

using namespace Segment_Tree;
int st[mx],en[mx];
int Final_array[mx];
vector<int>g[mx];

void dfs(int u,int p)
{
	st[u]=++k;
	for(int v:g[u])
	{
		if(v==p)continue;
		dfs(v,u);
	}
	en[u]=k;
}

void solve()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
		ar[i]={x,y};
	}
	dfs(1,-1);
	scanf("%d",&m);
	ll ex=0;
	for(int i=1;i<=m;i++)
	{
		int ti,x,y;
		scanf("%d%d%d",&ti,&x,&y);
		if(ti==1)
		{
			int u=ar[x].first;
			int v=ar[x].second;
			if(st[u]>st[v])
			{
				Rupdate(1,1,n,st[u],en[u],y);
			}
			else
			{
				ex+=y;
				Rupdate(1,1,n,st[v],en[v],-y);

			}

		}
		else
		{
			int u=ar[x].second;
			int v=ar[x].first;
			if(st[u]>st[v])
			{
				Rupdate(1,1,n,st[u],en[u],y);
			}
			else
			{
				ex+=y;
				Rupdate(1,1,n,st[v],en[v],-y);

			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		ll re=ex+query(1,1,n,st[i],st[i]);
		printf("%lld\n",re );
	}
}

int main()
{
	int t=1;
	//scanf("%d",&t);
	while(t--)solve();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    long k;
    cin >> a >> b >> k;
    long nCk[a+b+1][a+b+1];
    nCk[0][0] = 1;
    fill(nCk[0]+1,nCk[0]+a+b+1,0);
    for(int i = 1 ; i < a+b+1 ; i++){
        nCk[i][0] = 1;
        for(int j = 1 ; j < a+b+1 ; j++){
            nCk[i][j] = nCk[i-1][j-1] + nCk[i-1][j];
        }
    }
    string ans = "";
    int a2 = a;
    int b2 = b;
    for(int i = 0 ; i < a + b ; i++){
        long t = nCk[a2-1+b2][b2];
        if(k <= t){
            ans.push_back('a');
            a2--;
        }
        else{
            k-=t;
            ans.push_back('b');
            b2--;
        }
    }
    cout << ans << endl;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define random(l,r,T)    uniform_int_distribution<T>(l,r)(rng)
ll mod=1000000007;
ll fact[200000];
ll dmod(ll x){
    return ((x+mod)%mod);
}
ll power(ll x,ll y)
{
    ll res=1;
    while(y)
    {
        if(y&1) res=(res*x)%mod;
        x=(x*x)%mod; y>>=1;
    }
    return res;
}
ll nCr(ll n,ll r){
    if(r>n) return 0;
    else if(r<0) return 0;
    else if(r==0||r==n)return 1;
    ll ans=fact[n];
    ans=(ans*power(fact[n-r],mod-2))%mod; ans=(ans*power(fact[r],mod-2))%mod;
    return ans;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
template<class T, class H>using umap=unordered_map<T,H,custom_hash>;
template<class T>using uset=unordered_set<T,custom_hash>;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    ll a,b,c;
    cin>>a>>b>>c;
    if(min(a,b)>=0){
        if(a>b)cout<<">"<<endl;
        else if(a<b)cout<<"<"<<endl;
        else cout<<"="<<endl;
    }
    else if(max(a,b)<0){
        if(c%2==0){
            if(a>b)cout<<"<"<<endl;
        else if(a<b)cout<<">"<<endl;
        else cout<<"="<<endl;
        }
        else{
            if(a>b)cout<<">"<<endl;
        else if(a<b)cout<<"<"<<endl;
        else cout<<"="<<endl;
        }
    }
    else{
        if(a<0){
            if(c%2==0){
                if(abs(a)>abs(b))cout<<">"<<endl;
                else if(abs(a)<abs(b))cout<<"<"<<endl;
                else cout<<"="<<endl;
            }
            else{
                cout<<"<"<<endl;
            }
        }
        else{
            if(c%2==0){
                if(abs(b)>abs(a))cout<<"<"<<endl;
                else if(abs(b)<abs(a))cout<<">"<<endl;
                else cout<<"="<<endl;
            }
            else{
                cout<<">"<<endl;
            }
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
const int MOD=1e9+7;

int main(){
  ll B,C;
  cin>>B>>C;
  ll minus = C/2;
  if(B < 0 && B-minus < 0){
    ll base;
    if(C%2==0) base = (minus+1)*2-1;
    else base = (minus+1)*2;
    ll sub_minus = (C-1)/2,sub_cnt;
    if((C-1)%2==0) sub_cnt = max(sub_minus*2-1,0ll);
    else sub_cnt = sub_minus*2;
    base += min((-B-1)*2+1, sub_cnt);
    cout << base << endl;
  }else if(B > 0 && B-minus > 0){
    ll base;
    if(C%2==0) base = (minus+1)*2-1;
    else base = (minus+1)*2;
    ll sub_minus = (C-1)/2,sub_cnt;
    if((C-1)%2==0) sub_cnt = max(sub_minus*2-1,0ll);
    else sub_cnt = sub_minus*2;
    cout << base+sub_cnt << endl;
  }else if(B == 0){
    ll r = B+C/2;
    if(C%2==0) cout << r*2 << endl;
    else cout << r*2+1 << endl;
  }else{
    ll r = B+(C-1)/2;
    if((C-1)%2==0) cout << r*2 << endl;
    else cout << r*2+1 << endl;
  }
  return 0;
}

#include "bits/stdc++.h"
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
	int N, K;
	cin >> N >> K;
	vector<vector<mint>> dp(N + 1, vector<mint>(N + 1, 0));
	dp[0][0] = 1;
	for (int i = 1; i <= N; ++i) {
		for (int j = N; j >= 0; --j) {
			mint num = 0;
			if (j > 0) {
				num += dp[i - 1][j - 1];
			}
			if (2 * j <= N) {
				num += dp[i][2 * j];
			}
			dp[i][j] = num;
		}
	}
	cout << dp[N][K] << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

template <typename F>
class
#if defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard)
  [[nodiscard]]
#endif  // defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard)
FixPoint final : private F
{
public:
  template <typename G>
  explicit constexpr FixPoint(G&& g) noexcept
    : F{std::forward<G>(g)}
  {}

  template <typename... Args>
  constexpr decltype(auto)
  operator()(Args&&... args) const
#if !defined(__GNUC__) || defined(__clang__) || __GNUC__ >= 9
  noexcept(noexcept(F::operator()(std::declval<FixPoint>(), std::declval<Args>()...)))
#endif  // !defined(__GNUC__) || defined(__clang__) || __GNUC__ >= 9
  {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};  // class FixPoint

#if defined(__cpp_deduction_guides)
template <typename F>
FixPoint(F&&)
  -> FixPoint<std::decay_t<F>>;
#endif  // defined(__cpp_deduction_guides)

namespace
{
  template <typename F>
#if !defined(__has_cpp_attribute) || !__has_cpp_attribute(nodiscard)
  #  if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__((warn_unused_result))
#  elif defined(_MSC_VER) && _MSC_VER >= 1700 && defined(_Check_return_)
_Check_return_
#  endif  // defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 4)
#endif  // !defined(__has_cpp_attribute) || !__has_cpp_attribute(nodiscard)
  inline constexpr decltype(auto)
  makeFixPoint(F&& f) noexcept
  {
    return FixPoint<std::decay_t<F>>{std::forward<std::decay_t<F>>(f)};
  }
}  // namespace

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N;
	cin>> N;
	vector<pair<int, string>> mon(N);
	REP(i, N) {
	  cin >> mon[i].sc >> mon[i].fs;
	}
	sort(all(mon), greater<>());
	cout << mon[1].sc << endl;
}

#include <bits/stdc++.h>
#include<bits/extc++.h>

using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int N = (int)2e5 + 50;

int n, m, q;
struct P {
    ll x, y;
} p[N], res[N];

struct Op {
    int tp, p;
} ops[N];
vector<pii> qrs[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    rep(i, 0, n) cin >> p[i].x >> p[i].y;
    cin >> m;
    rep(i, 0, m) {
        cin >> ops[i].tp;
        if(ops[i].tp >= 3) cin >> ops[i].p;
    }
    cin >> q;
    rep(i, 0, q) {
        int a, b; cin >> a >> b; b--;
        qrs[a].push_back({b, i});
    }
    ll c_x = 0, dx_x = 1, dy_x = 0;
    ll c_y = 0, dx_y = 0, dy_y = 1;
    rep(i, 0, m + 1) {
        for(auto pr : qrs[i]) {
            int id = pr.first;
            res[pr.second] = {c_x + dx_x * p[id].x + dy_x * p[id].y, c_y + dx_y * p[id].x + dy_y * p[id].y};
        }
        if(ops[i].tp == 1) {
            tie(c_x, dx_x, dy_x, c_y, dx_y, dy_y) =
                    make_tuple(c_y, dx_y, dy_y, -c_x, -dx_x, -dy_x);
        } else if(ops[i].tp == 2) {
            tie(c_x, dx_x, dy_x, c_y, dx_y, dy_y) =
                    make_tuple(-c_y, -dx_y, -dy_y, c_x, dx_x, dy_x);
        } else if(ops[i].tp == 3) {
            tie(c_x, dx_x, dy_x, c_y, dx_y, dy_y) =
                    make_tuple(2 * ops[i].p - c_x, -dx_x, -dy_x, c_y, dx_y, dy_y);
        } else {
            tie(c_x, dx_x, dy_x, c_y, dx_y, dy_y) =
                    make_tuple(c_x, dx_x, dy_x, 2 * ops[i].p - c_y, -dx_y, -dy_y);
        }
    }
    rep(i, 0, q) cout << res[i].x << " " << res[i].y << "\n";
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
ll dmod(ll x){
    return ((x+mod)%mod);
}
ll modular_power(ll x,ll y){
    ll ans=1;
    while(y){
        if(y&1)ans=dmod(ans*x);
        y/=2;
        x=dmod(x*x);
    }
    return ans;
}
vector <int> v[3000];
set <int> st;
int ans;
void dfs(int x){
    if(st.count(x))return;
    st.insert(x);
    ans++;
    for(auto node:v[x]){
        dfs(node);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int a,b;
        cin>>a>>b;
        v[a].push_back(b);
    }
    ans=0;
    for(int i=1;i<=n;i++){
        st.clear();
        dfs(i);
    }
    cout<<ans;
    return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <set>
#include <stdio.h>
#include <string.h>
#include <map>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;
ll n, a, b, s, res;
int main(){
    cin>>n;
    s = 0;
    res = 0;
    for(int i = 0; i < n; ++i){
        cin>>a>>b;
        s = (b * (b + 1)) / 2;;
        s -= (a * (a + 1)) / 2;
        s += a;
        res += s;
    }
    cout<<res<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
//#define endl '\n'

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	llo n,k;
	cin>>n>>k;
	llo mod=998244353;
	llo ans=0;
	for(llo i=2;i<=2*n;i++){
		llo j=i-k;
		if(j<2 or j>2*n){
			continue;
		}
		llo val1=(i-1)-2*max(i-n-1,(llo)0);
		llo val2=(j-1)-2*max(j-n-1,(llo)0);
		ans+=val1*val2;
		//cout<<i<<","<<j<<','<<val1<<','<<val2<<endl;
	}
	cout<<ans<<endl;

	return 0;
}

#include<bits/stdc++.h>
using namespace std;

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
typedef tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define cntleadz(x) __builtin_clz(x) // or add ll at the end for long long
#define cnttrailz(x) __builtin_ctx(x)
#define cntpop(x) __builtin_popcount(x)
#define binparity(x) __builtin_parity(x)
#define pb push_back
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 998244353//1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)

int binExp(int x,int n)
{
    int res=1;
    while(n)
    {
        if(n&1) res=(res*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return res;
}

// int fact[100001];
// int modInv(int i) {return binExp(i,mod-2);}
// int ncr(int n,int r) {return (n>=r?(fact[n]*modInv(fact[r]))%mod*modInv(fact[n-r])%mod:0);}

void solve()
{
    int n,k;
    cin>>n>>k;

    int an = 0;

    if(k < 0) k = -k;
    f1(i,2,2*n)
    {
        if(i + k > 2*n) break;
        // cout<<"i "<<i<<'\n';

        int ans;

        if(i < n+2)
        {
            ans = (i-2+1);
        }
        else
        {
            int extra = i - n;

            extra = n - extra;
            ans = extra+1;
        }

        int ans2;
        if(i+k < n+2)
        {
            ans2 = (i-2+k+1);
        }
        else
        {
            int extra = i+k - n;

            extra = n - extra;
            ans2 = extra+1;
        }

        an += ans*ans2;

        // cout<<i<<' '<<ans<<' '<<ans2<<'\n';
    }

    cout<<an;
}

signed main()
{
    fast

    clock_t start,end;
    #ifndef ONLINE_JUDGE
        freopen("inputf.txt","r",stdin);
        freopen("outputf.txt","w",stdout);
    #endif
    start = clock();

    // test
    solve();

    end = clock();
    double time_taken = double(end-start) / double(CLOCKS_PER_SEC);
    // cout<<time_taken<<" sec";
}


#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); ++i)

int main(){
    ll b, c;
    cin >> b >> c;
    ll d, q;
    ll ans = 0;
    if(c > 1){
        // -b => -b-1 への遷移の数
        d = (ll) (c-1) / 2;  // 0
        // -bからのあまりの金額
        q = (ll) (c-1) % 2;  // 1
        // -bからの遷移の数(-bできることが前提)
        ans += (d+1)*2;  // 2
        // -b から -b-1に遷移出来るなら
        if(q >= 1){  // q=1
            // ans++;
        }else{
            ans--;
        }
    }else{
        ans++; // B
        if(c == 1 && b != 0){  // -B
            ans++;
        }
    }

// 多分個々からおかしい
    // B-1がどれぐらい出来るか
    d = (ll) c / 2;  // 1
    q = (ll) c % 2;  // 0
    if(b < 0){
        b *= -1;
        ans++;
    }

    // B-1ができるか
    if(d >= b){  // 1 > 22
        if(b > 0){
            // B - 最大~最小
            ans += b*2;
            ans--; // 0が重複
            // cout << "重複" << endl;
        }
    }else{
        ans += d*2; // 4
        if(q==0){
            ans--;
            // cout << "あまりなし" << endl;
        }
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, i, q, a, b, t;
    bool sw = false;
    string s;
    cin >> n >> s >> q;
    while (q--)
    {
        cin >> t >> a >> b;
        // cout<<sw<<" ";
        if (t == 1)
        {
            if (sw == false)
            {
                char c = s[a - 1];
                s[a - 1] = s[b - 1];
                s[b - 1] = c;
            }
            else
            {
                if(a <= n && b <= n)
                {
                    char c = s[a + n - 1];
                    s[a + n - 1] = s[b + n - 1];
                    s[b + n - 1] = c;
                    // cout << s;
                }
                else if(a <= n && b > n)
                {
                    char c = s[a + n - 1];
                    s[a + n - 1] = s[b - n - 1];
                    s[b - n - 1] = c;
                    // cout << s;
                }
                else if(a > n && b > n)
                {
                    char c = s[a - n - 1];
                    s[a - n - 1] = s[b - n - 1];
                    s[b - n - 1] = c;
                    // cout << s;
                }
                else
                {
                    char c = s[a - n - 1];
                    s[a - n - 1] = s[b + n - 1];
                    s[b + n - 1] = c;
                    // cout << s;
                }
            }
        }
        else
        {
            sw = !sw;
        }
    }
    if(sw)
        s = s.substr(n,n) + s.substr(0,n);
    cout << s;
    return 0;
}


//#pragma GCC optimize ("O2")
//#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;

#include<cstdio>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

ll dph[2000], dphw[4000], *naname = dphw + 2000;
const int mod = 1e9 + 7;

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);

	int H = 0, W = 0;
	char c;
	while ((c = getchar_unlocked()) >= '0') H = H * 10 + c - '0';
	while ((c = getchar_unlocked()) >= '0') W = W * 10 + c - '0';

	getchar_unlocked();
	dph[0] = 1;
	naname[0] = 1;
	ll w = 1;
	ll tmp = 1;
	rep1(i, W - 1) {
		tmp = w;
		if (getchar_unlocked() == '.') {
			dph[i] = w;
			naname[i] = w;
			w = w * 2 % mod;
		}
		else {
			dph[i] = 0;
			naname[i] = 0;
			w = 0;
		}
	}
	getchar_unlocked();

	rep1(i, H - 1) {
		if (getchar_unlocked() == '.') {
			tmp = dph[0];
			w = tmp;
			dph[0] = (tmp + dph[0]) % mod;
			naname[-i] = (tmp + naname[-i]) % mod;
		}
		else {
			w = 0;
			dph[0] = 0;
			naname[-i] = 0;
		}
		if (!(i & 7)) {
			rep1(j, W - 1) {
				if (getchar_unlocked() == '.') {
					tmp = w + dph[j] + naname[j - i];
					w += tmp - ll(double(w + tmp) / mod) * mod;
					dph[j] += tmp - ll(double(dph[j] + tmp) / mod) * mod;
					naname[j - i] += tmp - ll(double(tmp + naname[j - i]) / mod) * mod;
				}
				else {
					w = 0;
					dph[j] = 0;
					naname[j - i] = 0;
				}
			}
		}
		else {
			rep1(j, W - 1) {
				if (!(j & 7)) {
					if (getchar_unlocked() == '.') {
						tmp = w + dph[j] + naname[j - i];
						w += tmp - ll(double(w + tmp) / mod) * mod;
						dph[j] += tmp - ll(double(dph[j] + tmp) / mod) * mod;
						naname[j - i] += tmp - ll(double(tmp + naname[j - i]) / mod) * mod;
					}
					else {
						w = 0;
						dph[j] = 0;
						naname[j - i] = 0;
					}
				}
				else {
					if (getchar_unlocked() == '.') {
						tmp = w + dph[j] + naname[j - i];
						w = w + tmp;
						dph[j] = tmp + dph[j];
						naname[j - i] = tmp + naname[j - i];
					}
					else {
						w = 0;
						dph[j] = 0;
						naname[j - i] = 0;
					}
				}
			}
		}
		getchar_unlocked();
	}

	printf("%lld\n", tmp % mod);

	Would you please return 0;
}

#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()

const int mod = 1e9 + 7;
int H, W;
char arr[2200][2200];
ll cache[2200][2200][4];
int dy[] = { 1, 0, 1 };
int dx[] = { 0, 1, 1 };

ll dp(int y, int x, int dir) {
	if (y == H - 1 && x == W - 1) return 1;

	ll& ret = cache[y][x][dir];
	if (ret != -1) return ret;

	ret = 0;
	if (x + 1 < W && arr[y][x + 1] != '#') ret = (ret + dp(y, x + 1, 0)) % mod;
	if (y + 1 < H && arr[y + 1][x] != '#') ret = (ret + dp(y + 1, x, 1)) % mod;
	if (y + 1 < H && x + 1 < W && arr[y + 1][x + 1] != '#') ret = (ret + dp(y + 1, x + 1, 2)) % mod;

	if (dir == 0 && x + 1 < W && arr[y][x + 1] != '#') ret = (ret + dp(y, x + 1, 0)) % mod;
	if (dir == 1 && y + 1 < H && arr[y + 1][x] != '#') ret = (ret + dp(y + 1, x, 1)) % mod;
	if (dir == 2 && y + 1 < H && x + 1 < W && arr[y + 1][x + 1] != '#') ret = (ret + dp(y + 1, x + 1, 2)) % mod;
	return ret;
}

void solve(int tc) {
	cin >> H >> W;
	for (int i = 0; i < H; i++) cin >> arr[i];
	memset(cache, -1, sizeof(cache));
	cout << dp(0, 0, 3) << '\n';
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	if (0) {
		int T; cin >> T;
		for (int i = 1; i <= T; i++) solve(i);
	}
	else {
		solve(0);
	}
	return 0;
}


#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;

const lld N = 200043;
const lld MOD = 1000000007;

lld add(lld x, lld y)
{
    x =((x%MOD)+(y%MOD))%MOD;
    while(x >= MOD) x -= MOD;
    while(x < 0) x += MOD;
    return x;
}

lld mul(lld x, lld y)
{
    return ((x%MOD)*(y%MOD))% MOD;
}

lld binpow(lld x, lld y)
{
    lld z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}

lld inv(lld x)
{
    return binpow(x, MOD - 2);
}

lld divide(lld x, lld y)
{
    return mul(x, inv(y));
}

// Combinations

/*
lld fact[N];

void precalc()
{
    fact[0] = 1;
    for(lld i = 1; i < N; i++)
        fact[i] = mul(fact[i - 1], i);
}

lld C(lld n, lld k)
{   if(k>n)
        return 0;
    return divide(fact[n], mul(fact[k], fact[n - k]));
}
*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t,i,j;
    t=1;
    //cin>>t;
    while(t--)
    {
        lld n;
        cin>>n;
        vector<lld>ar(n);
        for(i=0;i<n;i++)
            cin>>ar[i];
        sort(ar.begin(),ar.end());
        lld p=0;
        lld ans=1;
        for(i=0;i<n;i++)
        {
            ans=mul(ans,ar[i]-p+1);
            p=ar[i];
        }
        cout<<ans<<endl;
    }
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll pref[200005], suff[200005], up[200005], down[200005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    ll arr[n];
    unordered_map<ll, ll> mp;
    ll ans = 0;
    for(int i = 0; i < n; i++)  {
        cin >> arr[i];
        ll temp = arr[i];
        ll mod = temp%200;
        ans += mp[mod];
        mp[mod]++;
    }
    cout << ans << "\n";
}


#include <bits/extc++.h>
using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  double dp[101][101][101] = {};
  for (auto i = 99; i >= a; i--) {
    for (auto j = 99; j >= b; j--) {
      for (auto k = 99; k >= c; k--) {
        dp[i][j][k] = 1 + (i * dp[i + 1][j][k] + j * dp[i][j + 1][k] +
                           k * dp[i][j][k + 1]) /
                              (i + j + k);
      }
    }
  }
  cout << fixed << setprecision(10);
  cout << dp[a][b][c] << endl;
}

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2> void add( T1 &x, T2 y, ll m = MOD )
{
    x += y;
    if( x >= m )
        x -= m;
}

template<class T1, class T2> void sub( T1 &x, T2 y, ll m = MOD )
{
    x -= y;
    if( x < 0 )
        x += m;
}

ld dp[102][102][102];
int vis[102][102][102];
ld solve( int a, int b, int c )
{
    if( a == 100 || b == 100 || c == 100 )
        return 0;

    if( vis[a][b][c] != 0 )
        return dp[a][b][c];

    vis[a][b][c] = 1;
    ld go = 1.0/(a+b+c);

    ld ans = 1;

    ans += (1.0*a*go) * solve(a+1,b,c);
    ans += (1.0*b*go) * solve(a,b+1,c);
    ans += (1.0*c*go) * solve(a,b,c+1);

    return dp[a][b][c] = ans;
}

int main()
{
    #ifdef gupta_samarth
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    fastio();

    memset(vis,0,sizeof(vis));

    int a,b,c;
    cin>>a>>b>>c;
    cout<<fixed<<setprecision(9)<<solve(a,b,c);

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD int(1e9+7)
#define INF int(1e9+7)
#define LINF ll(1e18+7)
#define PI acos(-1)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define P pair<ll,ll>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

int n;
int Mat[550][550];

int main(){
  cin>>n;
  rep(i,n)rep(j,n) cin>>Mat[i][j];
  vector<int> a(n),b(n);
  a[0]=0;
  b[0]=Mat[0][0]-a[0];
  bool ok=1;
  rep(i,n) a[i]=Mat[i][0]-b[0];
  rep(j,n) b[j]=Mat[0][j]-a[0];
  rep(i,n)rep(j,n){
    if(a[i]+b[j]!=Mat[i][j]) ok=0;
  }
  int amin=INT_MAX, bmin=INT_MAX;
  rep(i,n) chmin(amin,a[i]);
  rep(i,n) chmin(bmin,b[i]);
  if(amin<0 && bmin<0) ok=0;
  else if(amin<0){
    rep(i,n) a[i]+=abs(amin);
    rep(i,n){
      b[i]-=abs(amin);
      if(b[i]<0) ok=0;
    }
  }else if(bmin<0){
    rep(i,n) b[i]+=abs(bmin);
    rep(i,n){
      a[i]-=abs(bmin);
      if(a[i]<0) ok=0;
    }
  }
  if(ok){
    cout<<"Yes"<<endl;
    rep(i,n) cout<<a[i]<<" "; cout<<endl;
    rep(i,n) cout<<b[i]<<" "; cout<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define ss cout << " ";
#define nn cout << "\n";
#define ct(x) cout << x;
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define qr queries();
void solve();
void YN(bool b){if (b){ctn("YES");}else{ctn ("NO");}};
void yn(bool b){if (b){ctn("Yes");}else{ctn ("No");}};
void queries(){int n;cin >> n;while (n--)solve();}
// // // // // // // // // // // // // // // // // // // // // //
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
const int maxn = 200200;

void solve(){

    return;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    long double a,b;
    cin >> a >> b;
    cout << fixed << setprecision(9) << (100 - (b / a * 100));
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main() {
	srand(time(0));
	for(int c=1; c<=1000; c++) {
		int x1,y1,x2,y2;
		cin>>x1>>y1>>x2>>y2;
		x1++,y1++,x2++,y2++;
		string s="";
		for(int i=x1; i<=x2-1; i++) {
			s+='D';
		}
		for(int i=x2; i<=x1-1; i++) {
			s+='U';
		}
		for(int i=y1; i<=y2-1; i++) {
			s+='R';
		}
		for(int i=y2; i<=y1-1; i++) {
			s+='L';
		}
		random_shuffle(s.begin(),s.end());
		cout<<s<<"\n";
		fflush(stdout);
		int x;
		cin>>x;
	}
}

#include <iostream>
#include <vector>
#include <string>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

pair<int, int> divmod(int a, int b) { return make_pair(a / b, a % b); }

class Solver {
private:
    const int n = 30;
    double score = 0.0;

    pair<int, int> input_query() {
        int si, sj, ti, tj;
        cin >> si >> sj >> ti >> tj;
        return make_pair(si * n + sj, ti * n + tj);
    }

    void output(string path) { cout << path << endl; }

    void input_score() { int in; cin >> in; }

    string query(int s, int t) {
        auto[si, sj] = divmod(s, n);
        auto[ti, tj] = divmod(t, n);
        string res = "";
        int di = ti - si;
        int dj = tj - sj;
        if(di > 0) res += string(di, 'D');
        else res += string(-di, 'U');
        if(dj > 0) res += string(dj, 'R');
        else res += string(-dj, 'L');
        return res;
    }

public:
    void solve() {
        rep(k, 1000) {
            auto[s, t] = input_query();
            string path = query(s, t);
            output(path);
            input_score();
        }
    }
};

int main() {
    Solver solver;
    solver.solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
constexpr ll MOD=1000000007;
constexpr ll INF=1e18;

int main(){
    int n, x; cin >> n >> x;
    x*=100;
    int v, p;
    ll sum=0;
    REP(i,n){
        cin >> v >> p;
        sum+=v*p;
        if(sum>x){
            cout << i+1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,x;
    cin >> n >> x;

    vector<int> v(n);
    vector<int> p(n);

    for (int i = 0; i < n; i++) {
        cin >> v.at(i) >> p.at(i);
    }

    int sum = 0;
    for (int i = 0; i < n; i++) {
        int g = (v.at(i)*p.at(i));

        sum += g;

        if (sum > x*100) {
            cout << i+1 << endl;
            break;
        }
        }
    if (sum <= x*100) {
        cout << -1 << endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 998244353;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

struct dsu {
	public:
		dsu(int n): cnt(n), par(n), siz(n, 1) {
			for (int i = 0; i < n; i++) par[i] = i;
		}
		bool merge(int x, int y) {
			x = find(x);
			y = find(y);
			if (x == y) return false;
			if (siz[x] < siz[y]) swap(x, y);
			siz[x] += siz[y];
			par[y] = x;
			--cnt;
			return true;
		}
		int find(int x) {
			return par[x] == x ? x : par[x] = find(par[x]);
		}
		int size(int x) {
			return siz[find(x)];
		}
		bool same(int x, int y) {
			return find(x) == find(y);
		}
		int groups() {
			return cnt;
		}
	private:
		int cnt;
		vector<int> par, siz;
};

int main() {
	int n, d;
	cin >> n >> d;
	vector<vector<int>> a(n, vector<int>(n));
	rep(i,n) rep(j,n) cin >> a[i][j];
	dsu h(n), w(n);
	ll ans = 1;
	rep(i,n) {
		rep(k,n) {
			bool b = true;
			rep(j,n) {
				if (a[i][j] + a[k][j] > d) b = false;
			}
			if (b) h.merge(i, k);
		}
	}
	map<int, int> mph;
	rep(i,n) {
		if (mph[h.find(i)]) continue;
		int m = h.size(i);
		for (int j = 1; j <= m; j++) {
			ans *= j;
			ans %= MOD;
		}
		mph[h.find(i)]++;
	}

	rep(j,n) {
		rep(k,n) {
			bool b = true;
			rep(i,n) {
				if (a[i][j] + a[i][k] > d) b = false;
			}
			if (b) w.merge(j, k);
		}
	}
	map<int, int> mpw;
	rep(i,n) {
		if (mpw[w.find(i)]) continue;
		int m = w.size(i);
		for (int j = 1; j <= m; j++) {
			ans *= j;
			ans %= MOD;
		}
		mpw[w.find(i)]++;
	}
	cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, const T& t){ return v2<T>(r, vector<T>(c, t)); }
#define F first
#define S second

const int MOD = 998244353;
inline int add(int a, int b){ return (a+b)%MOD; }
inline int sub(int a, int b){ return ((a-b)%MOD + MOD)%MOD; }
inline int mul(int a, int b){ return ((ll)a*b)%MOD; }

int n, k;
v2<int> adjc, adjr;
vector<int> v, fact;

int dfs(v2<int>& adj, int node){
    v[node] = true;
    int ans = 1;
    for(int i : adj[node]){
        if(!v[i])
            ans += dfs(adj, i);
    }
    return ans;
}

int ways(v2<int>& adj){
    int x = 1;
    v = vector<int>(n, false);
    for(int i = 0; i < n; ++i){
        if(!v[i]){
            int s = dfs(adj, i);
            x = mul(x, fact[s]);
        }
    }
    return x;
}

void solve(){
    cin >> n >> k;

    v2<int> m = fill(n,n,-1);
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            cin >> m[i][j];
        }
    }

    adjc = v2<int>(n), adjr = v2<int>(n);
    for(int x = 0; x < n; ++x){
        for(int y = x+1; y < n; ++y){
            bool okc=true, okr=true;
            for(int i = 0; i < n; ++i){
                if(m[i][x]+m[i][y] > k){
                    okc = false;
                }
                if(m[x][i]+m[y][i] > k){
                    okr = false;
                }
            }
            if(okc){
                adjc[x].push_back(y);
                adjc[y].push_back(x);
            }
            if(okr){
                adjr[x].push_back(y);
                adjr[y].push_back(x);
            }
        }
    }

    fact = vector<int>(n+1);
    fact[0] = 1;
    for(int i = 1; i <= n; ++i){
        fact[i] = mul(i, fact[i-1]);
    }

    int r = ways(adjr);
    int c = ways(adjc);
    int ans = mul(r, c);
    cout << ans << "\n";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


/////////////////////////////////////////////////
/////             Give me AC!!!!            /////
/////////////////////////////////////////////////
//↑これじゃ気合いが足りない！
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////             お願いしますACをくださいそうじゃないと僕泣きますお願いしますACをくださいJudge様....            /////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N - 1; i >= 0; i--)
const int MOD = 1000000007;
const int INF = 10000000;
const int MAX = 100000;
const ld PI = (acos(-1));
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true;} return false;}
typedef pair<int, int> P;
typedef pair<ll,ll> PLL;
ld rad(ld a) {return a * 180 / PI;}
const int dx[4] = {1, 0, -1, 0};//2次元グリッド上のx軸方向
const int dy[4] = {0, 1, 0, -1};//2次元グリッド上のy軸方向

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};

map<ll,ll> factorize_list;

void prime_factorize(ll N) {
    for (ll a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        ll ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        factorize_list[a] = ex;
    }

    // 最後に残った数について
    if (N != 1) factorize_list[N] = 1;
    return ;
}

//dpTable
vector<ll> dp(13,0);

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll mod(ll val, ll m) {
  ll res = val % m;
  if (res < 0) res += m;
  return res;
}

long long fac[MAX], finv[MAX], inv[MAX];

char upper(char c){
    if('a' <= c && c <= 'z'){
        c = c - ('a' - 'A');
    }
    return c;
}
char lower(char c){
    if('A' <= c && c <= 'Z'){
        c = c + ('a' - 'A');
    }
    return c;
}

struct edge{ll to, cost;};

vector<vector<edge>> graph;
vector<int> dist;
vector<int> prever;

void dijkstra(int N,int S) {
    dist = vector<int>(N,INF);
    prever = vector<int>(N, -1);
    dist.at(S) = 0;
    priority_queue<P,vector<P>,greater<P>> que;
    que.push({0,S});
    while (!que.empty()) {
        auto p = que.top();
        que.pop();
        int v = p.second;
        if (dist.at(v) < p.first) continue;
        for (int i = 0; i < graph.at(v).size(); i++) {
            edge e = graph.at(v).at(i);
            if (dist.at(e.to) > dist.at(v) + e.cost) {
                dist.at(e.to) = dist.at(v) + e.cost;
                prever.at(e.to) = v;
                que.push({dist.at(e.to),e.to});
            }
        }
    }
}

vector<int> get_path(int t){ //頂点tへの最短路
    vector<int> path;
    for(; t != -1;t=prever[t]){
        path.push_back(t);
    }
    reverse(path.begin(), path.end());
    return path;
}

using Graph = vector<vector<edge>>;

signed main(){
    int A,B;
    cin >> A >> B;
    cout << (A + B) / 2 << ' ' << (A - B) / 2 << endl;
    return 0;
}

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<cmath>

#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define per(i,a,b) for(ll i=a;i>=b;--i)
#define fi first
#define se second
#define mp make_pair
#define all(x) x.begin(),x.end()
#define debug(x) cout<<# x <<" is "<<x<<endl;

using namespace std;
typedef long long ll;
typedef pair<ll,ll> PII;
const ll maxn=1e5+10,inf=0x3f3f3f3f3f3f3f3f,mod=1e9+7;

int main()
{
	int n;
	string s;
	cin>>n;
	cin>>s;

	if(s[0]!=s[n-1]) cout<<1<<endl;
	else{
		bool flag=0;
		rep(i,1,n-3){
			if(s[i]!=s[0]&&s[i+1]!=s[0])
				flag=1;break;
		}
		if(flag) cout<<2<<endl;
		else cout<<-1<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define int long long

#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pp pair< int , int >
#define mod 1000000007
#define N 200005

int A[N];

signed main(){
    int n;
    cin >> n;
    for(int i=1; i<=n; i++) scanf("%d", &A[i]);

    vector < int > ans;
    for(int i=1; i<=n;){

        int j = i;
        for(; A[j] == j+1 ;) j++;

        if(j < n && A[j+1] != i){
            cout << -1;
            return 0;
        }

        for(int k=min(n-1, j); k>=i; k--)
            ans.pb(k);

        i = j + 1;
        A[i] = A[i-1];
    }

    for(int w: ans)
        printf("%d\n", w);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff(i,a,b) for( ll i=a;i<b;i++)
#define fb(i,a,b) for( ll i=a;i>=b;i--)
#define tc() int t; cin>> t; while (t--)
#define MOD 1000000007
#define vec vector<ll>
#define pb push_back
#define b begin()
#define e end()
int main()
{ios_base::sync_with_stdio(false);
    cin.tie(NULL);
ll n; cin>>n;
if(n%2)
{cout<<"Black";}
else
{
    cout<<"White";
}

return 0;}
//PRATIK_SINGH!!

// ░█████╗░░░░░░░░░░░░░░░
// ██╔══██╗░░██╗░░░░██╗░░
// ██║░░╚═╝██████╗██████╗
// ██║░░██╗╚═██╔═╝╚═██╔═╝
// ╚█████╔╝░░╚═╝░░░░╚═╝░░
// ░╚════╝░░░░░░░░░░░░░░░


#include <bits/stdc++.h>
using namespace std;
int a,b,c,d;
int main(){
	cin>>a>>b>>c>>d;
	cout<<b-c;

}

#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define all(V) V.begin(),V.end()
#define PI 3.14159265359
#define fi fixed
#define se setprecision(10)
using namespace std;

int main(){
  int a,b,c,d;cin >> a >> b >> c >> d;
  int x = b,y = c;
  cout << x - y << endl;
}


#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

typedef long long LL;

const LL N = 1e10;

LL a[10];
LL b[10],c[10];

int main()
{
    LL k;
    cin >> k;
    for(int i = 1;i <= 9;i++){
        a[i] = k;
    }
    string s1,s2;
    cin >> s1 >> s2;
    for(int i = 0;i < 4;i++){
        b[s1[i] - '0']++;
        c[s2[i] - '0']++;
    }
    for(int i = 1;i <= 9;i++){
        int cnt = b[i];
        a[i] -= cnt;
        b[i] = i;
        while (cnt--)
        {
            b[i] *= 10;
        }
        int cnt1 = c[i];
        a[i] -= cnt1;
        c[i] = i;
        while (cnt1--)
        {
            c[i] *= 10;
        }
    }
    LL count = (9 * k - 8) * (9 * k - 9);//total
    LL res = 0;
    for(int i = 1;i <= 9;i++){
        for(int j = 1;j <= 9;j++){
            if(i == j && a[i] < 2){

            }else if(a[i] <= 0 || a[j] <= 0){
                continue;
            }else {
                b[i] *= 10;
                c[j] *= 10;
                LL sum = 0;
                for(int m1 = 1;m1 <= 9;m1++){
                    sum += b[m1];
                    sum -= c[m1];
                }
                if(sum > 0){
                    if(i == j){
                        res += a[i] * (a[j] - 1);
                    }else {
                        res += a[i] * a[j];
                    }
                }
                b[i] /= 10;
                c[j] /= 10;
            }
        }
    }
    //cout << res << "===" << count << endl;
    printf("%.7lf",double(res) / count);
    return 0;
}

#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <deque>
#include <set>
#include <limits>
#include <string>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <numeric>

using namespace std;

using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

/* input & output */
#define IN(a) cin >> a
#define OUT(a) cout << a << endl
#define OUT_PREC(a, n) cout << fixed << setprecision(n) << a << endl

/* vector */
#define VEC(t, v, n, ini) vector<t> v(n, ini)
#define VEC2(t, v, m, n, ini) vector<vector<t>> v(m, vector<t>(n, ini))
#define VEC3(t, v, k, m, n, ini) vector<vector<vector<t>>> v(k, vector<vector<t>>(m, vector<t>(n, ini)))

/* bit */
#define IS_TRUE(bit, i) (bit & (1 << i))   // bitのi成分
#define FLAG_ON(bit, i) (bit｜(1 << i))    // bitのi成分をtrueに
#define FLAG_OFF(bit, i) (bit & ~(1 << i)) // bitのi成分をfalseに
#define ALL_TRUE(n) (1 << n)               // 2^n
#define CMPSET(bit, s) (bit ^ s)           // sのbitに対する補集合
#define INCLUDES(a, b) ((a & b) == b)      // aはbを含むか

double solve()
{
    int k;

    cin >> k;

    int s[9] = {0};
    int t[9] = {0};
    int rest[9] = {k, k, k, k, k, k, k, k, k};
    int crdnum = 9 * k - 8;

    string tmp;
    cin >> tmp;
    FOR(i, 0, 4)
    {
        ++s[tmp[i] - '1'];
        --rest[tmp[i] - '1'];
    }
    cin >> tmp;
    FOR(i, 0, 4)
    {
        ++t[tmp[i] - '1'];
        --rest[tmp[i] - '1'];
    }

    vector<vector<bool>> win(9, vector<bool>(9, false));

    FOR(i, 0, 9)
    {
        FOR(j, 0, 9)
        {
            ++s[i];
            ++t[j];

            ll ps = 0;
            ll pt = 0;

            FOR(k, 0, 9)
            {
                ps += (k + 1) * pow(10, s[k]);
                pt += (k + 1) * pow(10, t[k]);
            }

            if (ps > pt)
                win[i][j] = true;

            --s[i];
            --t[j];
        }
    }

    double ans = 0;
    double test = 0;

    FOR(i, 0, 9)
    {
        if (rest[i] > 0)
        {
            double pos = (double)rest[i] / (double)crdnum;
            --rest[i];
            FOR(j, 0, 9)
            {
                if (rest[j] > 0)
                {
                    double npos = pos * ((double)rest[j] / (double)(crdnum - 1));
                    test += npos;
                    if (win[i][j])
                        ans += npos;
                }
            }
            ++rest[i];
        }
    }

    return ans;
}

int main()
{
    /* solve */
    OUT_PREC(solve(), 15);
    system("pause");
}


#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline T int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
#include <bits/stdc++.h>
using namespace std;
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
// sort(ALL(v), [](auto const& lhs, auto const& rhs) { return lhs > rhs; /* 左の方が大きい...というイメージ。*/ });
// --------------------------------------------------------------------------------------------- //

static const int MAX = 100001;
static const ll MOD = 1000000007;

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	ll N; cin >> N;
	vector<ll> A(N), B(N), AmB(N);
	rep(i, N){
		cin >> A[i];
	}
	ll sum = 0;
	rep(i, N) {
		cin >> B[i];
		sum += B[i];
		AmB[i] = A[i] - B[i];
	}
	priority_queue<ll> gu, ki;
	rep(i, N){
		if(i % 2 == 0){
			gu.push(AmB[i]);
		}
		else{
			ki.push(AmB[i]);
		}
	}

	ll ans = sum;
	while(!gu.empty()){
		ll a = gu.top(), b = ki.top();
		gu.pop(), ki.pop();
		chmax(ans, ans + a + b);
	}
	cout << ans << endl;

	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

template <class T>
struct BIT {
    BIT(int n) : b(n + 1), n(n) {}
    void add(int i, T v) {
        for (int k = i + 1; k <= n; k += k & -k) b[k] ^= v;
    }
    T sum(int k) {
        T s = 0;
        for (; k > 0; k -= k & -k) s ^= b[k];
        return s;
    }
    vector<T> b;
    int n;
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, q;
    cin >> n >> q;

    BIT<int> bt(n);

    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        bt.add(i, a);
    }

    while (q--) {
        int t, x, y;
        cin >> t >> x >> y;
        x--;

        if (t == 1) {
            bt.add(x, y);
        } else {
            cout << (bt.sum(y) ^ bt.sum(x)) << '\n';
        }
    }

    return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long, long long>
using namespace std;

const int mod = 1e9+7;
#define INF INT_MAX

int main()
{
	int n,m;
	cin>>n>>m;
	vector<pll> xs[n+1];
	for(int i =0;i<m;i++)
	{
		int x,y,z;
		cin>>x>>y>>z;
		xs[x].pb({y,z});
	}
	vector<ll> dp(1<<n);
	vector<bool> ok(1<<n,1);
	for(int i = 1; i < 1<<n; i++)
	{
		int subsetsize = __builtin_popcount(i);
		for(auto [y,z] : xs[subsetsize])
		{
			int count = 0;
			for(int j = 1; j <= n;j++)
			{
				if(i&(1<<(j-1)) && j <= y)
					count++;

			}
			if(count > z)
			{
				ok[i] = 0;
				break;
			}
		}
	}
	dp[0] = 1;
	for (int i = 0; i < 1<<n; i++)
	{
		if(!ok[i])
			dp[i] = 0;
		for(int b = 0; b < n; b++)
		{
			if(!((1<<b)&i))
			{
				int nextid = i | (1<<b);
				dp[nextid] += dp[i];

			}
		}
	}
	cout<<dp[(1<<n)-1]<<"\n";

}