//#pragma GCC optimize(3)
#include <random>
#include <stdio.h>
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<int, int> pii;
#define Continue(x) { x; continue; }
#define Break(x) { x; break; }
#define Return(x) { x; return; }
#define P2(x) ((x) * (x))
#define lowbit(x) ((x) & -(x))
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define MEM(x, y) memset((x), (y), sizeof(x))
#define MEN(x, y, z) memset((x), (y), sizeof((x)[0]) * (z))
#define Diz(x) (lower_bound(dz.begin(), dz.end(), (x)) - dz.begin())
#define DISCRETIZA(x) (x).push_back(-INF), sort((x).begin(), (x).end()), (x).erase(unique((x).begin(), (x).end()), (x).end())
#ifdef LOCAL
#define DEBUG(...) cout << ">> " << #__VA_ARGS__ << " =", PRT(__VA_ARGS__), cout << endl;
#define DEBUGS(...) cout << ">> " << #__VA_ARGS__ << " =", PRTS(__VA_ARGS__), cout << endl;
void PRT() {} template <typename S, typename... T> void PRT(S x, T ... y){ cout << " " << x; PRT(y...); }
void PRTS() {} template <typename S> void PRTS(S x) { for (auto v : x) cout << " " << v; }
#define TIME cout << "RunTime: " << clock() << "ms\n", 0
#define __int128_t long long
#else
#define DEBUG(...) ;
#define DEBUGS(...) ;
#define TIME 0
#endif

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
template<typename S, typename T> inline bool Min(S &a, const T &b){ return a > b ? a = b, true : false; }
template<typename S, typename T> inline bool Max(S &a, const T &b){ return a < b ? a = b, true : false; }
template<typename S, typename T> inline void Adm(S &a, const T &b){ a = (a + b) % MOD; if (a < 0) a += MOD; }
template<typename S, typename T> inline void Mum(S &a, const T &b){ a = 1LL * a * b % MOD; }
template<typename T> inline bool IsPri(T x) { if (x < 2) return false; for (T i = 2; i * i <= x; ++i) if (x % i == 0) return false; return true; }
template<typename T> inline T Gcd(T a, T b){ while (b){ T t = b; b = a % b; a = t; } return a; }
template<typename T> inline int BitCnt(T x){ int cnt = 0; while (x)++cnt, x &= x - 1; return cnt; }
template<typename T> inline T MDis(T x1, T y1, T x2, T y2){ return abs(x1 - x2) + abs(y1 - y2); }
template<typename T> inline T MDis(T x1, T y1, T z1, T x2, T y2, T z2){ return abs(x1 - x2) + abs(y1 - y2) + abs(z1 - z2); }
inline double EDis(double x1, double y1, double x2, double y2){ return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
inline double EDis(double x1, double y1, double z1, double x2, double y2, double z2){ return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + (z1 - z2) * (z1 - z2)); }
inline ll Pow(ll a, ll n) { ll t = 1; a %= MOD; while (n) { if (n & 1) t = t * a % MOD; a = a * a % MOD, n >>= 1; } return t % MOD; }
#define gc p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2) ? EOF : *p1++;
inline int read(){ static char buf[1000000], *p1 = buf, *p2 = buf; register int x = false; register char ch = gc; register bool sgn = false; while (ch != '-' && (ch < '0' || ch > '9')) ch = gc; if (ch == '-') sgn = true, ch = gc; while (ch >= '0'&& ch <= '9') x = (x << 1) + (x << 3) + (ch ^ 48), ch = gc; return sgn ? -x : x; }
//emplace unordered 能ll就开 函数内判非法

ll n, k;
ll calc(ll y) //计算n范围内以y为最高二进制位的数字数量
{
	ll res = 0, w = 1;
	while (y <= n) //枚举二进制长度
	{
		res += min(w, n - y + 1); //变化量和n限制取min
		y <<= 1, w <<= 1;
	}
	return res;
}
ll solve(ll y)
{
	ll res = calc(y);
	if (!(y & 1)) //如果y为偶数 可以从奇数过来
		res += calc(y + 1);
	return res;
}
int main()
{
#ifdef LOCAL
	//freopen("C:/input.txt", "r", stdin);
	//freopen("C:/output.txt", "w", stdout);
#endif
	//二分满足单调性 calc(x) >= calc(x + 2) 分奇偶二分答案
	cin >> n >> k;
	ll l = 1, r = n / 2, ans = 0; //偶数
	while (l <= r)
	{
		ll mid = l + r >> 1;
		if (solve(mid * 2) >= k) //*2
			Max(ans, mid * 2), l = mid + 1;
		else
			r = mid - 1;
	}
	l = 1, r = (n + 1) / 2; //奇数
	while (l <= r)
	{
		ll mid = l + r >> 1;
		if (solve(mid * 2 - 1) >= k) //*2-1
			Max(ans, mid * 2 - 1), l = mid + 1;
		else
			r = mid - 1;
	}
	cout << ans << endl;

	return TIME;
}


#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

ll n, k;
ll dp[2500][2500];
ll ans2;

bool dfs (vector<int>& v, ll K) {
    int sum = 0;
    for (int i : v) sum += i;
    if (sum > n) return 0;
    if (K <= 1) return 1;
    vector<int> nxt;
    int t = 0;
    for (int i = (int)v.size()-1; i >= 0; i--) {
        t++;
        rep(j,v[i]) nxt.push_back(t);
    }
    return dfs(nxt, K-1);
}

void hoge (vector<int>& v) {
    for (int i = v.size()==0?1:v.back(); ; i++) {
        v.push_back(i);
        if (!dfs(v, k)) {
            v.pop_back();
            break;
        }
        ans2++;
        hoge(v);
        v.pop_back();
    }
}

int main() {
    scanf("%lld%lld", &n, &k);
    if (k == 1) {
        dp[1][1] = 1;
        ll ans = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++) {
                dp[i][j] = (dp[i][j] + dp[i-1][j-1] + dp[i-j][j]) % MOD;
                ans = (ans + dp[i][j]) % MOD;
            }
        }
        printf("%lld\n", ans);
        return 0;
    }
    if (k == 2) {
        dp[1][1] = 1;
        ll ans = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++) {
                dp[i][j] = (dp[i][j] + dp[i-j][j-1]) % MOD;
                if (i >= j*(j+1)/2) dp[i][j] = (dp[i][j] + dp[i-j*(j+1)/2][j]) % MOD;
                ans = (ans + dp[i][j]) % MOD;
            }
        }
        printf("%lld\n", ans);
        return 0;
    }
    vector<int> v;
    hoge(v);
    printf("%lld\n", ans2);
}


#include<iostream>
#include<fstream>
#include<vector>
#include<ctime>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define per(i,b,a) for(int i = (b); i >= (a); i--)
#define ll long long
#define mod 998244353
#define N 200022
#define B 400
using namespace std;

int n, k;
int mu[N], prime[N], siz;
bool vis[N];
ll fact[N], invf[N];
ll S[B+2][B+2], val[N], sum[N];

ll qpow(ll a, int b){
    ll ret = 1;
    for(; b; b >>= 1){ if(b&1) (ret *= a) %= mod; (a *= a) %= mod; }
    return ret;
}

void init(){
    fact[0] = 1;
    rep(i,1,n) fact[i] = fact[i-1] * i % mod;
    invf[n] = qpow(fact[n], mod-2);
    per(i,n-1,0) invf[i] = invf[i+1] * (i+1) % mod;

    sum[0] = 1;
    rep(i,1,n) sum[i] = (sum[i-1] + (i&1 ? mod-1 : 1) * invf[i]) % mod;

    S[0][0] = 1;
    int siz = min(n, B);
    rep(i,1,siz){
        val[i] = mod-1;
        rep(j,1,i){
            S[i][j] = (j * S[i-1][j] + S[i-1][j-1]) % mod;
            if(j <= k) (val[i] += S[i][j]) %= mod;
        }
    }
}

void euler(){
    mu[1] = 1;
    rep(i,2,n){
        if(!vis[i]) mu[i] = -1, prime[++siz] = i;
        for(int j = 1; j <= siz && i * prime[j] <= n; j++){
            int v = i * prime[j];
            vis[v] = true;
            if(i % prime[j] == 0){ mu[v] = 0; break; }
            mu[v] = -mu[i];
        }
    }
}

ll cal(int n){
    if(val[n]) return val[n];
    ll ret = mod-1;
    per(i,min(n,k),0) (ret += qpow(i, n) * invf[i] % mod * sum[min(n,k)-i]) %= mod;
    return val[n] = ret;
}

int main(){
    cin>>n>>k;
    if(n == 1 || k == 1){ cout<<"1\n"; return 0; }

    init(), euler();
    ll ans = 0;
    rep(i,1,n) if(mu[i])
        (ans += (mod + mu[i]) * cal((n+i-1)/i)) %= mod;
    cout<< ans <<endl;
    return 0;
}


// luogu-judger-enable-o2
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
    int T,n,i;
    scanf("%d",&T);
    while(T--){
        scanf("%d",&n);
        if(n%3==0||n%7==0){
            printf("YES\n");continue;
        }
        for(i=1;i*3<=n;i++){
            if((n-i*3)%7==0){
                printf("YES\n");break;
            }
        }
        if(i*3<=n)continue;
        for(i=1;i*7<=n;i++){
            if((n-i*7)%3==0){
                printf("YES\n");break;
            }
        }
        if(i*7<=n)continue;
        printf("NO\n");
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef vector<int> Poly;

const int N = 4333;
const int MOD = 998244353;

namespace {
  int inv[N], fac[N], ifac[N], pw2[N];

  int Add(int a, int b) {
    return (a += b) >= MOD? a - MOD : a;
  }
  int Sub(int a, int b) {
    return (a -= b) < 0? a + MOD : a;
  }
  int Mul(int a, int b) {
    return (long long)a * b % MOD;
  }
  int Inv(int a) {
    return (a == 1)? 1 : Mul(MOD - MOD / a, Inv(MOD % a));
  }
  int Ch(int a, int b) {
    if (a < b) return 0;
    return Mul(fac[a], Mul(ifac[b], ifac[a - b]));
  }
  int Pow(int a, int b) {
    int r = 1;
    for (; b; b >>= 1) {
      if (b & 1) {
        r = Mul(r, a);
      }
      a = Mul(a, a);
    }
    return r;
  }

  void Math_init() {
    inv[1] = 1;
    for (int i = 2; i < N; ++i) {
      inv[i] = Mul(MOD - MOD / i, inv[MOD % i]);
    }
    fac[0] = ifac[0] = pw2[0] = 1;
    for (int i = 1; i < N; ++i) {
      fac[i] = Mul(fac[i - 1], i);
      ifac[i] = Mul(ifac[i - 1], inv[i]);
      pw2[i] = Add(pw2[i - 1], pw2[i - 1]);
    }
  }
}

namespace PO {
  int rev[N * 4], w[N * 4], L = 1;

  void Init(int l) {
    for (; L < l; L <<= 1) {
      int wn = Pow(3, (MOD - 1) / (L << 1));
      for (int i = L; i < (L << 1); ++i) {
        w[i] = (i == L)? 1 : Mul(w[i - 1], wn);
      }
    }
    for (int i = 0; i < l; ++i) {
      rev[i] = (rev[i >> 1] >> 1) | (i & 1? l >> 1 : 0);
    }
  }

  void Dft(Poly &a, int l) {
    for (int i = 0; i < l; ++i) {
      if (i < rev[i]) {
        swap(a[i], a[rev[i]]);
      }
    }
    for (int i = 1, y; i < l; i <<= 1) {
      for (int j = 0; j < l; j += i << 1) {
        int *l = &a[j], *r = l + i, *wx = w + i;
        for (int k = 0; k < i; ++k, ++l, ++r, ++wx) {
          y = Mul(*r, *wx);
          *r = Sub(*l, y);
          *l = Add(*l, y);
        }
      }
    }
  }

  void Idft(Poly &a, int l) {
    reverse(a.begin() + 1, a.end());
    Dft(a, l);
    int il = Inv(l);
    for (int i = 0; i < l; ++i) {
      a[i] = Mul(a[i], il);
    }
  }

  Poly Poly_mul(Poly a, Poly b) {
    int n = a.size(), m = b.size(), l;
    for (l = 1; l < n + m - 1; l <<= 1);
    Init(l);
    a.resize(l);
    Dft(a, l);
    b.resize(l);
    Dft(b, l);
    for (int i = 0; i < l; ++i) {
      a[i] = Mul(a[i], b[i]);
    }
    Idft(a, l);
    a.resize(n + m - 1);
    return a;
  }

}

int main() {
  Math_init();

  int n, k, l;
  cin >> n >> k >> l;

  Poly AL(n + 1), AR(n + 1);
  for (int j = k; j <= n; ++j) {
    AL[j] = ifac[j];
  }
  for (int j = 0; j <= n; ++j) {
    AR[j] = (j & 1)? Sub(0, ifac[j]) : ifac[j];
  }
  Poly A = PO::Poly_mul(AL, AR);
  A.resize(n + 1);
  for (int i = 0; i <= n; ++i) {
    A[i] = Mul(A[i], Mul(fac[n], ifac[n - i]));
  }

  int ans = 0;
  for (int i = k; i <= n * 2; ++i) {
    int tmp = 0;
    for (int j = k; j <= min(i, n); ++j) {
      tmp = ((i - j) & 1? Sub : Add)(tmp, Mul(Mul(A[j], pw2[j]), Ch(j, i - j)));
    }
    ans = Add(ans, Mul(tmp, inv[i + 1]));
  }
  printf("%d\n", Mul(ans, l));

  return 0;
}


#include <bits/stdc++.h>

typedef long long s64;

const int mod = 998244353;
const int MaxN = 1e6 + 5;

int n, ans;
int fac[MaxN], inv[MaxN], pw[MaxN], f[MaxN];

inline void add(int &x, const int &y)
{
	x += y;
	x >= mod ? x -= mod : 0;
	x < 0 ? x += mod : 0;
}

inline int qpow(int a, s64 b)
{
	int res = 1;
	for (; b; b >>= 1, a = 1LL * a * a % mod)
		if (b & 1)
			res = 1LL * res * a % mod;
	return res;
}

inline int C(int n, int m)
{
	if (n < 0 || m < 0 || n < m)
		return 0;
	return 1LL * fac[n] * inv[m] % mod * inv[n - m] % mod;
}

int main()
{
//	freopen("matrix.in", "r", stdin);
//	freopen("matrix.out", "w", stdout);

	std::cin >> n;

	pw[0] = fac[0] = 1;
	for (int i = 1; i <= n; ++i)
	{
		pw[i] = 3LL * pw[i - 1] % mod;
		fac[i] = 1LL * fac[i - 1] * i % mod;
	}
	inv[n] = qpow(fac[n], mod - 2);
	for (int i = n - 1; i >= 0; --i)
		inv[i] = 1LL * inv[i + 1] * (i + 1) % mod;

	int ind = qpow(pw[n], mod - 2);
	for (int i = 1; i <= n; ++i)
	{
		int tmp = 1LL * pw[i] * ind % mod;
		int res = qpow((tmp + mod - 1) % mod, n);
		if (n & 1)
			res = ((s64)mod * 2 - res - 1) % mod;
		else
			res = (res + mod - 1) % mod;
		res = 1LL * res * (i & 1 ? 1 : -1) * C(n, i) % mod * qpow(3, 1LL * n * (n - i) + 1) % mod;
		add(ans, res);
	}

	for (int i = 1; i <= n; ++i)
	{
		int type = i & 1 ? 1 : -1;
		int res = C(n, i);
		add(ans, 1LL * type * qpow(3, 1LL * n * (n - i) + i) % mod * res % mod);
		add(ans, 1LL * type * qpow(3, 1LL * n * (n - i) + i) % mod * res % mod);
	}

	std::cout << ans << std::endl;

	fclose(stdin);
	fclose(stdout);
	return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>

struct Vertex {
	bool init;
	std::string s; //name of initial var or operator
	Vertex *lhs, *rhs;

	bool calced;
	std::string ssa;

	Vertex(): init(false), lhs(nullptr), rhs(nullptr), calced(false), ssa("") {}
	friend bool operator== (const Vertex &a, const Vertex &b) {
		return
			(a.init == b.init) &&
			(a.s == b.s) &&
			(a.lhs == b.lhs) &&
			(a.rhs == b.rhs)
		;
	}
};

std::set<std::string> initS;
std::string nextSSA = "acaa";

std::string get_ssa() {
	while (true) {
		nextSSA[0]++;
		for (uint32_t i = 0;i < nextSSA.size();i++) {
			if (nextSSA[i] > 'z') {
				nextSSA[i + 1]++;
				nextSSA[i] = 'a';
			}
		}
		if (initS.find(nextSSA) == initS.end()) {
			break;
		}
	}
	return nextSSA;
}

const uint32_t MAX_V = 5000;

Vertex vertMem[MAX_V];
Vertex *vertPtr = vertMem;

std::map<std::string, Vertex*> curV;

Vertex *get_vertex() {
	return vertPtr++;
}
Vertex *get_vertex(const std::string &s) {
	auto it = curV.find(s);
	if (it == curV.end()) {
		Vertex *ans = get_vertex();

		ans->ssa = s;
		ans->init = true;
		initS.insert(s);
		std::cerr << "Vertex " << ans - vertMem << " initial " << s << "\n";

		curV[s] = ans;
		return ans;
	} else {
		return it->second;
	}
}

std::vector<std::string> rawP;

void input() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	uint32_t n;
	std::cin >> n;
	rawP.resize(n);
	for (std::string &s : rawP) {
		std::cin >> s;
	}
}

bool is_opr(char c) {
	return (c == '$') || (c == '^') || (c == '#') || (c == '&') || (c == '=');
}

std::vector<std::string> tokenize(const std::string &s) {
	std::vector<std::string> ans;
	std::string curS = "";
	bool op = false;
	for (uint32_t i = 0;i < s.size();i++) {
		bool curOp = is_opr(s[i]);
		if (op == curOp) {
			curS += s[i];
		} else {
			ans.push_back(curS);
			op = curOp;
			curS = s[i];
		}
	}
	ans.push_back(curS);
	return ans;
}

void build_dag() {
	for (const std::string &s : rawP) {
		auto l = tokenize(s);

		if (l.size() == 3) { // assignment
			Vertex *v = get_vertex(l[2]);
			curV[l[0]] = v;
		} else { //operation
			Vertex *v = get_vertex();
			v->s = l[3];
			v->lhs = get_vertex(l[2]);
			v->rhs = get_vertex(l[4]);

			for (Vertex *u = vertMem;u != vertPtr;u++) {
				if ((*u) == (*v)) {
					if (v == u) {
						std::cerr << "vertex " << u - vertMem << ": ";
						std::cerr << "lhs " << u->lhs - vertMem;
						std::cerr << " opr " << u->s;
						std::cerr << " rhs " << u->rhs - vertMem << "\n";

					}
					curV[l[0]] = u;
					break;
				}
			}
		}
	}
}

std::vector<std::string> optP;

void build_program(Vertex *v) {
	if ((v->calced) || (v->init)) {
		return;
	} else {
		build_program(v->lhs);
		build_program(v->rhs);
		if (v->ssa.empty()) {
			v->ssa = get_ssa();
		}
		optP.push_back(v->ssa + "=" + v->lhs->ssa + v->s + v->rhs->ssa);
		v->calced = true;
	}
}

int main() {
	input();
	build_dag();
	auto it = curV.find("res");
	if (it != curV.end()) {
		if ((it->second->init) && (it->second->ssa != "res")) {
			optP.push_back("res=" + it->second->ssa);
		} else {
			it->second->ssa = "res";
			build_program(it->second);
		}
	}
	std::cout << optP.size() << "\n";
	for (const std::string &s : optP) {
		std::cout << s << "\n";
	}
}


#include <stdio.h>

int main(){
    int num, base = 0, aux, i = 1, extra;
    scanf("%d", &num);

    do{
        aux = 5*i;
        if(aux + base < num){
            base += aux;
            i *= 2;
        }
    }while(aux + base < num);

    extra = num - base;

    if(num <= base + i){
        printf("Sheldon\n");
    }
    else if(num <= base + (i * 2)){
        printf("Leonard\n");
    }
    else if(num <= base + (i * 3)){
        printf("Penny\n");
    }
    else if(num <= base + (i * 4)){
        printf("Rajesh\n");
    }
    else if(num <= base + (i * 5)){
        printf("Howard\n");
    }

    return 0;
}


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

using namespace std;

	const int N = 100000;
	int temp[N + 1];
	vector <int> prime;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;
	cin >> n;

	bool flag = true;
	for (int i = 2; i*i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = false;
		}
	}

	if (flag)
	{
		cout << 1 << "\n" << n;
		return 0;
	}

	flag = true;
	for (int i = 2; i*i <= n - 2; i++)
	{
		if ((n - 2) % i == 0)
		{
			flag = false;
		}
	}

	if (flag)
	{
		cout << 2 << "\n" << 2 << " " << n - 2;
		return 0;
	}

	cout << 3 << endl;

	int up = min(n - 1, N);

	for (int i = 2; i <= up; i++)
	{
		if (temp[i] == 0)
		{
			temp[i] = i;
			prime.push_back(i);
		}
		for (int j = 0; j < prime.size() && prime[j] <= temp[i] && i * prime[j] <= up; j++)
		{
			temp[i * prime[j]] = prime[j];
		}
	}

	vector <bool> check(up + 1, false);

	for (int i = 0; i < prime.size(); i++)
	{
		check[prime[i]] = true;
	}

	for (int x = n - 3; ;x--)
	{
		bool pr = true;
		for (int i = 2; i*i <= x; i++)
		{
			if (x % i == 0)
			{
				pr = false;
				break;
			}
		}
		if (pr)
		{
			cout << x << " ";
			n -= x;
			break;
		}
	}

	for (int i = 0; i < prime.size(); i++)
	{
		if (check[n - prime[i]])
		{
			cout << prime[i] << " " << n - prime[i];
			return 0;
		}
	}

	return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,c[23][23],d[23],u[23];
main() {
    scanf("%d%d", &n, &m);
    for (int xt,yt,i = 1; i <= m; ++i) {
        scanf("%d%d", &xt, &yt);
        if (c[xt][yt] || xt == yt) continue;
        ++d[xt], ++d[yt];
        c[xt][yt] = c[yt][xt] = 1;
    }
    for (int j,co,p,mint,i = 1; i <= n; ++i) {
        fill(u, u + n + 1, 0);
        co = 0;
        for (j = i; !u[j]; j = p) {
            mint = n+n;
            p = j;
            u[j] = 1;
            ++co;
            for (int k = 1; k <= n; ++k)
                if (!u[k] && c[j][k] && (d[k] < mint || d[k] == mint && k < p))
                    p = k, mint = d[k];
        }
        if (co == n) {puts("Yes");return 0;}
    }
    puts("No");
}


#include <iostream>
#include <math.h>
#include <bits/stdc++.h>

using namespace std;

const int LIMIT = 1000000;

typedef pair<int, int> PII;
PII p[LIMIT];
vector<PII> v;

inline bool pr(const PII& lhs, const PII& rhs) {
  return atan2(lhs.second, lhs.first) < atan2(rhs.second, rhs.first) - 1e-8;
}

inline int R(const PII& p) { return p.first * p.first + p.second * p.second; }

int main() {
  int n, s, x, y, nx, ny, tx, ty, dx, dy;

  scanf("%d", &n);
  for (int i = 0, ii; (ii = i * i) < LIMIT; ++i) {
    for (int j = i, jj; (jj = i * i + j * j) < LIMIT; ++j) {
      p[jj].first = i;
      p[jj].second = j;
    }
  }

  s = 0;
  for (int i = 0; i < LIMIT && (int)v.size() <= n; ++i) {
    if (p[i].first != 0 || p[i].second != 0) {
      s += R(p[i]);
      v.push_back(p[i]);
    }
  }

  reverse(v.begin(), v.end());
  for (vector<PII>::iterator it = v.begin(); it != v.end(); ++it) {
    if ((s - R(*it)) % 2 == 0) {
      v.erase(it);
      break;
    }
  }

  x = y = 0;
  for (vector<PII>::iterator it = v.begin(); it != v.end(); ++it) {
    nx = ny = LIMIT;
    dx = it->first;
    dy = it->second;
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j < 2; ++j) {
        for (int k = 0; k < 2; ++k) {
          tx = x + dx;
          ty = y + dy;
          if (abs(tx) + abs(ty) < abs(nx) + abs(ny)) {
            nx = tx;
            ny = ty;
            *it = make_pair(dx, dy);
          }
          dx = -dx;
        }
        dy = -dy;
      }
      swap(dx, dy);
    }
    x = nx;
    y = ny;
  }

  sort(v.begin(), v.end(), pr);
  x = y = 0;
  puts("YES");
  for (vector<PII>::iterator it = v.begin(); it != v.end(); ++it) {
    printf("%d %d\n", x, y, atan2(it->second, it->first));
    x += it->first;
    y += it->second;
  }
  if (x != 0 || y != 0) {
    throw 1;
  }

  return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

int main() {
    int n, m, d;
    std::cin >> n >> d;
    std::vector<int> a(n);
    for (auto &e: a) {
        std::cin >> e;
    }
    std::cin >> m;
    std::sort(a.begin(), a.end());
    int ans = 0;
    if (m > n) {
        for (auto &e :a) {
            ans += e;
        }
        ans -= (m - n) * d;
    } else {
        for (int i = 0; i < m; ++i) {
            ans += a[i];
        }
    }

    std::cout << ans;
}


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

int main(int argc, char** argv) {
    ios_base::sync_with_stdio(false);
#ifdef IN_FILE
    ifstream in_file(argv[1]);
    auto sbuf = cin.rdbuf(in_file.rdbuf());
#endif

    int n;
    cin >> n;
    string s(to_string(n));
    vector<int> nl;
    while (1) {
        string ns;
        bool zeros = true;
        for (int i = 0; i < s.length(); ++i) {
            if (s[i] > '0') {
                ns += '1';
                s[i] -= 1;
                zeros = false;
            } else {
                ns += '0';
            }
        }

        if (zeros) {
            break;
        }

        nl.push_back(stoi(ns));
    }

    cout << nl.size() << "\n";
    copy(nl.begin(), nl.end(), ostream_iterator<int>(cout, " "));
    cout << endl;

#ifdef IN_FILE
    cin.rdbuf(sbuf);
    in_file.close();
#endif

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+10,mod=1e9+7;
int a[maxn],b[maxn],c[maxn],vis[maxn],cur[maxn],x,d,n;
int getNextX() {
    x = (1ll*x * 37 + 10007) % 1000000007;
    return x;
}
void initAB() {
	int i;
    for(i = 0; i < n; i = i + 1){
        a[i] = i + 1;
    }
    for(i = 0; i < n; i = i + 1){
        swap(a[i], a[getNextX() % (i + 1)]);
    }
    for(i = 0; i < n; i = i + 1){
        if (i < d)
            b[i] = 1;
        else
            b[i] = 0;
    }
    for(i = 0; i < n; i = i + 1){
        swap(b[i], b[getNextX() % (i + 1)]);
    }
}
struct node
{
	int v,id;
	node(int x,int y){v=x,id=y;}
	bool operator<(const node&t)const
	{
		return v<t.v;
	}
};
priority_queue<node>q;
int main()
{
	scanf("%d%d%d",&n,&d,&x);
	initAB();
	int cnt=0;
	for(int i=0;i<n;i++)
	if(b[i])cur[cnt++]=i;
	for(int i=0;i<n;i++)
	q.push(node(a[i],i));
	for(int i=0;i<min(70,n);i++)
	{
		node e=q.top();q.pop();
		for(int j=0;j<cnt;j++)
		if(e.id+cur[j]<n&&!vis[e.id+cur[j]])
		{
			vis[e.id+cur[j]]=1;
			c[e.id+cur[j]]=e.v;
		}
	}
	for(int i=0;i<n;i++)
	if(!vis[i])
	{
		for(int j=0;j<cnt&&cur[j]<=i;j++)
		c[i]=max(c[i],a[i-cur[j]]);
	}
	for(int i=0;i<n;i++)
	printf("%d\n",c[i]);
}
	 	 	 	 	 			 	    									  	//hellobig_tq//hello//hello


#include <iostream>
#include <cstdlib>
#include <string>
#include <math.h>

using namespace std;

long long perevod (int n, int *ax, int x)
{
    long long res=0;
    int t=n;
    for (int i=0;i<t;i++)
    {
        n--;
        res+=(pow((double)x,(double)n)*ax[i]);
    }
    return res;
}

int main()
{
    int n,x,i,n2,y;
    string str="", str2="";
    int ax[100], by[100];
    cin>>n>>x;
    for (i=0;i<n;i++)
    {
        cin>>ax[i];
    }
    cin>>n2>>y;
    for (i=0;i<n2;i++)
    {
        cin>>by[i];
    }
    long long res1=perevod(n,ax,x);
    long long res2=perevod(n2,by,y);
    if (res1<res2) cout<<'<';
    else if (res1>res2) cout<<'>';
    else cout<<'=';
}


#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int dp[505][505];
string s;
int helper(int i,int j)
{ if(i==j)
    return 1;
     if(i>j)
    return 0;
    if(dp[i][j]!=-1)
    return dp[i][j];

    dp[i][j]=1000;
    dp[i][j]=min(dp[i][j],1+helper(i+1,j));
    int k;
    for(k=i+1;k<=j;k++)
    {
        if(s[k]==s[i])

        dp[i][j]=min(dp[i][j],helper(i+1,k-1)+helper(k,j));
    }
return dp[i][j];

}
int main()
{
    int n,i,j;

    cin>>n>>s;
    memset(dp, -1, sizeof dp);
    cout<<helper(0,n-1);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;

long long b,s,c,nb,nc,ns,pb,pc,ps,money;
bool check(long long mid){
	long long n=0;
	if(mid*b>nb)n+=(mid*b-nb)*pb;
	if(mid*s>ns)n+=(mid*s-ns)*ps;
	if(mid*c>nc)n+=(mid*c-nc)*pc;
	return n<=money;
}
int main() {
	char a[110];
	cin>>a+1;
	long long len=strlen(a+1);
	cin>>nb>>ns>>nc;
	cin>>pb>>ps>>pc;
	cin>>money;
	for(long long i=1;i<=len;i++){
		if(a[i]=='B')b++;
		else if(a[i]=='C')c++;
		else s++;
	}
	long long l=0,r=money+max(nb,max(nc,ns));
	while(l<=r){
		long long mid=l+r>>1;
		if(check(mid)){
			l=mid+1;
		}
		else r=mid-1;
	}
	printf("%lld",r);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a[100],n,i,j,b=0,c,d;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        b=b+a[i];
    }

    b=b/(n/2);

    for(i=0; i<n-1; i++)
    {
        for(j=i+1; j<=n; j++)
        {
            if(a[i]+a[j]==b)
            {
                cout<<i+1<<" "<<j+1<<endl;
                a[j]=0;
                a[i]=0;

            }

        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;

ull bad(ull n, ull m) {
	vector<ull> dp(n+2);
	ull total = 0;
	dp[1] = 1;
	dp[2] = 2;
	total = 3;

	for (int i = 3; i <= n; i++) {
		dp[i] = (total)%m;

		for (int j = 2; j <= i; j++) {
			dp[i] = (dp[i]+ dp[i/j])%m;
		}

		total = (total+dp[i]) % m;
	}

	return dp[n];
}
ull good(ull n, ull m) {
	vector<ull> dp(n+2);
	ull total = 0;
	dp[1] = 1;
	dp[2] = 2;
	total = 3;

	for (ull i = 3; i <= n; i++) {
		dp[i] = total;

		ull s = sqrt(i)+1;
		for (ull j = 1; j <= s; j++) {
			if (j*j < i) {
				dp[i] = (dp[i] + ((i/j-i/(j+1))*dp[j]))%m;
			}
			if (j > 1 && ((i/j)*(i/j)) >= i) {
				dp[i] = (dp[i] + dp[i/j])%m;
			}
		}

		total = (total+dp[i]) % m;
	}

	return dp[n];
}

int main() {
	ull n, m; cin >> n >> m;
	cout << good(n, m) << endl;
}


#include <iostream>

using namespace std;

int main(){

    long long l1,l2,r1,r2,k;
    cin>>l1>>r1>>l2>>r2>>k;

    long long lmax,rmin;

    if(l1>l2){
        lmax=l1;
    }
    else{
        lmax=l2;
    }

    if(r1>r2){
        rmin=r2;
    }
    else{
        rmin=r1;
    }

    long long ln;

    //cout<<lmax<<" "<<rmin;

    if(rmin>=lmax){
        ln = rmin - lmax + 1;
    }
    else{
        ln=0;
    }

    if(k>=lmax && k<=rmin &&ln>0){
        ln=ln-1;
    }

    cout<<endl<<ln;

}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int n;
char original1[15][15],original2[15][15],temp[15][15];
bool check;

void theSame(char table[15][15]){
	bool tempCheck=true;

	for(int i=0; i<n && tempCheck; i++){
		for(int j=0; j<n && tempCheck; j++){
			if(table[i][j]!=original2[i][j]){
				tempCheck=false;
			}
		}
	}
	if(tempCheck){
		check=true;
	}
}

void turnLeft(char table[15][15]){
	char T[15][15];
	int tempi, tempj;

	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			tempi=j;
			tempj=-1*i+n-1;
			T[tempi][tempj]=table[i][j];
		}
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			temp[i][j]=T[i][j];
		}
	}
	theSame(temp);
}

void flipX(char table[15][15]){
	char T[15][15];
	int tempi,tempj;

	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			tempi=i;
			tempj=n-1-j;
			T[tempi][tempj]=table[i][j];
		}
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			temp[i][j]=T[i][j];
		}
	}
	theSame(temp);
}

void flipY(char table[15][15]){
	char T[15][15];
	int tempi,tempj;

	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			tempi=n-1+(-1*i);
			tempj=j;
			T[tempi][tempj]=table[i][j];
		}
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			temp[i][j]=T[i][j];
		}
	}
	theSame(temp);
}

int main(int argc, char** argv) {

	while(scanf(" %d",&n)==1){
		for(int i=0; i<n; i++){
			scanf(" %s",original1[i]);
		}

		for(int i=0; i<n; i++){
			scanf(" %s",original2[i]);
		}

		check=false;
		theSame(original1);
		turnLeft(original1);
		turnLeft(temp);
		turnLeft(temp);
		flipX(original1);
		turnLeft(temp);
		turnLeft(temp);
		turnLeft(temp);
		flipX(original1);
		flipY(temp);
		turnLeft(temp);
		turnLeft(temp);
		turnLeft(temp);
		if(check){
			cout<<"Yes"<<endl;
		}
		else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}


#include <iostream>
int main()
{
    int a, b;
    std::cin >> a >> b;
    std::cout << (a == b ? a : 2) << std::endl;
    return 0;
}


#include<cstdio>
using namespace std;
int main()
{
    long long x,ct=0,a,b,aux;
    scanf("%lld",&x);
    a=2;
    ct=2;b=3;
    if(x<3) printf("1");
    else if(x<5) printf("2");
    else {
            while(x>=b)
    {
        ct++;
        aux=a;a=b;b=b+aux;
    }
    printf("%lld",ct-1);
    }
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
	int n; scanf("%d", &n);
	int baseSize = 1;
	while (2 * baseSize + 1 <= n) baseSize = baseSize * 2 + 1;
	vector<int> color(baseSize + 1);
	for (int i = 2; i <= baseSize; ++i) color[i] = color[i >> 1] ^ (~i & 1);
	int k = 0;
	for (int i = 1; i <= baseSize / 2; ++i) {
		int nextLeaf = i * 2 + 1;
		while (2 * nextLeaf <= baseSize) nextLeaf = 2 * nextLeaf;
		if (color[nextLeaf] == color[i]) ++k;
	}
	if (n == k + baseSize || n == k + baseSize + 1) printf("1\n");
	else printf("0\n");
	return 0;
}


#include <iostream>
#include <map>
#include <algorithm>
#include <iterator>
#include <vector>
#include <math.h>
using namespace std;
#define ll long long
#define the_num 1000000007
#define ano_num 998244353
#define forn(n) for(int i=0;i<n;i++)
#define forr(i,start_i,n) for(int i=start_i;i<n;i++)
#define forrr(i,start_i,n) for(int i=n-1;i>=0;i--)
#define test int t;cin >> t;while(t--)
#define all(v) v.begin(),v.end()
#define in_arr(arr,n) int arr[n];forn(n) cin >> arr[i];
#define invec(arr,n) vector <int> arr(n); forn(n) cin >> arr[i];
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define take(data_type,n) data_type n;cin >> n;
#define test int t;cin >> t;while(t--)
int mint = 100000000;
//cout.precision(100);
int eightno(int c)
{
    int count = 0;
    int d = abs(c);
    while (d != 0)
    {
        int rem = d % 10;
        if (rem == 8)
            count++;
        d = d / 10;
    }
    return count;

}
int main()
{
    int a; cin >> a;
    int b = 1;
    if ((eightno(a) == 2 && a%10!=8) || eightno(a)>2)
    {
        cout << "1";
    }
    else
    {
        while (eightno(a + b) != 1)
        {
            b = b + 1;
        }

        cout << b;
    }
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
typedef priority_queue <ll> pq;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define graph vector<vi>

const ll mod = 1000000007;
const ll INF = (ll)1e18;
const ll MAXN = 1000006;

ll po(ll x, ll n ){
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}

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 T=1;
    //cin >> T;
    while(T--){
        int n;
        cin>>n;
        vector<pair<int, int> > v;
        ll l,r;
        rep(i,n){
            cin>>l>>r;
            v.pb(mp(l,r));
        }
        ld ans=0, tmp, tmp1,tmp2, tmp3;
        rep_a(i,1 ,10001){
            rep_a(j,1,(1<<n)){
                tmp=1;
                tmp2=1;
               tmp3=1;
                vector<pair<int ,int> > z;
                rep(k,n){
                    if(((j>>k)&1) && (v[k].ff<=i && v[k].ss>=i)){
                        tmp*=1/(ld)(v[k].ss-v[k].ff+1);
                    }
                    else if((j>>k)&1) tmp=0;
                    else{
                        z.pb(mp(max(min(i-1, v[k].ss)-v[k].ff+1, 0), max(0, v[k].ss+1-max(i+1, v[k].ff))));
                        tmp2*=(v[k].ss-v[k].ff+1);
                        tmp3*=max(min(i-1, v[k].ss)-v[k].ff+1, 0);
                    }
                }
                if(tmp==0) continue;
                // if(tmp>0) cout<<tmp<<" "<<j<<" "<<i<<" "<<tmp2<<el;
                tmp1=0;
                if(z.size()<n-1){
                    tmp1=(tmp3/(ld)tmp2);
                }
                rep(k, z.size()){
                    // cout<<z[k].ff<<" "<<z[k].ss<<"{"<<el;
                    tmp3 = z[k].ss;
                    rep(l,z.size()){
                        if(l!=k){
                            tmp3*=z[l].ff;
                        }
                    }
                    tmp1 +=(tmp3/(ld)tmp2);
                }

                ans += (i*tmp*tmp1);
                // cout<<ans<<" "<<tmp1<<el;
                // cout<<el;
            }

            // cout<<ans<<el<<el;
        }
        cout<<fixed<<setprecision(12)<<ans<<el;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int sum(int a)
{
    int x=0;
    while(a>0)
    {
        x=x+a%10;

        a=a/10;

    }
    return x;
}
int main()
{
    int m;
    cin>>m;
    int a=sum(m);
    //cout<<a;

    if(a%4==0)
    {
        cout<<m;
        return 0;
    }
    else
    {

        int r;
        r=sum(m);

        while(r%4!=0)
        {
            m=m+1;
            r=sum(m);
        }
        cout<<m;
    }

}


// ~/BAU/ACM-ICPC/Teams/OverflowLimitExceeded/Corvus
// ~/sudo apt-get verdict Accpeted

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <memory.h>
#include <limits.h>
#include <math.h>
#include <string.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int N = 1000001;
const ll MOD = 1e9 + 7;

int main() {
	ll x2;
	scanf("%lld",&x2);

	ll mn = 1e18, c = x2;
	for(ll i=2; i*i<=c; i++)
		if(c%i==0) {
			mn = min(mn, x2-i+1);
			while(c%i==0)
				c /= i;
		}
	if(c>1) mn = min(mn, x2-c+1);

	ll ans = 1e18;
	for(ll x1=mn; x1<=x2; x1++) {
		c = x1;
		for(ll i=2; i*i<=c; i++) {
			if(c%i==0) {
				ans = min(ans, x1-i+1);
				while(c%i==0)
					c /= i;
			}
		}
		if(x1!=c && c>1) ans = min(ans, x1-c+1);
	}

	printf("%lld\n", ans);
	return 0;
}


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

int main(){
	int w,h,k;
	cin>>w>>h>>k;
	int sum=0;
	for(int i=1;i<=k;i++){
		sum+=(w+w+h+h-4);
		w-=4;
		h-=4;
	}
	cout<<sum;
	return 0;
	}


#include<bits/stdc++.h>
#include<stdio.h>
#include<vector>
#include<deque>
#include<string>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#include<set>
#define ws " "
#define nl "\n"
#define tc ll test; cin>>test; while(test--)
#define f(i, a, b) for(ll i = a; i<b; i++)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mod 1000000007
using namespace std;

#define pll pair<ll, ll>
bool compare(pll a, pll b)
{
	//for descending order replace with a.roll >b.roll
   if((a.ff < b.ff)||((a.ff==b.ff)&&a.ss<b.ss))
        return 1;
	else
		return 0;
}

/*bool compare(pll i, pll j)
{
	return (i.first<j.first)||((i.first==j.first)&&(i.second<j.second));
}*/
ll getSum(ll n)
{
   ll sum = 0;
   while (n != 0)
   {
       sum = sum + n % 10;
       n = n/10;
   }
   return sum;
}

void SieveOfEratosthenes(ll n, bool prime[], bool primesquare[], ll a[]);
ll countDivisors(ll n);
bool checkPrime(ll n);
int countFreq(string &pat, string &txt)
{
    int M = pat.length();
    int N = txt.length();
    int res = 0;

    /* A loop to slide pat[] one by one */
    for (int i = 0; i <= N - M; i++)
    {
        /* For current index i, check for
           pattern match */
        int j;
        for (j = 0; j < M; j++)
            if (txt[i+j] != pat[j])
                break;

        // if pat[0...M-1] = txt[i, i+1, ...i+M-1]
        if (j == M)
        {
           res++;
           j = 0;
        }
    }
    return res;
}
ll binaryToDecimal(ll n)
{
    ll num = n;
    ll dec_value = 0;

    // Initializing base value to 1, i.e 2^0
    ll base = 1;

    ll temp = num;
    while (temp) {
        ll last_digit = temp % 10;
        temp = temp / 10;

        dec_value += last_digit * base;

        base = (base * 2)%1000003;
    }

    return dec_value;
}

ll power(ll x, ll y, ll p)
{
    ll res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
                // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
void solve()
{
    string s;
    cin>>s;

    int i = 0;
    string st = "";

    while(s[i]!='\0')
    {

        if(s[i]=='>')
        st+="1000";
        else if(s[i]=='<')
        st+="1001";
        else if(s[i]=='+')
        st+="1010";
        else if(s[i]=='-')
        st+="1011";
        else if(s[i]=='.')
        st+="1100";
        else if(s[i]==',')
        st+="1101";
        else if(s[i]=='[')
        st+="1110";
        else
        st+="1111";

        i++;
    }

   reverse(st.begin(), st.end());
   ll ans = 0;

   f(i, 0, st.size())
   {
       if(st[i]=='1')
        ans+=power(2, i, 1000003);
 //      ans%=1000003;
   }

   cout<<ans%1000003<<nl;

}

int main()
{
    fastIO;

    //cout<<3<<nl;
  //  tc
    solve();
}

void fillPrefixSum(ll arr[], int n, ll prefixSum[])
{
    prefixSum[0] = arr[0];
    for (int i = 1; i <n; i++)
        prefixSum[i] = prefixSum[i-1] + arr[i];

}

void SieveOfEratosthenes(ll n, bool prime[], bool primesquare[], ll a[])
{
    for (ll i = 2; i <= n; i++)
        prime[i] = true;
    for (ll i = 0; i <= (n * n + 1); i++)
        primesquare[i] = false;
    prime[1] = false;

    for (ll p = 2; p * p <= n; p++) {
        if (prime[p] == true) {
            for (ll i = p * 2; i <= n; i += p)
                prime[i] = false;
        }
    }

    ll j = 0;
    for (ll p = 2; p <= n; p++) {
        if (prime[p]) {
            a[j] = p;

            primesquare[p * p] = true;
            j++;
        }
    }
}

ll countDivisors(ll n)
{
    if (n == 1)
        return 1;

    bool prime[n + 1], primesquare[n * n + 1];

    ll a[n]; // for storing primes upto n
    SieveOfEratosthenes(n, prime, primesquare, a);

    ll ans = 1;

    for (ll i = 0;; i++) {
        if (a[i] * a[i] * a[i] > n)
            break;
        ll cnt = 1; // cnt is power of prime a[i] in n.
        while (n % a[i] == 0) // if a[i] is a factor of n
        {
            n = n / a[i];
            cnt = cnt + 1; // incrementing power
        }

        ans = ans * cnt;
    }
    if (prime[n])
        ans = ans * 2;

    // Second case
    else if (primesquare[n])
        ans = ans * 3;

    // Third casse
    else if (n != 1)
        ans = ans * 4;

    return ans; // Total divisors
}

bool checkPrime(ll n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;

    for (ll i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;

    return true;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(x) x.begin(), x.end()
#define left left228
#define right right228
template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

struct triple{
	int x, y, z;
	triple() {}
	triple(int _x, int _y, int _z) {
		x = _x, y = _y, z = _z;
	}
};

int n, m, k;

vector<vector<int>> up, down, left, right, top, bottom;

void Read(vector<vector<int>> & have, int a, int b) {
	have.resize(a, vector<int> (b));
	for (auto &i : have)
		for (auto &j : i)
			cin >> j;
}

void read() {
	cin >> n >> m >> k;
	Read(left, m, k);
	Read(right, m, k);
	Read(top, n, k);
	Read(bottom, n, k);
	Read(down, n, m);
	Read(up, n, m);
}

bool operator==(const triple & a, const triple & b) {
	return tie(a.x, a.y, a.z) == tie(b.x, b.y, b.z);
}

vector<vector<vector<triple>>> par[3];
vector<vector<vector<int>>> Min[3], Max[3];

triple get_par(triple a, int it) {
	if (a == par[it][a.x][a.y][a.z]) return a;
	return par[it][a.x][a.y][a.z] = get_par(par[it][a.x][a.y][a.z], it);
}

void uni(triple a, triple b, int it) {
	a = get_par(a, it);
	b = get_par(b, it);
	if (a == b) return;
	par[it][b.x][b.y][b.z] = a;
	chkmin(Min[it][a.x][a.y][a.z], Min[it][b.x][b.y][b.z]);
	chkmax(Max[it][a.x][a.y][a.z], Max[it][b.x][b.y][b.z]);
}

void no() {
	cout << -1 << endl;
	exit(0);
}

vector<vector<vector<bool>>> used;
queue<triple> q;

int get_color(int x, int y, int z) {
	set<int> color;
	triple a;

	// get_left
	if (x != 0) {
		a = {x - 1, y, z};
		a = get_par(a, 0);
	}
	if (x == 0 || (Min[0][a.x][a.y][a.z] == 0 && used[x - 1][y][z])) {
		color.insert(left[y][z]);
	}

	// get_right
	if (x != n - 1) {
		a = {x + 1, y, z};
		a = get_par(a, 0);
	}
	if (x == n - 1 || (Max[0][a.x][a.y][a.z] == n - 1 && used[x + 1][y][z])) {
		color.insert(right[y][z]);
	}

	// get top
	if (y != 0) {
		a = {x, y - 1, z};
		a = get_par(a, 1);
	}
	if (y == 0 || (Min[1][a.x][a.y][a.z] == 0 && used[x][y - 1][z])) {
		color.insert(top[x][z]);
	}

	// get bottom
	if (y != m - 1) {
		a = {x, y + 1, z};
		a = get_par(a, 1);
	}
	if (y == m - 1 || (Max[1][a.x][a.y][a.z] == m - 1 && used[x][y + 1][z])) {
		color.insert(bottom[x][z]);
	}

	// get down
	if (z != 0) {
		a = {x, y, z - 1};
		a = get_par(a, 2);
	}
	if (z == 0 || (Min[2][a.x][a.y][a.z] == 0 && used[x][y][z - 1])) {
		color.insert(down[x][y]);
	}

	// get up
	if (z != k - 1) {
		a = {x, y, z + 1};
		a = get_par(a, 2);
	}
	if (z == k - 1 || (Max[2][a.x][a.y][a.z] == k - 1 && used[x][y][z + 1])) {
		color.insert(up[x][y]);
	}

	if (color.empty()) return -1;
	if (color.size() >= 2) return 0;
	return *color.begin();
}

void build() {
	used.assign(n, vector<vector<bool>> (m, vector<bool> (k, false)));
	for (int i = 0; i < 3; i++) {
		par[i].resize(n, vector<vector<triple>> (m, vector<triple> (k)));
		Min[i].resize(n, vector<vector<int>> (m, vector<int> (k)));
		Max[i].resize(n, vector<vector<int>> (m, vector<int> (k)));
	}
	for (int x = 0; x < n; x++) {
		for (int y = 0; y < m; y++) {
			for (int z = 0; z < k; z++) {
				for (int it = 0; it < 3; it++) {
					par[it][x][y][z] = {x, y, z};
				}
				Min[0][x][y][z] = x;
				Max[0][x][y][z] = x;
				Min[1][x][y][z] = y;
				Max[1][x][y][z] = y;
				Min[2][x][y][z] = z;
				Max[2][x][y][z] = z;
			}
		}
	}

	for (int x = 0; x < n; x++) {
		for (int y = 0; y < m; y++) {
			for (int z = 0; z < k; z++) {
				if (!get_color(x, y, z)) {
					q.push({x, y, z});
					used[x][y][z] = true;
				}
			}
		}
	}
}

vector<int> dx = {-1, 1, 0, 0, 0, 0};
vector<int> dy = {0, 0, -1, 1, 0, 0};
vector<int> dz = {0, 0, 0, 0, -1, 1};

bool check(int x, int y, int z) {
	return x >= 0 && x < n && y >= 0 && y < m && z >= 0 && z < k;
}

void del(int x, int y, int z) {
	for (int i = 0; i < 6; i++) {
		int nx = x + dx[i], ny = y + dy[i], nz = z + dz[i];
		if (!check(nx, ny, nz)) continue;
		if (!used[nx][ny][nz]) continue;
		uni({x, y, z}, {nx, ny, nz}, i / 2);
	}
}

void bfs() {
	while (!q.empty()) {
		auto v = q.front();
		int x = v.x, y = v.y, z = v.z;
		q.pop();
		del(x, y, z);
		for (int i = 0; i < 6; i++) {
			int nx = x + dx[i], ny = y + dy[i], nz = z + dz[i];
			if (!check(nx, ny, nz)) continue;
			if (get_color(nx, ny, nz)) continue;

			if (used[nx][ny][nz]) {
				auto a = triple(nx, ny, nz);
				a = get_par(a, i / 2);
				if (i / 2 == 0) {
					if (i % 2 == 0) {
						nx = Min[i / 2][a.x][a.y][a.z] - 1;
					}
					else {
						nx = Max[i / 2][a.x][a.y][a.z] + 1;
					}
				}
				else if (i / 2 == 1) {
					if (i % 2 == 0) {
						ny = Min[i / 2][a.x][a.y][a.z] - 1;
					}
					else {
						ny = Max[i / 2][a.x][a.y][a.z] + 1;
					}
				}
				else {
					if (i % 2 == 0) {
						nz = Min[i / 2][a.x][a.y][a.z] - 1;
					}
					else {
						nz = Max[i / 2][a.x][a.y][a.z] + 1;
					}
				}
				if (!check(nx, ny, nz)) continue;
				if (get_color(nx, ny, nz)) continue;
			}
			if (used[nx][ny][nz]) continue;
			used[nx][ny][nz] = true;
			q.push({nx, ny, nz});
		}
	}
}

void check_ans() {
	for (int y = 0; y < m; y++) {
		for (int z = 0; z < k; z++) {
			bool flag = false;
			for (int x = 0; x < n; x++) {
				if (!used[x][y][z]) {
					flag = true;
				}
			}
			if (!flag) {
				if (left[y][z] || right[y][z]) {
					no();
				}
			}
		}
	}
	for (int x = 0; x < n; x++) {
		for (int z = 0; z < k; z++) {
			bool flag = false;
			for (int y = 0; y < m; y++) {
				if (!used[x][y][z]) {
					flag = true;
				}
			}
			if (!flag) {
				if (top[x][z] || bottom[x][z]) {
					no();
				}
			}
		}
	}
	for (int x = 0; x < n; x++) {
		for (int y = 0; y < m; y++) {
			bool flag = false;
			for (int z = 0; z < k; z++) {
				if (!used[x][y][z]) {
					flag = true;
				}
			}
			if (!flag) {
				if (up[x][y] || down[x][y]) {
					no();
				}
			}
		}
	}
}

void run() {
	build();
	bfs();
	check_ans();
}

void write() {
	for (int x = 0; x < n; x++) {
		for (int y = 0; y < m; y++) {
			for (int z = 0; z < k; z++) {
				int ans = get_color(x, y, z);
				if (ans == -1) ans = 0;
				if (used[x][y][z]) ans = 0;
				cout << ans << " ";
			}
		}
	}
	cout << endl;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}


#include <bits/stdc++.h>
#define rp(_s,_i,_n) for(int _s=_i;_s<_n;_s++)
#define sz(_itt) (int)_itt.size()
#define mp(__a,__b) make_pair(__a,__b)
#define pb(_p) push_back(_p)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define inf 1e9 + 7
using namespace std;
typedef long long ll;
int main()
{
    fastio

    int a,m;cin>>a>>m;
    if(a%m==0){cout << "Yes";return 0;}
    if(m%a==0&&m/a%2==0){
    int r=m/a;
    while(r%2==0){
        r/=2;
    }
    if(r==1){cout << "Yes";return 0;}
    }
    while(m%2==0){
        m/=2;
    }
    if(m==1){cout << "Yes";return 0;}
    cout << "No";
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <bitset>
#include <vector>
using namespace std;

//int main(){
//    string s;
//    cin >> s;
//    cout << (s.back()%2);
//    return 0;
//}

#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define lli long long int
#define f first
#define s second
#define fw(i, start, end) for (lli i = start; i < end; ++i)
//bc sherlock pe banao aur humse naa bane XD
vector<string> element = {"H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", "Cn", "Nh", "Fl", "Mc", "Lv", "Ts", "Og"};
string p;
bool dfs(string w)
{
    if (!w.size())
        return 1;
    for (int i = 0; i < element.size(); i++)
        if (w.size() >= element[i].size())
            if (w.substr(0, element[i].size()) == element[i])
                if (dfs(w.substr(element[i].size(), w.size() - element[i].size())))
                    return 1;
    return 0;
}
int main()
{
    for (auto &c : element)
        for (auto &t : c)
            t = toupper(t);
    cin >> p;
    cout << (dfs(p) ? "YES" : "NO");
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long n,m;
long long a[30];
long long dp[30];
int main(){
	cin >> n >> m;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		dp[i] = a[i];
	}
	for(int i = 0;i < n;i++){
		for(int j = 0;j <= i;j++){
			dp[i] = min(dp[i],(1ll << (i-j))*dp[j]);
		}
	}
	long long fans = 0;
	long long ans = 1ll << 60;
	for(int i = n-1;i >= 0;i--){
		long long L = m/(1ll << i);
		fans += L*dp[i];
		m %= (1ll << i);
		ans = min(ans,fans+(m>0)*dp[i]);
	}
	cout << ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
	cin>>a>>b>>c;
	cout<<min(a,min(b/2,c/4))*7;
	return 0;
}


#include <iostream>
using namespace std;

int main() {
    int n, m, a;

    cin >> n >> m;

    if (m - 1 >= n - m) {
        a = m - 1;
    }

    if (m - 1 < n - m) {
        a = m + 1;
    }

    if (a == 0) a++;

    cout << a << endl;

    return 0;
}


#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

typedef long long ll;

#define M 10000000
int maxsq[M+10];

int main(void){
    int i,j;

    for(i=1;i*i<=M;i++){
        int s = i*i;
        for(j=s;j<=M;j+=s) maxsq[j] = s;
    }

    int a,n;
    cin >> a >> n;

    ll ans = 0;
    for(i=a;i<=a+n-1;i++) ans += i / maxsq[i];
    cout << ans << endl;

    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>

#define For(i, j, k) for(LL i = j; i <= k; i++)
#define Forr(i, j, k) for(LL i = j; i >= k; i--)
#define Set(i, v) memset(i, v, sizeof i)

using namespace std;

typedef long long LL;

const int N = 110, M = N * 60000;

typedef long long LL;

LL k;
int A[N], val[M], n, m;

LL check(LL v){
	LL ret = 0;
	For(i, 1, n) ret += A[i] % v == 0 ? 0 : v - A[i] % v;
	return ret;
}

int main(){
	cin >> n >> k;
	LL sum = 0;
	For(i, 1, n) cin >> A[i], sum += A[i];
	For(i, 1, n){
		for(int j = A[i], nxt; j; j = nxt) nxt = A[i] / (A[i] / j + 1), val[++m] = j + bool(A[i] % j);
	}
	val[++m] = 1;
	sort(val + 1, val + m + 1), m = int(unique(val + 1, val + m + 1) - val) - 1;
	LL ans = 1;
	For(i, 1, m){
		LL delt = 0, x = val[i], s = 0, nxt = i == m ? 1e18: val[i + 1];
		For(j, 1, n){
			delt += (A[j] - 1) / x + 1;
			s += A[j] % x ? x - A[j] % x : 0;
		}
		//cout << x << ' ' << nxt << ' ' << s << ' ' <<  check(x) << ' ' << delt << endl;
		if(k >= s) ans = max(ans, min(x + (k - s) / delt, nxt - 1));
	}
	cout << ans << endl;
	return 0;
}


#define _CRT_DISABLE_PERFCRIT_LOCKS
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <math.h>
#include <string>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>

using namespace std;

#define get() _getchar_nolock()
#define put(c) _putchar_nolock(c)
#define pb push_back
#define mk make_pair
#define fr first
#define sc second

#define xx real()
#define yy imag()

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

#define task "rare"
#define file 0

const int maxn = 100100;
int n, k;
bool a[33];
char s[maxn];
void fail(){
    puts("IMPOSSIBLE");
    exit(0);
}
void solve(){
    scanf("%d %s", &k, &s);
    n = strlen(s);
    if((n + 1) / 2 < k){
        puts("IMPOSSIBLE");
        return;
    }

    for(int i = 0; i < n; i ++){
        if(s[i] == '?' && s[n - i - 1] != '?'){
            s[i] = s[n - i - 1];
        }
        if(s[i] != '?') a[s[i] - 'a'] = true;
        if(s[n - i - 1] != '?' && s[i] != s[n - i - 1])
            fail();
    }
    int j = k - 1;
    for(; j >= 0 && a[j]; j --);
    for(int i = (n - 1) / 2; i >= 0; i --){
        if(s[i] == '?'){
            if(j < 0) j = 0;
            s[i] = s[n - i - 1] = j + 'a';
            a[s[i] - 'a'] = true;
            while(j >= 0 && a[j]) j --;
        }
    }
    if(j < 0)
        puts(s);
    else fail();
}
int main(){
    if(file){
        freopen(task".in", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    solve();
}


#include <bits/stdc++.h>

const int MAXN = 50;
typedef long long LL;
int n;
char buf[MAXN];
int fail[MAXN], tr[MAXN][2];
LL dp[MAXN][MAXN][2];
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> buf + 1; int S = strlen(buf + 1);
	for (int i = 1; i <= S; ++i) {
		int now = fail[i - 1];
		while (now && (now + 1 == i || buf[now + 1] != buf[i])) now = fail[now];
		fail[i] = now + 1 != i && buf[now + 1] == buf[i] ? now + 1 : 0;
	}
	for (int i = 0; i <= S; ++i)
		for (int j = 0; j < 2; ++j) {
			int now = i;
			while (now && buf[now + 1] != j + '0') now = fail[now];
			tr[i][j] = buf[now + 1] == j + '0' ? now + 1 : 0;
		}
	LL ans = 0;
	for (int i = 0; i <= S; ++i) {
		memset(dp, 0, sizeof dp);
		dp[0][i][i == S] = 1;
		for (int j = 1; j <= n; ++j)
		for (int k = 0; k <= S; ++k)
		for (int l = 0; l < 2; ++l)
		for (int p = 0; p < 2; ++p)
			dp[j][tr[k][p]][(tr[k][p] == S) || l] += dp[j - 1][k][l];
		ans += dp[n][i][1];
	}
	std::cout << ans << std::endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <queue>
#include <cassert>
#include <fstream>
#include <sstream>
#include <bitset>
#include <stack>
#include <list>
#define debug1(x) cout << #x" = " << x << endl;
#define debug2(x, y) cout << #x" = " << x << " " << #y" = " << y << endl;
#define debug3(x, y, z) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << endl;
#define debug4(x, y, z, w) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << " " << #w" = " << w << endl;
using namespace std;

int N;
int lower[10][10];
int upper[10][10];
int aa[10][10];

bool caled[6][5][10][15][20][25];
int sum[6][5][10][15][20][25];

struct State
{
	int in[6];
};

int getMaxSum(State s, int depth)
{
	int a = s.in[0];
	int b = s.in[1];
	int c = s.in[2];
	int d = s.in[3];
	int e = s.in[4];
	int f = s.in[5];

	if (caled[depth][b][c][d][e][f]) return sum[depth][b][c][d][e][f];
	caled[depth][b][c][d][e][f] = true;

	int & ret = sum[depth][b][c][d][e][f];
	ret = -1;

	if (depth == 0)
	{
		ret = 0;
		return ret;
	}

	int deal = depth;
	int shouldin = s.in[deal];
	int totalmaxin = 0;
	int totalminin = 0;
	for (int i = 0; i < deal; ++i)
	{
		totalmaxin += upper[i][deal];
		totalminin += lower[i][deal];
	}
	if (totalmaxin < shouldin || totalminin > shouldin)
		return ret = -1;

	int delta[6];
	memset(delta, 0, sizeof(delta));
	for (int i = 0; i < deal; ++i)
		delta[i] = lower[i][deal];

	while (true)
	{
		int nowin = 0;
		int nowcost = 0;
		for (int i = 0; i < deal; ++i)
		{
			nowin += delta[i];
			if (delta[i] > 0)
				nowcost += aa[i][deal] + delta[i] * delta[i];
		}

		if (nowin == shouldin)
		{
			State ns;
			for (int i = 0; i < 6; ++i)
				ns.in[i] = s.in[i] + delta[i];
			ns.in[deal] = 0;

			int t = getMaxSum(ns, depth - 1);
			if (t >= 0 && t + nowcost >= ret)
				ret = t + nowcost;
		}

		int last = deal - 1;
		delta[last]++;
		while (delta[last] > upper[last][deal] && last >= 0)
		{
			delta[last] = lower[last][deal];
			delta[last - 1]++;
			last--;
		}
		if (last < 0) break;
	}

	//debug2(depth, ret);
	return ret;
}

void york()
{
	int ansupper = 0;
	int anslower = 0;
	for (int i = 1; i < N; ++i)
	{
		ansupper += upper[0][i];
		anslower += lower[0][i];
	}

	for (int ans = anslower; ans <= ansupper; ++ans)
	{
		State s;
		for (int i = 0; i < 6; ++i) s.in[i] = 0;
		s.in[N - 1] = ans;
		memset(caled, false, sizeof(caled));
		int maxsum = getMaxSum(s, N - 1);

		//debug2(ans, maxsum);
		if (maxsum >= 0)
		{
			cout << ans << " " << maxsum << endl;
			return;
		}
	}
	cout << "-1 -1" << endl;
}

void init()
{
	memset(lower, 0, sizeof(lower));
	memset(upper, 0, sizeof(upper));
	memset(aa, 0, sizeof(aa));
	cin >> N;
	for (int i = 0; i < N * (N - 1) / 2; ++i)
	{
		int s, f, l, h, a;
		cin >> s >> f >> l >> h >> a;
		s--; f--;
		lower[s][f] = l;
		upper[s][f] = h;
		aa[s][f] = a;
	}
}

int main()
{
	init();
	york();
	return 0;
}


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

int main(){
	int n;
	cin>>n;
	cout<<n;
	LOOP:for(int i=2;i<=n;i++)
		if(n%i==0){
			n/=i;	cout<<' '<<n;	goto LOOP;
		}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long sum(string s)
{
    long long ans=0;
    for(int i=0 ;i<s.size() ;i++)
    {
        ans+=(s[i]-'0');
    }
    return ans;
}
void pt(string s)
{
    int n=0;
    if(s[0]=='0')
    {
        n=1;
    }
    for(int i=n ;i<s.size();i++)
    {
        cout<<s[i];
    }
}
int main() {
    string num,num1,mx;
    cin>>num;
    num1=mx=num;
    for(int j=num1.size()-2 ;j>=0 ;j--)
    {
        num1[j]--;
        for(int i=j+1 ; i<num1.size() ;i++)
        {
            num1[i]='9';
        }
        if(sum(mx)<sum(num1))
        {
            mx=num1;
        }
        num1=num;
    }
    pt(mx);
	return 0;
}


#include<iostream>
#include<vector>
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long

using namespace std;

vector<int>adj[200005];

int vis1[200005];
int vis2[200005];
int vis[200005];
int a,b;
void dfs1(int s){
    if(s!=a)vis1[s]++;
    for(int i=0;i<adj[s].size();i++){
        int u =adj[s][i];
        if(u==b){
            continue;
        }
        if(vis1[u]==0){
            dfs1(u);
        }
    }
}
void dfs2(int s){
    if(s!=b)vis2[s]++;
    for(int i=0;i<adj[s].size();i++){
        int u =adj[s][i];
        if(u==a){
            continue;
        }
        if(vis2[u]==0){
            dfs2(u);
        }
    }
}
int main(){
    IOS
    //freopen("output.txt","w",stdout);
    int t;
    cin>>t;

    for(int tt=0;tt<t;tt++){
        int n,m;
        cin>>n>>m>>a>>b;
        for(int i=1;i<=n;i++){
            adj[i].clear();
            vis1[i]=0;
            vis2[i]=0;
            vis[i]=0;
       }
        for(int i=0;i<m;i++){
            int u,v;
            cin>>u>>v;

            adj[u].pb(v);
            adj[v].pb(u);
        }
        dfs1(a);
        dfs2(b);
       for(int i=1;i<=n;i++){
           vis[i]=vis1[i]+vis2[i];
       }
       ll fora =0;
       ll forb=0;
       for(int i=1;i<=n;i++){
            if(vis[i]==2)continue;
            if(vis1[i]==1){
                fora++;
            }
            if(vis2[i]==1){
                forb++;
            }
       }
       cout<<fora*forb<<"\n";

       for(int i=1;i<=n;i++){
            adj[i].clear();
            vis1[i]=0;
            vis2[i]=0;
            vis[i]=0;
       }
    }
}


#include <iostream>
using namespace std;

int main()
{  long long n;
   cin >> n;
   cout << n/2520;
}


#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 52;
int n,a[N],Ans,ans[N],qz[N];
bitset<25*50000+5>f[52][26];
int main() {
	read(n);rep(i,1,n*2)read(a[i]);sort(a+1,a+n*2+1);
	rep(i,1,n*2)qz[i]=qz[i-1]+a[i];
	Ans=1e9;f[n*2+1][0][0]=1;
	per(i,n*2,3){
		f[i][0][0]=1;
		rep(j,1,min(n-1,n*2-i+1))f[i][j]=f[i+1][j]|(f[i+1][j-1]<<a[i]);
		if(i-2<=n){
			int p=0,now=1e9;
			rep(j,0,25*50000)if(f[i][n-(i-2)][j]&&max(qz[i-2]+j+a[i-1],qz[n*2]-(qz[i-2]+j)+a[1])<Ans&&max(qz[i-2]+j+a[i-1],qz[n*2]-(qz[i-2]+j)+a[1])<now){
				now=max(qz[i-2]+j+a[i-1],qz[n*2]-(qz[i-2]+j)+a[1]);p=j;
			}
			if(p){
				Ans=now;
				bool cho[N]={0};rep(j,1,i-2)cho[j]=1;
				for(int x=i,y=n-(i-2),z=p;x<=n*2;x++){
					assert(f[x][y][z]);
					if(!f[x+1][y][z])cho[x]=1,y--,z-=a[x];
				}
				int pos=0;rep(i,1,n*2)if(cho[i])ans[++pos]=a[i];
				per(i,n*2,1)if(!cho[i])ans[++pos]=a[i];
			}
		}
	}
	rep(i,1,n)printf("%d ",ans[i]);puts("");
	rep(i,n+1,n+n)printf("%d ",ans[i]);puts("");
	cerr<<Ans<<endl;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker,"/STACK:16777216")
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#define FOR(i,a,n) for(int i=(a);i<(n);i++)
#define REP(i,n) FOR(i, 0, n)
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define lint long long
#define PII pair <int,int>
#define PDD pair <double,double>
#define VI vector <int>
#define VII vector < PII >
#define X first
#define Y second
#define sz(a) (int)(a.size())
using namespace std;

const int DIM = 110*1000;
int dn[DIM];
int n;
//char us[DIM][DIM];
int nim(int n){
	if (dn[n] != -1) return dn[n];
	int res = 0;
	VI v;
	FOR(k, 2, n){
		int x = (2*n + (lint)k*(k-1)) / 2 / k;
		if ((k*x - (k*(k-1))/2) == n && x > k-1){
			int cand = 0;
			REP(i, k){
				cand ^= nim(x-i);
			}
			v.pb(cand);
		}
	}
	sort(all(v));
	v.resize(unique(all(v))-v.begin());
	int p = 0;
	while (sz(v) > p && v[p] == p) p++;
	res = p;
	return dn[n] = res;
}
int main(){
	//freopen("t.in", "r", stdin);
	memset(dn, -1, sizeof(dn));
	//FOR(i, 1, 100) printf("%d %d\n", i, nim(i));
	scanf("%d", &n);
	int ans = nim(n);
	if (ans == 0) printf("-1\n");
	else {
		FOR(k, 2, n){
			int x = (2*n + (lint)k*(k-1)) / 2 / k;
			if ((k*x - (k*(k-1))/2) == n && x > k-1){
				int cand = 0;
				REP(i, k){
					cand ^= nim(x-i);
				}
				if (cand == 0){
					printf("%d\n", k);
					return 0;
				}
			}
		}
	}
	return 0;
}


/*
    Take me to church
    I'll worship like a dog at the shrine of your lies
    I'll tell you my sins and you can sharpen your knife
    Offer me that deathless death
    Good God, let me give you my life
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 19;
ll INF = 2e9 + 19, A[N], dp[N][2], dpt[N][2], C[N][N];
inline ll Solve(int len, int w = -1)
{
    if (!len) return 1LL;
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for (int i = 0; i < 16; i ++)
    {
        memset(dpt, 0, sizeof(dpt));
        for (int j = 0; j <= len; j ++)
            for (int h = 0; j + h <= len && h <= A[i]; h ++)
            {
                if (len > j)
                    dpt[j + h][0] = min(dpt[j + h][0] + dp[j][0] * C[h][len - j - 1], INF);
                if (i > w && h > 0 && len > j)
                    dpt[j + h][1] = min(dpt[j + h][1] + dp[j][0] * C[h - 1][len - j - 1], INF);
                if (i > w)
                    dpt[j + h][1] = min(dpt[j + h][1] + dp[j][1] * C[h][len - j], INF);
            }
        memcpy(dp, dpt, sizeof(dp));
    }
    return (dp[len][1]);
}
int main()
{
    ll K, T, len = 1;
    scanf("%lld%lld", &K, &T);
    for (int i = 0; i < N; i ++)
        for (int j = C[0][i] = C[i][i] = 1; j < i; j ++)
            C[j][i] = min(C[j - 1][i - 1] + C[j][i - 1], INF);
    for (int i = 0; i < N; i ++)
        A[i] = T;
    for (; K > Solve(len, 0); )
        K -= Solve(len, 0), len ++;
    ll rs = 0;
    for (int i = 1; i <= len; i ++)
        for (int j = (i == 1); j < 16; j ++)
            if (A[j] > 0)
            {
                A[j] --;
                ll vl = Solve(len - i, -1);
                if (vl < K)
                    K -= vl, A[j] ++;
                else
                    rs = rs * 16 + j, j = 16;
            }
    return !printf("%llx", rs);
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define clr(x) memset((x), 0, sizeof(x))
#define pb push_back
#define mp make_pair
#define sz size()
#define x first
#define y second
#define forn(i, n) for(int i=0; i<(n); i++)
#define ford(i, n) for(int i=(n)-1; i>=0; i--)

typedef long double ld;

// Constants
const ld PI = 3.1415926535897932384626433832795;
const ld EPS = 1e-11;

// Types
typedef signed   long long i64;
typedef unsigned long long u64;
typedef pair < int, int > PII;

i64 f,w,h,MOD=1000000007;
i64 kw[100100];
i64 kf[100100];
i64 kw2[100100];

i64 kall,kall2;

i64 bp(i64 c, i64 st)
{
	i64 res=1,t=c;
	while(st>0)
	{
		if(st%2)
			res=(res*t)%MOD;
		st/=2;
		t=(t*t)%MOD;
	}
	return res;
}
int main()
{
	//freopen("z.in","rt",stdin);
	//freopen("z.out","wt",stdout);

	cin >>f>>w>>h;
	if(w==0)
	{
		cout <<1<<endl;
		return 0;
	}

	f--,w--;

	kf[1]=1;
	for(int i=1; i<=f; i++)
	{
		kf[i+1]=(kf[i]*(f-i+1))%MOD;
		kf[i+1]=(kf[i+1]*bp(i,MOD-2))%MOD;
	}
	kw[1]=1;
	for(int i=1; i<=w; i++)
	{
		kw[i+1]=(kw[i]*(w-i+1))%MOD;
		kw[i+1]=(kw[i+1]*bp(i,MOD-2))%MOD;
	}

	kall=0;
	for(int i=1; i<100100; i++)
	{
		kall=(kall+kw[i]*kf[i]*2)%MOD;
		kall=(kall+kw[i]*kf[i-1])%MOD;
		kall=(kall+kw[i]*kf[i+1])%MOD;
	}

	if(w>=h)
		kw2[1]=1;

	i64 Nlast=w-h;
	i64 Klast=Nlast;

	for(int i=1; Nlast>0 && i<100100; i++)
	{
		kw2[i+1]=kw2[i];

		for(int j=0; j<=h && Nlast>=0; j++)
		{
			kw2[i+1]=(kw2[i+1]*Nlast)%MOD;
			Nlast--;
		}
		forn(j,h)
		{
			kw2[i+1]=(kw2[i+1]*bp(Klast,MOD-2))%MOD;
			Klast--;
		}

		kw2[i+1]=(kw2[i+1]*bp(i,MOD-2))%MOD;
		if(Nlast<=0)
			break;
	}
	/*
	forn(i,10)
		cout <<kw[i]<<' ';
	cout <<endl;
	forn(i,10)
		cout <<kf[i]<<' ';
	cout <<endl;
	forn(i,10)
		cout <<kw2[i]<<' ';
	cout <<endl;
	*/
	kall2=0;
	for(int i=1; i<100100; i++)
	{
		kall2=(kall2+kw2[i]*kf[i]*2)%MOD;
		kall2=(kall2+kw2[i]*kf[i-1])%MOD;
		kall2=(kall2+kw2[i]*kf[i+1])%MOD;
	}
	//cout <<kall2<<' '<<kall<<endl;
	cout <<(kall2*bp(kall,MOD-2))%MOD;
	return 0;
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#define pll              pair<long,long>
#define pii              pair<int,int>
#define scn(a)           scanf("%d", &a)
#define scn2(a, b)       scanf("%d%d", &a, &b)
#define scn3(a, b, c)    scanf("%d%d%d", &a, &b, &c)
#define pairl            pair<ll , ll >
#define scnl(a)          scanf("%lld", &a)
#define scnl2(a, b)      scanf("%lld%lld", &a, &b)
#define scnl3(a, b, c)   scanf("%lld%lld%lld", &a, &b, &c)
#define scns(s)          scanf("%s",s)
#define prts(s)          printf("%s\n",s)
#define prt(a)           printf("%d\n", a)
#define prtl(a)          printf("%lld\n", a)
#define prs(a)           printf("%d ", a)
#define prt2(a, b)       printf("%d %d\n", a, b)
#define prt3(a, b, c)    printf("%d %d %d\n", a, b, c)
#define prsl(a)          printf("%lld ", a)
#define prtl2(a, b)      printf("%lld %lld\n", a, b)
#define prtl3(a, b, c)   printf("%lld %lld %lld\n", a, b, c)
#define ptcs(a)          printf("Case %d: ", a)
#define pf               printf
#define sc               scanf
#define vi               vector<int >
#define vil              vector<ll >
#define pb               push_back
#define mem(a, b)        memset((a), (b), sizeof(a))
#define lg2(n)           (31-__builtin_clz(n))
#define inf              9999999
#define ll               long long
#define ull              unsigned long long
#define MIN              INT_MIN
#define MAX              INT_MAX
#define fast             ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<pair<int, int> , null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> odrst;
ll gcd(ll a, ll b){if(b==0) {return a;}return gcd(b, a % b);}
ll BigMod(ll B,ll P,ll M){     ll R=1; while(P>0)      {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;}
//___________________________________________________________________________________________________________________
const int N = 3e5 + 9;
const int mod = 1e9 + 7;
ll a[N];
vector< pair<ll,ll> >v;
bool ok;
int main()
{
    fast;
    ll x0,y0,ax,ay,bx,by,xs,ys,t,x,y,z,x1,y1,mx=9e16,ans=0,p;
    cin>>x0>>y0>>ax>>ay>>bx>>by>>xs>>ys>>t;
    x=x0;
    y=y0;
    while(x<mx && y<mx)
    {
        v.pb({x,y});
        x=ax*x+bx;
        y=ay*y+by;
    }
    for(int i=0;i<v.size();i++)
    {
        z=abs(xs-v[i].first)+abs(ys-v[i].second);
        if(z<=t)
        {
            x=v[i].first;
            y=v[i].second;
            p=1;
            int j=i-1;
            while(j>=0)
            {
                z+=(abs(x-v[j].first)+abs(y-v[j].second));
                if(z>t)
                {
                    break;
                }
                x=v[j].first;
                y=v[j].second;
                j--;
                p++;
            }
            j=i+1;
            while(j<v.size() && z<=t)
            {
                z+=(abs(x-v[j].first)+abs(y-v[j].second));
                if(z>t)
                {
                    break;
                }
                x=v[j].first;
                y=v[j].second;
                j++;
                p++;
            }
            ans=max(ans,p);
            z=abs(xs-v[i].first)+abs(ys-v[i].second);
            x=v[i].first;
            y=v[i].second;
            p=1;
            j=i+1;
            while(j<v.size())
            {
                z+=(abs(x-v[j].first)+abs(y-v[j].second));
                if(z>t)
                {
                    break;
                }
                x=v[j].first;
                y=v[j].second;
                j++;
                p++;
            }
            j=i-1;
            while(j>=0 && z<=t)
            {
                z+=(abs(x-v[j].first)+abs(y-v[j].second));
                if(z>t)
                {
                    break;
                }
                x=v[j].first;
                y=v[j].second;
                j--;
                p++;
            }
            ans=max(ans,p);
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int v,s,vedro[105],t,m,i,n;
main(){
cin>>v>>s;
for (i=0; i<v; i++){
cin>>vedro[i];
}
sort(vedro,vedro+v);
for (i=v-1; i>=0; i--){
if (s%vedro[i]==0) {cout<<s/vedro[i]; return 0;}
}
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=5e7;
const long long mod=1e9+7;
bool number[maxn+5];
int prime[maxn+5];
int c=0;
long long x,n;
long long qsm(long long a,long long b,long long c)
{
    long long ans=1,base=a;
    while(b!=0)
	{
        if(b&1)
        ans=ans*base%c;
        base=base*base%c;
        b>>=1;
	}
    return ans%c;
}
long long kk(long long a,long long b)
{
    long long ans=1,base=a;
    while(b!=0)
	{
        if(b&1)
        ans=ans*base;
        base=base*base;
        b>>=1;
	}
    return ans;
}
long long f(long long p)
{
	long long maxp=0,cc=n;
	while(cc>=p)
	{
		maxp++;
		cc/=p;
	}
	//printf("maxp=%lld\n",maxp);
	long long cs[100];
	cs[maxp]=n/kk(p,maxp);
//	cs[maxp]=(n%phi)*qsm(p,maxp*(phi-2),phi)%phi;
	//printf("cs==%lld ",cs[maxp]);
	long long zx=0;
	if(maxp>1)
	{
	for(long long i=maxp-1;i>=1;i--)
	{
		zx=(zx+cs[i+1]);
//		cs[i]=((n%phi)*qsm(p,i*(phi-2),phi)%phi-zx%phi+phi)%phi;
		cs[i]=(n/kk(p,i)-zx);
		//printf("%lld ",cs[i]);
	}
	}
	//printf("\n");
	long long ans=0;
	for(long long i=1;i<=maxp;i++)
		ans=(ans+(i*cs[i]));
	//printf("ans=%lld\n",ans);
	//printf("\n");
	return ans;
}
void init()
{
    int i,j;
    memset(number,true,sizeof(number));
    memset(prime,-1,sizeof(prime));
    for(i=2;i<=maxn;i++)
    {
        if(number[i])
            prime[c++]=i;
        for(j=0;j<c&&prime[j]*i<=maxn;j++)
        {
            number[prime[j]*i]=false;
            if(i%prime[j]==0) //保证每个合数只会被它的最小质因数筛去，因此每个数只会被标记一次
                break;
        }
    }
}
int main()
{
	init();
//	for(int i=0;i<10;i++)
//	printf("%lld\n",prime[i]);
	//printf("cnt=%d\n",c);
	//printf("%lld\n",(long long)(log(20190929)/log(2837)));
	scanf("%lld%lld",&x,&n);
	long long yz[10000];
	int psum=0;
	for(int i=0;i<c && prime[i]<=x && x>1;i++)//筛因子
		{
			if(x%prime[i]==0 && prime[i]!=1 && x>1)
			{
				yz[++psum]=prime[i];
				while(x>=prime[i] && x%prime[i]==0)
				{

					x/=prime[i];
				//	printf("x=%lld\n",x);
				}
			}
		}
	if(x>1)
	{
		yz[++psum]=x;
	}
	//printf("psum=%d\n",psum);
//	for(int i=1;i<=psum;i++)
//	{
//		printf("%lld ",yz[i]);
//	}
//	printf("\n");
	long long ans=1;
	for(int i=1;i<=psum;i++)
	{
	//	printf("f(%lld)=%lld\n",yz[i],f(yz[i]));
		ans=(ans*qsm(yz[i],f(yz[i]),mod))%mod;
	}
	printf("%lld\n",ans%mod);
//	f(5);
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a)
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;

inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=1025;
//i_am_noob
int n,k,m,cnt=0;
vector<vector<int>> vec;
vector<int> vec1;
bool ok[maxn];

void query(vector<int> vec){
    char tmp;
    for(int i:vec){
        print2("?",i+1);
        cout << flush;
        cin >> tmp;
        if(tmp=='Y') ok[i]=false;
    }
    cout << "R" << endl;
}

void report(){
    int ans=0;
    rep(n) ans+=ok[i];
    print2("!",ans);
    cout << flush;
    exit(0);
}

void build(int n, int x){
    if(n==4){
        vec.pb({x,x+1,x+2,x+3});
        return;
    }
    if(n==8){
        rep(4) rep2(j,i+1,4) vec.pb({x+i,x+j,x+4+i,x+4+j});
        return;
    }
    if(n==16){
        rep(4) vec.pb({x+4*i,x+4*i+1,x+4*i+2,x+4*i+3});
        vec.pb({x,x+4,x+8,x+12});
        vec.pb({x,x+5,x+10,x+15});
        vec.pb({x,x+6,x+11,x+13});
        vec.pb({x,x+7,x+9,x+14});
        vec.pb({x+1,x+4,x+11,x+14});
        vec.pb({x+1,x+5,x+9,x+13});
        vec.pb({x+1,x+6,x+8,x+15});
        vec.pb({x+1,x+7,x+10,x+12});
        vec.pb({x+2,x+4,x+9,x+15});
        vec.pb({x+2,x+5,x+11,x+12});
        vec.pb({x+2,x+6,x+10,x+14});
        vec.pb({x+2,x+7,x+8,x+13});
        vec.pb({x+3,x+4,x+10,x+13});
        vec.pb({x+3,x+5,x+8,x+14});
        vec.pb({x+3,x+6,x+9,x+12});
        vec.pb({x+3,x+7,x+11,x+15});
        return;
    }
    int tmp=n/4+1;
    rep(tmp) rep1(j,tmp){
        vec1.clear();
        if(i!=tmp-1) vec1.pb(x+i);
        if(j!=tmp-1) vec1.pb(x+n/4+j);
        if((j+i)%tmp!=tmp-1) vec1.pb(x+n/4*2+(j+i)%tmp);
        if((j+2*i)%tmp!=tmp-1) vec1.pb(x+n/4*3+(j+2*i)%tmp);
        vec.pb(vec1);
    }
    rep(4) build(n/4,x+n/4*i);
}

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n >> k;
	rep(n) ok[i]=true;
	if(k==1){
        rep(n) rep2(j,i+1,n) query({i,j});
        report();
	}
	if(k==2){
        rep(n/2) rep2(j,i+1,n/2){
            query({i,j,i+n/2});
            query({i,i+n/2,j+n/2});
        }
        query({n/2-1,n-1});
        report();
	}
	build(n/k*4,0);
	rep1(ii,sz(vec)){
        m=sz(vec[ii]);
        rep2(i,1,k/4) rep1(j,m){
            vec[ii].pb(n/k*4*i+vec[ii][j]);
        }
	}
    /*
	for(auto vec2:vec){
        for(auto i:vec2) {print0(i);cnt++;}
        cout << "\n";
	}
	print1(cnt);
    rep(n) rep2(j,i+1,n) b[i][j]=false;
    for(auto vec2:vec) rep(sz(vec2)) rep2(j,i+1,sz(vec2)) b[vec2[i]][vec2[j]]=true;
    rep(n) rep2(j,i+1,n) if(!b[i][j]) print2(i,j);
    */

	for(auto vec2:vec) query(vec2);
	report();

	return 0;
}


#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pb push_back
#define fastcin() ios_base::sync_with_stdio(0); cin.tie(0)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef pair<int, int> ii;

vector<int> d;
int LCM(int a, int b) {
	if(!(a*b)) return max(a, b);
	return a / (int)__gcd(a, b) * b;
}

int dp[21][50][2550], pos[2600], cnt, dig_lim, pre[2550][10], nxt[2550][10];

int call(int dig, int lcm, int r, bool fl) {
	int p = pos[lcm], ret = 0, limit = (fl ? 9 : d[dig]);
	if(!dig) return (r % lcm == 0);
	if(fl and dp[dig][p][r] != -1) return dp[dig][p][r];
	for(int i = 0; i <= limit; i++)
 		ret += call(dig - 1, pre[lcm][i], nxt[r][i], max(fl, i < limit));
	if(fl) dp[dig][p][r] = ret;
	return ret;
}

int solve(int x) {
	dig_lim = 0; d.clear(); d.pb(0);
	while(x) {
		d.pb(x % 10);
		x /= 10;
		dig_lim++;
	}
	return call(dig_lim, 1, 0, 0);
}

signed main() {
	for(int i = 1; i <= 2520; i++)
		if(2520 % i == 0) pos[i] = ++cnt;
	for(int i = 0; i <= 2520; i++) for(int j = 0; j < 10; j++) pre[i][j] = LCM(i, j), nxt[i][j] = (i * 10 + j) % 2520;
	memset(dp, -1, sizeof dp);
	int t; cin >> t;
	while(t--) {
		int l, r; cin >> l >> r;
		cout << solve(r) - solve(l-1) << '\n';
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll arra[300009];
ll brra[100009];
ll sum[100009];
double input[100009];
vector<char>save;
string str1[108];
string str2[108];
string str;
map<int,int>vis;
string stp[5];
string stpc[5];
int main()
{
   ll m,n,i,j,k,l,p,q,r=1,s,t;
   //cin>>t;
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a==d&&(a>0||!c))
  {
    cout<<"1";
  }
  else
  cout<<"0";

}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a) begin(a),end(a)
#define FOR(x,val,to) for(int x=(val);x<int((to));++x)
#define FORE(x,val,to) for(auto x=(val);x<=(to);++x)
#define FORR(x,arr) for(auto &x: arr)
#define FORS(x,plus,arr) for(auto x = begin(arr)+(plus); x != end(arr); ++x)
#define FORREV(x,plus,arr) for(auto x = (arr).rbegin()+(plus); x !=(arr).rend(); ++x)
#define REE(s_) {cout<<s_<<'\n';exit(0);}
#define GET(arr) for(auto &i: (arr)) sc(i)
#define whatis(x) cerr << #x << " is " << (x) << endl;
#define e1 first
#define e2 second
#define INF 0x7f7f7f7f
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::vector<std::string> vs;
typedef int64_t ll;
typedef uint64_t ull;
#define umap unordered_map
#define uset unordered_set
using namespace std;
using namespace __gnu_pbds;

#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
template<class L, class R> ostream& operator<<(ostream &os, map<L, R> P) { for(auto const &vv: P)os<<"("<<vv.first<<","<<vv.second<<")"; return os; }
template<class T> ostream& operator<<(ostream &os, set<T> V) { os<<"[";for(auto const &vv:V)os<<vv<<","; os<<"]"; return os; }
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os<<"[";for(auto const &vv:V)os<<vv<<","; os<<"]"; return os; }
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) { os<<"("<<P.first<<","<<P.second<<")"; return os; }
inline int fstoi(const string &str){auto it=str.begin();bool neg=0;int num=0;if(*it=='-')neg=1;else num=*it-'0';++it;while(it<str.end()) num=num*10+(*it++-'0');if(neg)num*=-1;return num;}
inline void getch(char &x){while(x = getchar_unlocked(), x < 33){;}}
inline void getstr(string &str){str.clear(); char cur;while(cur=getchar_unlocked(),cur<33){;}while(cur>32){str+=cur;cur=getchar_unlocked();}}
template<typename T> inline bool sc(T &num){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){if(c == EOF) return false;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; return true;}template<typename T, typename ...Args> inline void sc(T &num, Args &...args){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; sc(args...); }
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //s.find_by_order(), s.order_of_key() <- works like lower_bound
template<typename T> using ordered_map = tree<T, int, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 1000001

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    const int nn = 1 << 20;
    /* int nn = 1 << 3; */
    int n;
    sc(n);
    ++n;
    string s;
    getstr(s);
    s.insert(s.begin(),'0');
    FORR(i,s) i -= '0';
    /* int dp[n+1][nn]; */
    static int dp[77][nn];
    memset(dp,0,sizeof dp);
    dp[0][0] = 1;
    int mod = 1e9+7;
    FOR(i,0,n){
        vector<pi> vec;
        int cr = 0;
        FOR(x,i,n){
            cr = cr*2+s[x];
            if(i != 0){
                if(!cr) continue;
                if(cr > 19) break;
            }
            vec.pb({x+1,i ? cr : 0});
        }
        FOR(x,0,nn){
            if(!dp[i][x]) continue;
            FORR(j,vec){
                /* if(!i){ */
                /*     dp[j.e1][x] += dp[i][x]; */
                /* } */
                /* else{ */
                int nm = x | 1 << j.e2;
                assert(nm >= 0);
                assert(nm < nn);
                assert(j.e1 <= n);
                if(i)
                    nm &= ~1;
                dp[j.e1][nm] += dp[i][x];
                if(dp[j.e1][nm] >= mod)
                    dp[j.e1][nm] -= mod;
                /* } */
            }
        }
    }
    int ans = 0;
    FORE(i,2,n){
        /* whatis(i) */
        for(int x = 2; x < nn; x += 2){
            int cc = 0;
            int j = 2;
            while(j & x){
                cc |= j;
                j <<= 1;
            }
            if(cc == x){
                /* whatis(x) */
                /* whatis(dp[i][x]) */
                ans += dp[i][x];
                if(ans >= mod) ans -= mod;
            }
        }
    }
    cout << ans << '\n';
}


/*input
33
*/

#include <unordered_map>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <climits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define ar array
#define scd(t) scanf("%d",&t)
#define scld(t) scanf("%ld",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define tests int r; cin >> r; while(r--)
#define MP make_pair
#define PI acos(-1)
typedef pair<long long, long long> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
#define godspeed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);

#define M(x) ((x)%(1000000007))

 int64 fact(int n) {
   int64 count = 1;
   for(int64 i = 1;i<=n;i++){
   		count = M(count * i);
   }
   return count;
}

int main() {
 	godspeed;
 	int64 n;
 	cin>>n;
 	int64 bad = 1;
 	for(int64 i = 0; i<n-1;i++){
 		bad =  M(bad * 2);
 	}
 	int64 ans = M(fact(n)-bad);

 	if(ans<0){
 		ans = ans + 1000000007;
 	}
 	cout<<ans;

}


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

#define debug(x) {cerr << #x << " = " << x << '\n';}
#define PR(a, n) {cerr << #a << " = "; for (int _=1; _<=n; ++_) cerr << a[_] << ' '; cerr << '\n';}
#define PR0(a, n) {cerr << #a << " = "; for (int _=0; _<n; ++_) cerr << a[_] << ' '; cerr << '\n';}
#define FILE_NAME "data"

const int MAXN = 62;
const int MOD = 1000000007;

int n, a[MAXN], C[MAXN][MAXN], T[MAXN];
bool visited[MAXN];
int64_t f[1<<17][MAXN];
vector<int> inf, sup, cc_inf, cc_sup;
vector<int> g[MAXN];

void readInput() {
    cin >> n;

    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
}

void init() {
    for (int i = 1; i <= n; ++i) {
        bool isSup = false;
        for (int j = 1; j <= n; ++j) {
            if (i != j && a[i] % a[j] == 0)
                isSup = true;
        }
        if (isSup)
            sup.push_back(a[i]);
        else
            inf.push_back(a[i]);
    }

    for (auto u : sup) {
        for (auto v : sup) {
            bool ok = false;
            for (auto w : inf)
                ok = ok || (u % w == 0 && v % w == 0);
            if (ok && u != v)
                g[u].push_back(v);
        }
    }

    for (int i = 0; i <= n; ++i)
        C[i][i] = C[i][0] = 1;

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j < i; ++j) {
            C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
        }
    }
}

void visit(int u) {
    cc_sup.push_back(u);
    visited[u] = true;

    for (auto v : g[u]) {
        if (!visited[v])
            visit(v);
    }
}

int64_t dp(int mask, int t) {
    if (t == cc_sup.size())
        return 1;

    if (f[mask][t] > -1)
        return f[mask][t];

    int nPawn = 0;
    for (auto u : cc_sup) {
        if ((T[u] & mask) > 0 && (T[u] | mask) == mask) {
            ++nPawn;
        }
    }

    int64_t res = 0;
    if (nPawn > t)
        res = dp(mask, t + 1) * (nPawn - t) % MOD;

    for (auto u : cc_sup) {
        if ((T[u] & mask) > 0 && (T[u] | mask) > mask) {
            int newMask = (mask | T[u]);
            res = (res + dp(newMask, t + 1)) % MOD;
        }
    }

    return f[mask][t] = res;
}

void solve() {
    int64_t res = 1;
    vector<int> p, sz;
    PR0(inf, inf.size());
    PR0(sup, sup.size());
    for (auto u : sup) {
        if (!visited[u]) {
            cc_sup.clear();
            visit(u);
            memset(T, 0, sizeof(T));
            for (auto v : inf) {
                bool ok = false;
                for (auto w : cc_sup)
                    ok = ok || (w % v == 0);
                if (ok) {
                    for (auto w : cc_sup) {
                        if (w % v == 0)
                            T[w] |= (1 << cc_inf.size());
                    }
                    cc_inf.push_back(v);
                }
            }

            for (int mask = 0; mask < (1<<cc_inf.size()); ++mask) {
                for (int t = 0; t <= cc_sup.size(); ++t) {
                    f[mask][t] = -1;
                }
            }
            // PR0(cc_sup, cc_sup.size());
            // PR0(cc_inf, cc_inf.size());
            // cerr << T[4] << ' ' << T[9] << ' ' << T[12] << '\n';
            // debug(dp(3, 2));
            int s = 0;
            for (auto v : cc_sup) {
                s = (s + dp(T[v], 1)) % MOD;
                // debug(dp(T[v], 1))
            }

            p.push_back(s);
            sz.push_back(cc_sup.size() - 1);
        }
    }

    for (int i = 0, cur = sup.size() - p.size(); i < p.size(); ++i) {
        res = res * p[i] % MOD * C[cur][sz[i]] % MOD;
        cur -= sz[i];
    }
    cout << res << '\n';
}

int main() {
    #ifdef GLASSES_GIRL
        freopen(FILE_NAME".in", "r", stdin);
    #endif

    readInput();
    init();
    solve();
}


#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <ctime>
#include <set>
#define N 100
#define M 1000
#define int65 unsigned long long
#define For(i,x,y) for (i=x;i<=y;i++)
using namespace std;
const char P[4]={'B','R','W','Y'};
struct ww {
	int x,y;
};
struct w {
	ww a,b;
	int c,d,e;
} c[N],q[20][20][50];
int i,j,k,n,m,an,S,T,t,num,ge;
int a[N][N],h[200],f[N][N],b[N][N],len[N][N],id[N][N],st[N][N],d[N][N],
	ba[M],bb[M],head[M],next[M],F[M],g[M],gg[M];
char p[N],s[N][N],re[N][N];
set<int65> Set;
inline void add(int x,int y,int z) {
	ba[++t]=y,bb[t]=z,next[t]=head[x],head[x]=t;
	ba[++t]=x,bb[t]=0,next[t]=head[y],head[y]=t;
}
inline bool bfs() {
	int l,r,v;
	g[l=r=1]=S; gg[S]=0; F[S]=++num;
	for (;l<=r;l++) for (v=head[g[l]];v;v=next[v]) {
		int A=ba[v];
		if (bb[v]&&F[A]!=num) {
			F[A]=num; gg[A]=gg[g[l]]+1; g[++r]=A;
			if (A==T) return 1;
		}
	}
	return 0;
}
int Dfs(int x,int y) {
	if (x==T) return y;
	int v,w=0,re;
	for (v=head[x];v&&w<y;v=next[v]) {
		int A=ba[v];
		if (bb[v]&&gg[A]==gg[x]+1&&F[A]==num&&(re=Dfs(A,min(bb[v],y-w))))
			bb[v]-=re,bb[v^1]+=re,w+=re;
	}
	if (!w) gg[x]=0;
	return w;
}
inline void Print(ww A,int B) {
	re[2*A.x-1][2*A.y-1]=P[B];
}
inline void print(w A,int x,int y) {
	if (A.e) swap(A.a,A.b),swap(A.c,A.d);
	if (x!=A.c&&y!=A.d) swap(x,y);
	Print(A.a,x); Print(A.b,y);
}
inline void work() {
	int i,j,u,r;
	For(i,0,3)For(j,i,3) len[i][j]=0;
	For(i,1,ge) {
		w A=c[i];
		q[A.c][A.d][++len[A.c][A.d]]=A;
	}
	int65 hash=0;
	For(i,0,3)For(j,i,3) hash=hash*97+len[i][j];
	if (Set.count(hash)) return;
	Set.insert(hash);
	S=21,T=22; For(i,1,T) head[i]=0; t=1;
	int sum=0;
	For(i,0,3)For(j,i,3) {
		st[i][j]=min(len[i][j],b[i][j]);
		d[i][j]=b[i][j]-st[i][j];
		sum+=st[i][j]*2;
		if (len[i][j]>b[i][j]) add(S,id[i][j],len[i][j]-b[i][j]);
		if (len[i][j]<b[i][j]) add(id[i][j]+10,T,b[i][j]-len[i][j]);
		For(u,0,3)For(r,u,3) {
			if (i==u&&j==r) continue;
			int A=i==u||i==r||j==u||j==r;
			if (A) add(id[i][j],id[u][r]+10,M);
		}
	}
	for (;bfs();sum+=Dfs(S,M));
	if (sum>an) {
		an=sum;
		//print
		memcpy(re,s,sizeof(re));
		For(i,0,3)For(j,0,3) {
			For(k,1,st[i][j]) {
				w B=q[i][j][k];
				print(B,i,j);
			}
			int B=id[i][j],v;
			for (v=head[B];v;v=next[v]) {
				int C=ba[v];
				if (C<=10||C>20||bb[v]==M) continue;
				For(u,0,3)For(r,u,3) if (id[u][r]+10==C) goto yy1;
				yy1:;
				int o;
				For(o,bb[v]+1,M) print(q[i][j][++st[i][j]],u,r),d[u][r]--;
			}
		}
		For(i,0,3)For(j,i,3)
		for (;st[i][j]<len[i][j];) {
			int A=++st[i][j];
			For(u,0,3)For(r,u,3) if (d[u][r]) goto yy2;
			yy2:;
			print(q[i][j][A],u,r);
			d[u][r]--;
		}
	}
}
inline void get(int A,int B,ww C,ww D) {
	int a=0;
	if (A>B) swap(A,B),swap(C,D),a=1;
	c[++ge]=(w){C,D,A,B,a};
}
void dfs(int x,int y) {
	if (x>7) {
		work();
		return;
	}
	if (y>8) {
		dfs(x+1,1);
		return;
	}
	if (f[x][y]) {
		dfs(x,y+1);
		return;
	}
	if (x<7) {
		f[x][y]=f[x+1][y]=1;
		get(a[x][y],a[x+1][y],(ww){x,y},(ww){x+1,y});
		s[2*x][2*y-1]='|';
		dfs(x,y+1);
		s[2*x][2*y-1]='.';
		ge--;
		f[x][y]=f[x+1][y]=0;
	}
	if (y<8&&!f[x][y+1]) {
		f[x][y]=f[x][y+1]=1;
		get(a[x][y],a[x][y+1],(ww){x,y},(ww){x,y+1});
		s[2*x-1][2*y]='-';
		dfs(x,y+1);
		s[2*x-1][2*y]='.';
		ge--;
		f[x][y]=f[x][y+1]=0;
	}
}
int main() {
	//freopen("126e.in","r",stdin);
	//freopen("126e.out","w",stdout);
	h['B']=0,h['R']=1,h['W']=2,h['Y']=3;
	For(i,1,7) {
		scanf("%s",p+1);
		For(j,1,8) a[i][j]=h[p[j]];
	}
	For(i,0,3)for (j=3;j>=i;j--) scanf("%d",&b[i][j]);
	k=0; For(i,0,3)For(j,i,3) id[i][j]=++k;
	an=-1; memset(s,'.',sizeof(s));
	dfs(1,1);
	printf("%d\n",an);
	For(i,1,13) {
		For(j,1,15) printf("%c",re[i][j]);
		printf("\n");
	}
	//for(;;);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int len, l, up;
	cin >> len >> l >> up;
	if(l*4 + up*2 <= len) cout << 1 << endl;
	else if(l*2 > len && up*2 > len && up+l > len) cout << 6 << endl;
	else
	{
		int ans = 6;
		int l1 = len/l, r1 = len/up;
		if(l1 >= 4) l1 = 4; if(r1 >= 2) r1 = 2;
		int n1 = (4 % l1 == 0) ? 4/l1 : 4/l1+1;
		ans = min(ans, n1 + 2/(r1));
		if(len >= l + up)
		{
			int d = len-up, temp;
			d /= l;
			if(d >= 2) ans = min(ans, 2);
			if(l1 >= 2) temp = 1;
			else temp = 2;
			if(d == 1) ans = min(ans, 2 + temp);
		}
		if(len >= up*2 + l)
		{
			int d = len - up*2, temp;
			d /= l;
			if(d >= 4) ans = min(ans, 1);
			else{

				temp = ((4-d)%l1 == 0)? (4-d)/l1 : (4-d)/l1+1;
				ans = min(ans, 1 + temp);
				}
		}
		cout << ans << endl;
	}

	return 0;
}


// #includes {{{
#include <algorithm>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <cstring>
#include <cmath>
#include <complex>
#include <functional>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back
#define CLEAR(c,d) memset((c),(d),sizeof(c))
#define TO_STRING(VariableName) # VariableName
#define OUT(c) cout<<TO_STRING(c)<<"="<<(c)<<endl

typedef long long Int;
typedef unsigned long long uInt;
typedef long long ll;
typedef long double ld;

typedef pair<int,int> pii;

void rint(int &r){scanf("%d",&r);}
void rInt(Int &r){scanf("%lld",&r);}
void ruint(unsigned int &r){scanf("%u",&r);}
void ruInt(uInt &r){scanf("%llu",&r);}
typedef double number;

// }}}

const int N=1000, M=110;
int n,m;

int x[N],y[N],z[N];
number a,b,c;

number xx[N],yy[N];

//{{{ geometry components

typedef double number;
const number EPS = 1e-7;
typedef complex<number> P;
namespace std {
	bool operator < (const P& a, const P& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}

//}}}

vector<P> v;

number calc(number x,number y){
	number ret=-1.0;
	REP(i,n)ret=max(ret,(xx[i]-x)*(xx[i]-x)+(yy[i]-y)*(yy[i]-y));
//	cout<<p<<" "<<ret<<endl;
	return ret;
}

const number INF=1.8e+4;

//{{{

number ternaryY(number x){
	number left=-INF,right=INF;
	while(right-left>EPS){
//		cout<<left<<" "<<right<<endl;
		number leftThird=left+(right-left)*0.45;
		number rightThird=left+(right-left)*0.55;

		number rLeft=calc(x,leftThird);
		number rRight=calc(x,rightThird);

		if(rLeft > rRight)
			left=leftThird;
		else
			right=rightThird;
	}
//	cout<<x<<" "<<(left+right)/2<<endl;
	return (left+right)*0.5;
}

number largestCoveringCircle(){
	number left=-INF,right=INF;
	while(right-left>EPS){
//				cout<<left<<" "<<right<<endl;
		number leftThird=left+(right-left)*0.45;
		number rightThird=left+(right-left)*0.55;

		number rLeft=calc(leftThird,ternaryY(leftThird));
		number rRight=calc(rightThird,ternaryY(rightThird));
//		cout<<rLeft<<" "<<rRight<<endl;

		if(rLeft>rRight)
			left=leftThird;
		else
			right=rightThird;
	}
	number x=(left+right)*0.5;
	number y=ternaryY(x);
	return calc(x,y);
}
//}}}

const double phi=(1+sqrt(5))/2;
const double resphi=(double)2-phi;

//{{{
double goldenSectionSearchY(const double X){
	double a=-INF,b=INF, c=(phi*a+b)/(phi+1.0);
	double fb=calc(X,b);
	REP(i,80){
//		if(abs(c-a)<EPS*(abs(b)+abs(c)))return (c+a)/2;
		double x;
		if(c-b>b-a)x=b+resphi*(c-b);
		else x=b-resphi*(b-a);
//		cout<<a<<" "<<b<<" "<<c<<" "<<x<<endl;
		double fx=calc(X,x);
		if(fx<fb){
			if(c-b>b-a)a=b,b=x;
			else c=b,b=x;
			fb=fx;
		}else{
			if(c-b>b-a)c=x;
			else a=x;
		}
	}
	return (c+a)/2;
}

double goldenSectionSearch(){
	double a=-INF,b=INF, c=(phi*a+b)/(phi+1.0);
	double gb=goldenSectionSearchY(b),fb=calc(b,gb);
	REP(i,80){
//		if(abs(c-a)<EPS*(abs(b)+abs(c)))return (c+a)/2;
		double x;
		if(c-b>b-a)x=b+resphi*(c-b);
		else x=b-resphi*(b-a);
//		cout<<a<<" "<<b<<" "<<c<<" "<<x<<endl;
		double gx=goldenSectionSearchY(x),fx=calc(x,gx);
		if(fx<fb){
			if(c-b>b-a)a=b,b=x;
			else c=b,b=x;
			fb=fx;
		}else{
			if(c-b>b-a)c=x;
			else a=x;
		}
	}
	double x=(c+a)/2;
//	cout<<x<<endl;
	double y=goldenSectionSearchY(x);
	return calc(x,y);
}

//}}}

void main2();

int main(){
	rint(n);rint(m);
	REP(i,n){
		rint(x[i]);
		rint(y[i]);
		rint(z[i]);
	}
	REP(i,m)main2();
	return 0;
}

void main2(){
	scanf("%lf%lf%lf",&a,&b,&c);
	number d=sqrt(a*a+b*b+c*c);
	a/=d;b/=d;c/=d;
	number x1,y1,z1,x2,y2,z2;
	if(abs(c)<EPS){
		x1=b;y1=-a;z1=0;
	}else{
		x1=c;y1=0;z1=-a;
	}
	vector<P> v;
	x2=y1*c-z1*b;y2=z1*a-x1*c;z2=x1*b-y1*a;
	number d1=sqrt(x1*x1+y1*y1+z1*z1),d2=sqrt(x2*x2+y2*y2+z2*z2);
	x1/=d1;y1/=d1;z1/=d1;x2/=d2;y2/=d2;z2/=d2;
	REP(i,n){
		xx[i]=x1*x[i]+y1*y[i]+z1*z[i];
		yy[i]=x2*x[i]+y2*y[i]+z2*z[i];
		//		cout<<xx[i]<<" "<<yy[i]<<endl;
	}
	if(n==1){
		printf("%.10lf\n",0.0);
		return;
	}
	/*
		for(number x=-10.0;x<10.0;x+=0.1){
		number y=ternaryY(x,v);
		cout<<x<<": "<<y<<" "<<calc(P(x,y),v)<<endl;
		}
		assert(false);
		*/
	//	return;
//	number c=largestCoveringCircle();
	number c=goldenSectionSearch();
	printf("%.10lf\n",sqrt(c));
	return;
}