/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <ctime>

#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define mp make_pair

using namespace std;

typedef long long int64;
typedef vector<int> vi;
typedef pair<int, int> ii;

int BUBEN = 30;
int BUBEN2 = 5;
int BUBEN3 = 20;

class TaskH {
 public:
  void solveOne(istream &in, ostream &out) {
    double start = clock() / (double) CLOCKS_PER_SEC;

    int n;
    in >> n;
    vector<int> x(n + 1);
    vector<int> y(n + 1);
    for (int i = 0; i <= n; ++i) {
      in >> x[i] >> y[i];
    }
    vector<double> offset;
    vector<double> len;
    vector<double> dx;
    vector<double> dy;
    offset.push_back(0);
    for (int i = 0; i < n; ++i) {
      double vx = x[i + 1] - x[i];
      double vy = y[i + 1] - y[i];
      double z = hypot(vx, vy);
      dx.push_back(vx / z);
      dy.push_back(vy / z);
      len.push_back(z);
      offset.push_back(offset.back() + z);
    }
    auto ternary = [&](const auto& func, double left, double right) {
      while (right - left > 1e-12 * max(1.0, right)) {
        double mleft = (2 * left + right) / 3;
        double mright = (left + 2 * right) / 3;
        double vleft = func(mleft);
        double vright = func(mright);
        if (vleft > vright) {
          right = mright;
        } else {
          left = mleft;
        }
      }
      return func((left + right) / 2);
    };
    double total = offset.back();

    auto where = [&](double pos) {
      int i = lower_bound(all(offset), pos) - offset.begin() - 1;
      if (i < 0) i = 0;
      if (i >= n) i = n - 1;
      return i;
    };

    auto evalBefore = [&](double pos) {
      int i = where(pos);
      double xi = x[i] + dx[i] * (pos - offset[i]);
      double yi = y[i] + dy[i] * (pos - offset[i]);

      double bestBefore = 1;
      for (int j = 0; j < i; ++j) {
        auto eval2 = [&](double t) {
          double xj = x[j] + dx[j] * t;
          double yj = y[j] + dy[j] * t;
          double direct = pos - (offset[j] + t);
          return direct / max(1e-7, hypot(xi - xj, yi - yj));
        };
        double cur = ternary(eval2, 0, len[j]);
        bestBefore = max(bestBefore, cur);
      }
      return bestBefore;
    };

    auto evalAfter = [&](double pos) {
      int i = where(pos);
      double xi = x[i] + dx[i] * (pos - offset[i]);
      double yi = y[i] + dy[i] * (pos - offset[i]);

      double bestAfter = 1;
      for (int j = i + 1; j < n; ++j) {
        auto eval2 = [&](double t) {
          double xj = x[j] + dx[j] * t;
          double yj = y[j] + dy[j] * t;
          double direct = (offset[j] + t) - pos;
          return direct / max(1e-7, hypot(xi - xj, yi - yj));
        };
        double cur = ternary(eval2, 0, len[j]);
        bestAfter = max(bestAfter, cur);
      }
      return bestAfter;
    };

    auto eval = [&](double pos) {
      return min(evalBefore(pos), evalAfter(pos));
    };

    double STEP = total;
    vector<tuple<double, int, double>> best;
    while (clock() / (double) CLOCKS_PER_SEC < start + 1) {
      STEP *= 0.5;
      for (double at = STEP; at <= total; at += STEP * 2) {
        best.emplace_back(eval(at), where(at), at);
      }
    }
    sort(all(best));

    auto reduce = [&]() {
      sort(all(best), [](const auto& a, const auto& b) {
        return get<0>(a) > get<0>(b);
      });
      int got = 0;
      vector<int> gotIn(n);
      for (int i = 0; i < best.size(); ++i) {
        if (got < BUBEN3 && gotIn[get<1>(best[i])] < BUBEN2) {
          best[got] = best[i];
          ++got;
          ++gotIn[get<1>(best[i])];
        }
      }
      best.resize(got);
    };

    while (clock() / (double) CLOCKS_PER_SEC < start + 3) {
      reduce();
      STEP *= 0.5;
      sort(all(best), [](const auto& a, const auto& b) {
        return get<2>(a) < get<2>(b);
      });
      int old = best.size();
      double prev = 0;
      for (int i = 0; i <= old; ++i) {
        double cur;
        if (i == old) {
          cur = total;
        } else {
          cur = get<2>(best[i]);
        }
        if (cur - prev > 3 * STEP) {
          double at = prev + STEP;
          best.emplace_back(eval(at), where(at), at);
          at = cur - STEP;
          best.emplace_back(eval(at), where(at), at);
        } else if (cur - prev > 2 * STEP) {
          double at = (2 * prev + cur) / 3;
          best.emplace_back(eval(at), where(at), at);
          at = (prev + 2 * cur) / 3;
          best.emplace_back(eval(at), where(at), at);
        } else if (cur - prev > STEP) {
          double at = (prev + cur) / 2;
          best.emplace_back(eval(at), where(at), at);
        }
        prev = cur;
      }
    }

    cerr << STEP << endl;

    double res = 0;
    for (const auto& x : best) {
      res = max(res, get<0>(x));
    }
    out << res << "\n";
  }

  void solve(std::istream &in, std::ostream &out) {
    out.precision(20);
    int nt = 1;
    for (int it = 0; it < nt; ++it) {
      solveOne(in, out);
    }
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  TaskH solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

using ll = long long;
using ld = long double;
using db = double;
using str = string; // yay python!

using pi = pair<int,int>;
using pl = pair<ll,ll>;
using pd = pair<db,db>;

using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;

#define tcT template<class T
// ^ lol this makes everything look weird but I'll try it
tcT> using V = vector<T>;
tcT, size_t SZ> using AR = array<T,SZ>;

// pairs
#define mp make_pair
#define f first
#define s second

// vectors
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound

// loops
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18; // not too close to LLONG_MAX
const ld PI = acos((ld)-1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1}; // for every grid problem!!
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

// helper funcs
constexpr int pct(int x) { return __builtin_popcount(x); } // # of bits set
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x))
ll cdiv(ll a, ll b) { return a/b+((a^b)>0&&a%b); } // divide a by b rounded up
ll fdiv(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // divide a by b rounded down

tcT> bool ckmin(T& a, const T& b) {
	return b < a ? a = b, 1 : 0; } // set a = min(a,b)
tcT> bool ckmax(T& a, const T& b) {
	return a < b ? a = b, 1 : 0; }

#define tcTU tcT, class U
tcTU> T fstTrue(T lo, T hi, U f) {
	hi ++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true
		T mid = lo+(hi-lo)/2;
		f(mid) ? hi = mid : lo = mid+1;
	}
	return lo;
}
tcTU> T lstTrue(T lo, T hi, U f) {
	lo --; assert(lo <= hi); // assuming f is decreasing
	while (lo < hi) { // find first index such that f is true
		T mid = lo+(hi-lo+1)/2;
		f(mid) ? lo = mid : hi = mid-1;
	}
	return lo;
}
tcT> void remDup(vector<T>& v) { // sort and remove duplicates
	sort(all(v)); v.erase(unique(all(v)),end(v)); }
tcTU> void erase(T& t, const U& u) { // don't erase
	auto it = t.find(u); assert(it != end(t));
	t.erase(u); } // element that doesn't exist from (multi)set

// INPUT
#define tcTUU tcT, class ...U
tcT> void re(complex<T>& c);
tcTU> void re(pair<T,U>& p);
tcT> void re(vector<T>& v);
tcT, size_t SZ> void re(AR<T,SZ>& a);

tcT> void re(T& x) { cin >> x; }
void re(db& d) { str t; re(t); d = stod(t); }
void re(ld& d) { str t; re(t); d = stold(t); }
tcTUU> void re(T& t, U&... u) { re(t); re(u...); }

tcT> void re(complex<T>& c) { T a,b; re(a,b); c = {a,b}; }
tcTU> void re(pair<T,U>& p) { re(p.f,p.s); }
tcT> void re(vector<T>& x) { trav(a,x) re(a); }
tcT, size_t SZ> void re(AR<T,SZ>& x) { trav(a,x) re(a); }

// TO_STRING
#define ts to_string
str ts(char c) { return str(1,c); }
str ts(const char* s) { return (str)s; }
str ts(str s) { return s; }
str ts(bool b) {
	#ifdef LOCAL
		return b ? "true" : "false";
	#else
		return ts((int)b);
	#endif
}
tcT> str ts(complex<T> c) {
	stringstream ss; ss << c; return ss.str(); }
str ts(vector<bool> v) {
	str res = "{"; F0R(i,sz(v)) res += char('0'+v[i]);
	res += "}"; return res; }
template<size_t SZ> str ts(bitset<SZ> b) {
	str res = ""; F0R(i,SZ) res += char('0'+b[i]);
	return res; }
tcTU> str ts(pair<T,U> p);
tcT> str ts(T v) { // containers with begin(), end()
	#ifdef LOCAL
		bool fst = 1; str res = "{";
		for (const auto& x: v) {
			if (!fst) res += ", ";
			fst = 0; res += ts(x);
		}
		res += "}"; return res;
	#else
		bool fst = 1; str res = "";
		for (const auto& x: v) {
			if (!fst) res += " ";
			fst = 0; res += ts(x);
		}
		return res;

	#endif
}
tcTU> str ts(pair<T,U> p) {
	#ifdef LOCAL
		return "("+ts(p.f)+", "+ts(p.s)+")";
	#else
		return ts(p.f)+" "+ts(p.s);
	#endif
}

// OUTPUT
tcT> void pr(T x) { cout << ts(x); }
tcTUU> void pr(const T& t, const U&... u) {
	pr(t); pr(u...); }
void ps() { pr("\n"); } // print w/ spaces
tcTUU> void ps(const T& t, const U&... u) {
	pr(t); if (sizeof...(u)) pr(" "); ps(u...); }

// DEBUG
void DBG() { cerr << "]" << endl; }
tcTUU> void DBG(const T& t, const U&... u) {
	cerr << ts(t); if (sizeof...(u)) cerr << ", ";
	DBG(u...); }
#ifdef LOCAL // compile with -DLOCAL, chk -> fake assert
	#define dbg(...) cerr << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
	#define chk(...) if (!(__VA_ARGS__)) cerr << "Line(" << __LINE__ << ") -> function(" \
		 << __FUNCTION__  << ") -> CHK FAILED: (" << #__VA_ARGS__ << ")" << "\n", exit(0);
#else
	#define dbg(...) 0
	#define chk(...) 0
#endif

// FILE I/O
void setIn(str s) { freopen(s.c_str(),"r",stdin); }
void setOut(str s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { cin.tie(0)->sync_with_stdio(0); }
void setIO(str s = "") {
	unsyncIO();
	// cin.exceptions(cin.failbit);
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

/**
 * Description: Use in place of \texttt{complex<T>}.
 * Source: http://codeforces.com/blog/entry/22175, KACTL
 * Verification: various
 */

using T = db;
int sgn(T a) { return (a>0)-(a<0); }
T sq(T a) { return a*a; }

typedef pair<T,T> P; typedef vector<P> vP;
T norm(const P& p) { return sq(p.f)+sq(p.s); }
T abs(const P& p) { return sqrt(norm(p)); }
T arg(const P& p) { return atan2(p.s,p.f); }
P conj(const P& p) { return P(p.f,-p.s); }
P perp(const P& p) { return P(-p.s,p.f); }
P dir(T ang) { return P(cos(ang),sin(ang)); }

P operator-(const P& l) { return P(-l.f,-l.s); }
P operator+(const P& l, const P& r) {
	return P(l.f+r.f,l.s+r.s); }
P operator-(const P& l, const P& r) {
	return P(l.f-r.f,l.s-r.s); }
P operator*(const P& l, const T& r) {
	return P(l.f*r,l.s*r); }
P operator*(const T& l, const P& r) { return r*l; }
P operator/(const P& l, const T& r) {
	return P(l.f/r,l.s/r); }
P operator*(const P& l, const P& r) {
	return P(l.f*r.f-l.s*r.s,l.s*r.f+l.f*r.s); }
P operator/(const P& l, const P& r) {
	return l*conj(r)/norm(r); }
P& operator+=(P& l, const P& r) { return l = l+r; }
P& operator-=(P& l, const P& r) { return l = l-r; }
P& operator*=(P& l, const T& r) { return l = l*r; }
P& operator/=(P& l, const T& r) { return l = l/r; }
P& operator*=(P& l, const P& r) { return l = l*r; }
P& operator/=(P& l, const P& r) { return l = l/r; }

P unit(const P& p) { return p/abs(p); }
T dot(const P& a, const P& b) { return a.f*b.f+a.s*b.s; }
T cross(const P& a, const P& b) { return a.f*b.s-a.s*b.f; }
T cross(const P& p, const P& a, const P& b) {
	return cross(a-p,b-p); }
P reflect(const P& p, const P& a, const P& b) {
	return a+conj((p-a)/(b-a))*(b-a); }
P foot(const P& p, const P& a, const P& b) {
	return (p+reflect(p,a,b))/(T)2; }
bool onSeg(const P& p, const P& a, const P& b) {
	return cross(a,b,p) == 0 && dot(p-a,p-b) <= 0; }

int N;
vP poly;
vd dists;

void genDists() {
	dists = {0}; F0R(i,N) dists.pb(dists.bk+abs(poly[i]-poly[i+1]));
}

void rev() {
	db maxY = poly.bk.s;
	reverse(all(poly));
	genDists();
	trav(t,poly) t.s = maxY-t.s;
}

vP ans;
db vel;

P ternary(db lo, db hi, function<db(db)> eval) {
	F0R(_,50) {
		db m1 = (2*lo+hi)/3;
		db m2 = (lo+2*hi)/3;
		if (eval(m1) < eval(m2)) hi = m2;
		else lo = m1;
	}
	return {lo,eval(lo)};
}

void tri(int l, int r) {
	dbg("TRYING",l,r,poly);
	assert(l < r);
	P dirl = unit(poly[l+1]-poly[l]), dirr = unit(poly[r+1]-poly[r]);
	auto eval = [&](db t1, db t2) {
		P pos1 = poly[l]+t1*dirl;
		P pos2 = poly[r]+t2*dirr;
		return abs(pos2-pos1)/((dists[r]+t2)-(dists[l]+t1));
	};
	function<db(db)> getMin = [&](db rig) {
		return ternary(0,dists[l+1]-dists[l],[&](db x) { return eval(x,rig); }).s;
	};
	P mid = ternary(0,dists[r+1]-dists[r],getMin);
	// dbg("HA",mid);
	// dbg("???",l,r,mid);
	if (mid.s > 1/vel) return;
	// dbg("WHOOPS",mid,dists[r+1]-dists[r]);
	db L, R;
	{
		db lo = 0, hi = mid.f;
		F0R(_,50) {
			db m = (lo+hi)/2;
			if (getMin(m) < 1/vel) hi = m;
			else lo = m;
		}
		L = lo;
	}
	// dbg("MIDDLE");
	{
		db lo = mid.f, hi = dists[r+1]-dists[r];
		F0R(_,50) {
			db m = (lo+hi)/2;
			if (getMin(m) < 1/vel) lo = m;
			else hi = m;
		}
		R = lo;
	}
	// dbg("END",L,R);
	ans.pb({dists[r]+L,dists[r]+R});
}

vP ranges() {
	// dbg("RANGES");
	ans.clear();
	F0R(i,N) FOR(j,i+1,N) tri(i,j);
	sort(all(ans));
	vP ANS;
	trav(t,ans) {
		if (!sz(ANS) || ANS.bk.s < t.f) ANS.pb(t);
		else ckmax(ANS.bk.s,t.s);
	}
	return ANS;
}

bool intervalIsect(P a, P b) {
	if (a.s < b.f) return 0;
	if (b.s < a.f) return 0;
	return 1;
}

bool escape(db mid) {
	vel = mid;
	vP lef = ranges();
	rev();
	vP rig = ranges();
	rev();
	trav(t,rig) t = {dists.bk-t.s,dists.bk-t.f};
	reverse(all(rig));
	dbg("ESCAPE",mid);
	dbg(lef); dbg(rig);
	int il = 0, ir = 0;
	while (il < sz(lef) && ir < sz(rig)) {
		if (intervalIsect(lef[il],rig[ir])) return 1;
		if (lef[il].f < rig[ir].f) il ++;
		else ir ++;
	}
	return 0;
}

int main() {
	setIO(); re(N); poly.rsz(N+1); re(poly);
	genDists();
	db lo = 1, hi = 1e6;
	F0R(i,50) {
		db mid = (lo+hi)/2;
		if (escape(mid)) lo = mid;
		else hi = mid;
	}
	cout << fixed << setprecision(9) << lo;
	// you should actually read the stuff at the bottom
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* DON'T GET STUCK ON ONE APPROACH
*/


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<fstream>
typedef long long Int;
using namespace std;
Int H,M;
int K;
Int h1,m1,h2,m2;
Int Comp(Int h,Int m);
Int Cal(Int h,Int m);
int CalDigit(Int so);
Int Solve(Int so,int d);
int main(){
    /*
    cin>>H>>M>>K;
    cin>>h1>>m1>>h2>>m2;
    if (Comp(h1,m1)<=Comp(h2,m2))
    {
       cout<<Cal(h2,m2)-Cal(h1,m1)<<endl;
    }else
    {
        cout<<Cal(H-1,M-1)-Cal(h1,m1)+Cal(h2,m2)+(CalDigit(M-1)+CalDigit(H-1)>=K)<<endl;
    }
    */
    char s[100];
    while (scanf("%s",s))
    {
          cout<<s<<endl;
    }
    //system("pause");
    return 0;
}

Int Cal(Int h,Int m)
{
    int d=CalDigit(M-1);
    Int Ans= Solve(h,K-d);
    Ans=Ans+Solve(m,K)+h*Solve(M-1,K);
    return  Ans;
}

Int Solve(Int so,int d)
{
    for (int i=0;i<d-1;i++)
    {
        so/=10;
    }
    return so;
}
int CalDigit(Int so)
{
    int d=0;
    while (so>0L)
    {
          d++;
          so/=10;
    }
    return d;
}
Int Comp(Int h,Int m)
{
    return h*H+m;
}


/*Studied from WJMZBMR*/
#include<iostream>
using namespace std;

int h,m,k,h1,m1,h2,m2;

int cut(int a,int b){for(;--b;a/=10);return a;}

long long ch(int a){for(int ret=0;;a/=10)if(a%10)ret++;else if(!a)return ret;}

long long calc(int a,int b){return cut(a,k-ch(m-1))+a*cut(m-1,k)+cut(b,k);}

int main()
{
	cin>>h>>m>>k>>h1>>m1>>h2>>m2;
	if(h1<=h2||h1==h2&&m1<=m2)cout<<calc(h2,m2)-calc(h1,m1)<<endl;
	else cout<<calc(h-1,m-1)+(ch(h-1)+ch(m-1)>=k)-calc(h1,m1)+calc(h2,m2)<<endl;
	return 0;
}


#include <iostream>

int main()
{
      cout << "hi";
      return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;

const int N = 100005, M = 100005;

int n, m, t1, t2, top, v[M], next[M], head[N], d[N];
bool vis[N];

int abss(const int i) {return i < 0 ? -i : i;}

int gcd(const int x, const int y) {
  if (x == 0 || y == 0) return x + y;
  int a = x, b = y, c = a % b;
  while (c) {
	  a = b;
	  b = c;
	  c = a % b;
	}
	return b;
}

void dfs(const int i) {
  vis[i] = true;
  for (int j = head[i]; j; j = next[j]) {
	  if (!vis[v[j]]) {
		  d[v[j]] = d[i] + 1;
		  dfs(v[j]);
		}
	}
}

int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; ++i) {
		scanf("%d %d", &t1, &t2);
		++top; v[top] = t2; next[top] = head[t1]; head[t1] = top;
	}
	dfs(1);
	int tmp = 0;
	for (int i = 1; i <= n; ++i) {
		//printf("D%d %d\n", i, d[i]);
		for (int j = head[i]; j; j = next[j]) {
		  tmp = gcd(tmp, abss(d[v[j]] - d[i] - 1));
		}
	}
	if (tmp == 0) tmp = n;
	printf("%d\n", tmp);
	int cnt = 0;
	for (int i = 1; i <= n; ++i) if (d[i] % tmp == 0) ++cnt;
	printf("%d\n", cnt);
	for (int i = 1; i <= n; ++i) if (d[i] % tmp == 0) printf("%d ", i);
	return 0;
}


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

using namespace std;
typedef long long LL;
typedef vector<int> vi;
#define FOR(i, n) for(int i = 0; i < (int)(n); ++i)

void ASS(bool b)
{
	if (!b)
		++*(int*)0;
}

const int N = 1 << 17;
int G;
int f[N];
//int OnStack[N];
vi g[N];

int gcd(int a, int b)
{
	if (a < 0) a = -a;
	if (b < 0) b = -b;
	while (a)
	{
		int c = b % a;
		b = a;
		a = c;
	}
	return b;
}

int mabs(int x)
{
	return max(x, -x);
}

void dfs(int x, int d)
{
	f[x] = d;
	FOR(i, g[x].size())
	{
		int y = g[x][i];
		if (f[y])
			G = gcd(G, mabs(f[y] - d) - 1);
		else
			dfs(y, d + 1);
	}
}

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	FOR(i, m)
	{
		int x, y;
		scanf("%d %d", &x, &y);
		g[x].push_back(y);
	}
	dfs(1, 1);
//	if (G == 0)
	ASS(g != 0);

	//memset(f, 0, sizeof(f));
	//dfs2(x, 0);

	vi v;
	for (int i = 1; i <= n; i++)
		if (f[i] && (f[i] - 1) % G == 0)
			v.push_back(i);

	printf("%d\n", G);
	printf("%d\n", v.size());
	FOR(i, v.size())
	{
		if (i) printf(" ");
		printf("%d", v[i]);
	}
	printf("\n");

	return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;

const int N = 100005, M = 100005;

int n, m, t1, t2, top, v[M], next[M], head[N], d[N];
bool vis[N];

int abss(const int i) {return i < 0 ? -i : i;}

int gcd(const int x, const int y) {
  if (x == 0 || y == 0) return x + y;
  int a = x, b = y, c = a % b;
  while (c) {
	  a = b;
	  b = c;
	  c = a % b;
	}
	return b;
}

void dfs(const int i) {
  vis[i] = true;
  for (int j = head[i]; j; j = next[j]) {
	  if (!vis[v[j]]) {
		  d[v[j]] = d[i] + 1;
		  dfs(v[j]);
		}
	}
}

int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; ++i) {
		scanf("%d %d", &t1, &t2);
		++top; v[top] = t2; next[top] = head[t1]; head[t1] = top;
	}
	dfs(1);
	int tmp = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = head[i]; j; j = next[j]) {
		  tmp = gcd(tmp, abss(d[i] + d[v[j]] - 1));
		}
	}
	printf("%d\n", tmp);
	int cnt = 0;
	for (int i = 1; i <= n; ++i) if (d[i] % tmp == 0) ++cnt;
	printf("%d\n", cnt);
	for (int i = 1; i <= n; ++i) if (d[i] % tmp == 0) printf("%d ", i);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 2.1e5;
int n, m, g;
vector<int> a[N];
int d[N];

void dfs(int v) {
  for (int x : a[v]) {
    if (x > 1 && !d[x]) {
      d[x] = d[v] + 1;
      dfs(x);
    } else if (d[x] != d[v] + 1) {
      int dd = abs(d[v] + 1 - d[x]);
      if (!g) g = dd; else g = __gcd(g, dd);
    }
  }
}

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    a[x].push_back(y);
  }
  dfs(1);
  if (!g) g = *max_element(d+1, d+n+1);
  vector<int> ans;
  for (int i = 1; i <= n; ++i) {
    if (d[i] % g == 0) ans.push_back(i);
  }
  cout << g << endl << ans.size() << endl;
  for (int i = 0; i < n; ++i)
    cout << and[i] << (i == n-1 ? "\n" : " ");
}


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

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

#define int long long
#define ll long long
#define mp make_pair
#define f first
#define s second
#define pii pair<int, int>
#define all(_v) _v.begin(), _v.end()
#define sz(a) ((int)a.size())
#define what_is(x) cout << #x << " is " << x << endl;
typedef long double ld;

const ll inf = 1e17 + 7;

bool win(int a, int b) {
    return a != 0;
}

bool lose(int a, int b) {
    return a % (b + 1) % 2 == 0;
}

void solve() {
    int a, b;
    cin >> a >> b;
    vector<pii> c;

    while(a != 0 && b != 0) {
        if (a < b) swap(a, b);
        c.emplace_back(a / b, b);
        a = a % b;
    }

    bool to_win = true;
    for(int i = c.size() - 1;i >= 0;i--) {
        if (to_win) {
            to_win = !win(c[i].first, c[i].second);
        }else {
            to_win = !lose(c[i].first, c[i].second);
        }
    }

    cout << (!to_win ? "First" : "Second") << endl;
}

signed main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    cout.precision(10);

    int t;
    cin >> t;
    while(t--)
        solve();
}


E#include<cstdio>
#include<algorithm>
using namespace std;
#define i64 __int64
int d[110][110];
int dp(int a,int b)
{
    if(d[a][b]!=-1) return d[a][b];
    if(!b)  return d[a][b]=0;
    if(a%b==0)  return d[a][b]=1;
    if(!dp(b,a%b))  return d[a][b]=1;
    int cur=b;
    while(cur<=a)
    {
        if(!dp(max(a-cur,b),min(a-cur,b)))
            return d[a][b]=1;
        cur*=a;
    }
    return d[a][b]=0;
}
bool dfs(i64 a,i64 b)
{
    if(b==0)    return false;
    if(a%(b*2)<b)   return true;
    return !dfs(b,a%b);
}
int main()
{
   // memset(d,-1,sizeof(d));
    int n;
 /*   while(scanf("%d",&n)!=EOF)
    {
        for(int i=n;i<=100;++i)if(!dfs(i,n))
            printf("%d %d\n",i,i%(2*n));
    }*/
    i64 a,b;
    scanf("%d",&n);
    while(n--)
    {
        //if(n>20)continue;
        if(n==20){    printf("First\n");    break;    }
        scanf("%I64d %I64d",&a,&b);
        if(dfs(max(a,b),min(a,b)))
            printf("First\n");
        else
            printf("Second\n");
    }
    return 0;
}


#include <cstdio>
#include <iostream>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pii;

map<pii,bool> cache;

bool gana(ll a,ll b){
  map<pii,bool>::iterator it;
  if((it=cache.find(pii(a,b)))!=cache.end()) return it->second;
  if(b<a) swap(a,b);
  if(a==0) return false;

  if(!gana(a,b%a)) { cache[pii(a,b)]=true; return true;}

  ll k=a;
  while(b-k>=0){
    if(!gana(a,b-k)){  cache[pii(a,b)]=true; return true;}
    k*=a;
  }

  cache[pii(a,b)]=false;
  return false;
}

int main(){
  int T;
  cin>>T;
  ll a,b;
  for(int i=0;i<T;i++){
    cin >> a >> b ;
    if(gana(a,b)){
      puts("First");
    }else puts("Second");
  }

}


#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%I64d",&x)
#define ss(s)	scanf("%s",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;
const int N = 3e5;
vi g[N];
int a[N];
int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);
map<pll, int> dp;
int go(ll a, ll b){
    if (a < b) swap(a, b);
    if (dp.find({a, b}) != dp.end()) return dp[{a, b}];
    if (b == 0) return 0;
    if (b == 1) return 1;
    int ans = go(a%b, b);
    if (!ans) return dp[{a, b}] = 1;
    ll b_ = b;
    while(b_ < a){
        if ( go(a-b_, b_) == 0) return dp[{a, b}] = 1;
        if (a/b_ > b)
            b_ *= b;
        else break;
    }
    return dp[{a, b}] = 0;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int i,n,k,j;
	int t;
	cin>>t;
	while(t--){
        ll x, y;
        cin>>x>>y;
        int win = go(x, y);
        if (win) cout<<"First\n";
        else cout<<"Second\n";
	}

	return 0;
}

int mpow(int base, int exp) {
base %= mod;
int result = 1;
while (exp > 0) {
if (exp & 1) result = ((ll)result * base) % mod;
base = ((ll)base * base) % mod;
exp >>= 1;
}
return result;
}

void ipgraph(int n, int m){
int i, u, v;
while(m--){
	cin>>u>>v;
	g[u-1].pb(v-1);
	g[v-1].pb(u-1);
}
}

void dfs(int u, int par){
for(int v:g[u]){
	if (v == par) continue;
	dfs(v, u);
}
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <string.h>
#include <fstream>

using namespace std;

#define LL long long
#define N 1000002
#define M 1000100
#define MP make_pair
#define Pi acos(-1.0)
//#pragma comment(linker,"/STACK:1024000000,1024000000")
#define ls (rt << 1)
#define rs (ls | 1)
#define md ((ll+rr)/2)
#define lson ll, md, ls
#define rson md+1, rr, rs
#define mod 1000000007
#define inf 0x3f3f3f3f
#define sqr(x) ((x)*(x))
#define eps 1e-6
#define uLL unsigned long long
#define ui unsigned int
LL powmod(LL a,LL b) {LL res=1;for(;b;b>>=1){if(b&1)res=res*a;a=a*a;}return res;}
#define F(x) ((x)/3+((x)%3 == 1 ? 0 : tb))
#define G(x) ((x)<tb ? (x)*3+1 : ((x) - tb)*3+2)
#define lowbit(x) ((x)&(-x))
#define fi first
#define se second
#define pii pair<int,int>
#define pli pair<LL,int>
#define pb push_back
#define MP make_pair
LL gcd(LL x,LL y){
    while(y){
        LL t = x % y;
        x = y;
        y = t;
    }
    return x;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

ui read()
{
    ui x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

int n, tot, dfn[N], fa[N][20], ed[N], dep[N];
int bel[N], belong[N];
vector<int> g[N];

void dfs(int u, int id)
{
	bel[u] = id;
	dfn[u] = ++tot;
	for(int i = 1; i < 20; i++)
	{
		fa[u][i] = fa[fa[u][i - 1]][i - 1];
	}
	for(auto v : g[u])
	{
		if(v == fa[u][0]) continue;
		fa[v][0] = u;
		dep[v] = dep[u] + 1;
		dfs(v, id);
	}
	ed[u] = tot;
}

int lca(int u, int v)
{
	if(bel[u] != bel[v]) return -1;
	if(dep[u] > dep[v]) swap(u, v);
	for(int i = 0; dep[u] != dep[v]; i++)
		if((dep[v] - dep[u]) >> i & 1) v = fa[v][i];
	if(u == v) return v;
	for(int i = 19; i >= 0; i--)
		if(fa[u][i] != fa[v][i])
		{
			u = fa[u][i];
			v = fa[v][i];
		}
	return fa[u][0];
}

inline bool cmp(int i, int j){return dfn[i] < dfn[j];}

struct BCC
{
	int fst[N], nxt[M], vv[M], e;
	int n, belong[N], dfn[N], low[N], stk[N], tot, in[N];
	void init()
	{
		e = 0;
		memset(fst, -1, sizeof fst);
		memset(dfn, -1, sizeof dfn);
	}

	void add(int u, int v)
	{
		vv[e] = v, nxt[e] = fst[u], fst[u] = e++;
		vv[e] = u, nxt[e] = fst[v], fst[v] = e++;
	}

	void dfs(int u, int f = -1)
	{
		int tmp = tot;
		stk[dfn[u] = low[u] = tot++] = u;
		in[u] = 1;
		for(int i = fst[u]; ~i; i = nxt[i])
		{
			if(i == f) continue;
			int v = vv[i];
			if(dfn[v] == -1) dfs(v, i ^ 1), chkmin(low[u], low[v]);
			else if(in[v]) chkmin(low[u], dfn[v]);
		}
		if(dfn[u] == low[u])
		{
			while(tot != tmp)
			{
				tot--;
				in[stk[tot]] = 0;
				belong[stk[tot]] = n;
			}
			n++;
		}
	}
}bcc;

int stk[N];

int main()
{
	n = read();
	int m = read(), q = read();
	bcc.init();
	vector< pii > E;
	for(int i = 0; i < m; i++)
	{
		int u = read(), v = read();
		bcc.add(u, v);
		E.pb(MP(u,v));
	}
	bcc.n = bcc.tot = 1;
	for(int i = 1; i <= n; i++)
		if(bcc.dfn[i] == -1) bcc.dfs(i);
	for(int i = 1; i <= n; i++)
	{
		belong[i] = bcc.belong[i];
	}

	for(auto x : E)
	{
		int u = x.fi, v = x.se;
		if(belong[u] != belong[v])
		{
			g[belong[u]].pb(belong[v]), g[belong[v]].pb(belong[u]);
		}
	}

	for(int i = 1; i <= n; i++)
		if(!dfn[i]) dfs(i, i);

	int R = 0, id = 1;
	for(; q; q--, id++)
	{
		int nn = read(), mm = read();
		vector<int> x;
		x.resize(nn);
		for(int i = 0; i < nn; i++)
		{
			x[i] = (read() + R) % n, x[i] = belong[x[i] == 0 ? n : x[i]];
		}
		vector< pii > ee;
		vector< int > V(x);
		for(int i = 0 ; i < mm; i++)
		{
			int u = (read() + R) % n, v = (read() + R) % n;
			u = belong[u == 0 ? n : u], v = belong[v == 0 ? n : v];
			ee.pb(MP(u, v));
			V.pb(u) , V.pb(v);
		}
		sort(V.begin(), V.end(), cmp);
		nn = V.size();
		for(int i = 0; i < nn - 1; i++)
		{
			if(V[i] == V[i + 1]) continue;
			int lc = lca(V[i], V[i + 1]);
			if(lc > 0) V.pb(lc);
		}
		sort(V.begin(), V.end(), cmp);
		V.resize(unique(V.begin(), V.end()) - V.begin());
		nn = V.size();

		for(int i = 0; i < nn; i++)
			bcc.fst[V[i]] = -1; bcc.e = 0;
		tot = 0;
		for(int i = 0; i < nn; i++)
		{
			int u = V[i];
			while(tot && !(dfn[stk[tot - 1]] <= dfn[u] && dfn[u] <= ed[stk[tot - 1]])) tot--;
			if(tot) { bcc.add(u, stk[tot - 1]);}
			stk[tot++] = u;
		}
		for(auto u : ee)
			bcc.add(u.fi, u.se);
		bcc.tot = bcc.n = 1;
		for(int i = 0; i < nn; i++) bcc.dfn[V[i]] = -1;
		for(int i = 0; i < nn; i++)
			if(bcc.dfn[V[i]] == -1) bcc.dfs(V[i]);
		bool ans = 1;

		for(int i = 1; i < x.size(); i++)
			if(bcc.belong[x[i]] != bcc.belong[x[0]])
			{
				ans = 0;
				break;
			}
		puts(ans ? "YES" : "NO");
		R = (R + (ans ? id : 0)) % n;
	}
	return 0;

}


#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>

using namespace std;

int nmem=0;
int *memdir[5000000];
int memval[5000000];

void asigna(int &a,int b)
{
  memdir[nmem]=&a;
  memval[nmem]=a;
  a=b;
  nmem++;
  if (nmem>=5000000) {
    cout<<"pifia"<<endl;
    exit(0);
  }
}

void recupera()
{
  while (nmem>0) {
    nmem--;
    *(memdir[nmem])=memval[nmem];
  }
}

const int limite=600005;

void inserta(vector<int> &alcanza,int pos,int val,int primero)
{
  pos+=primero;
  asigna(alcanza[pos],val);
  while (pos>1) {
    pos/=2;
    asigna(alcanza[pos],max(alcanza[2*pos],alcanza[2*pos+1]));
  }
}

int alcanzaanterior(vector<int> &alcanza,int pos,int primero)
{
  pos+=primero;
  if (alcanza[pos]) return pos-primero;
  for (;;) {
    if (pos==1) return -1;
    if (pos%2==1 and alcanza[pos-1]) {
      pos--;
      while (pos<primero)
	if (alcanza[2*pos+1]) pos=2*pos+1;
	else pos=2*pos;
      return pos-primero;
    }
    pos/=2;
  }
  return -1;
}

int identificador[limite];

int computaidentificador(int u)
{
  int &idu=identificador[u];
  if (idu==0) return u;
  asigna(idu,computaidentificador(idu));
  return idu;
}

void fusiona(int u,int v)
{
  //cout<<"fusiona "<<u<<" "<<v<<endl;
  u=computaidentificador(u);
  v=computaidentificador(v);
  if (u==v) return;
  asigna(identificador[u],v);
}

pair<int,int> minimo[1<<21];

void inserta(int pos,int val,int u)
{
  pos+=1<<20;
  minimo[pos]=pair<int,int> (val,u);
  while (pos>1) {
    pos/=2;
    minimo[pos]=min(minimo[2*pos],minimo[2*pos+1]);
  }
}

int minimoentre(int pos0,int pos1)
{
  if (pos0>pos1) swap(pos0,pos1);
  pos0+=1<<20;
  pos1+=1<<20;
  if (pos0==pos1) return minimo[pos0].second;
  pair<int,int> mini0=minimo[pos0];
  pair<int,int> mini1=minimo[pos1];
  while (pos0+1<pos1) {
    if (pos0%2==0) mini0=min(mini0,minimo[pos0+1]);
    pos0/=2;
    if (pos1%2==1) mini1=min(mini1,minimo[pos1-1]);
    pos1/=2;
  }
  return min(mini0,mini1).second;
}

int n,m,casos;
vector<int> g[limite];
vector<pair<int,int> > gg[limite];
vector<int> alcanza[limite];
vector<int> elemento[limite];
int au[limite],av[limite],apendiente[limite];
int superidentificador[limite];
int superpadre[limite];
int superraiz[limite];
int superposicion[limite];
int primero[limite];
int tope[limite];
int visto[limite];
int numnodos[limite];
int profundidad[limite];

int s[limite];

int posle[limite];
int nrecorrido=0;

int ancestro(int u,int v)
{
  return minimoentre(posle[u],posle[v]);
}

void eliminapadre(int u,int p,int prof)
{
  visto[u]=1;
  profundidad[u]=prof;
  posle[u]=nrecorrido;
  inserta(nrecorrido++,profundidad[u],u);
  vector<int> &ar=g[u];
  vector<int> nextar;
  numnodos[u]=1;
  for (int i=0;i<int(ar.size());i++) {
    int v=ar[i];
    if (v!=p) {
      eliminapadre(v,u,prof+1);
      numnodos[u]+=numnodos[v];
      nextar.push_back(v);
      inserta(nrecorrido++,profundidad[u],u);
    }
  }
  ar=nextar;
}

void genera(int u,int sr,int sp)
{
  vector<int> lista;
  lista.push_back(u);
  for (;;) {
    vector<int> &ar=g[u];
    int nextu=0;
    for (int i=0;i<int(ar.size());i++) {
      int v=ar[i];
      if (2*numnodos[v]>=numnodos[u]) nextu=v;
      else genera(v,sr,u);
    }
    if (nextu==0) break;
    u=nextu;
    lista.push_back(u);
  }
  u=lista[0];
  {
    int nn=int(lista.size())+3;
    primero[u]=1;
    while (nn>0) {
      nn/=2;
      primero[u]*=2;
    }
    tope[u]=2*primero[u];
  }
  alcanza[u]=vector<int> (tope[u],0);
  elemento[u]=vector<int> (tope[u],0);
  for (int i=0;i<int(lista.size());i++) {
    int v=lista[i];
    superposicion[v]=i+1;
    superidentificador[v]=u;
    superpadre[v]=sp;
    superraiz[v]=sr;
    elemento[u][superposicion[v]]=v;
  }
}

void eliminaanteriores(int u)
{
  //cout<<"eliminaanteriores "<<u<<endl;
  int idu=superidentificador[u];
  vector<int> &alcanzaidu=alcanza[idu];
  int primeroidu=primero[idu];
  int posant=alcanzaanterior(alcanzaidu,superposicion[u],primeroidu);
  //cout<<"posant "<<posant<<" "<<alcanzaidu[primeroidu+posant]<<endl;
  if (posant==-1 or posant==0) return;
  inserta(alcanzaidu,posant,0,primeroidu);
  eliminaanteriores(u);
}

int cas=0;

void juntarancestro(int u,int w)
{
  //if (cas==11) cout<<"juntarancestro "<<u<<" "<<w<<endl;
  if (u==w) return;
  int idu=superidentificador[u];
  vector<int> &alcanzaidu=alcanza[idu];
  int primeroidu=primero[idu];
  if (superpadre[u]!=superpadre[w]) {
    if (alcanzaidu[primeroidu]<superposicion[u]) {
      int posant=alcanzaanterior(alcanzaidu,superposicion[u],primeroidu);
      if (posant==-1)
	inserta(alcanzaidu,0,superposicion[u],primeroidu);
      else {
	int nextpos=max(superposicion[u],alcanzaidu[primeroidu+posant]);
	eliminaanteriores(u);
	inserta(alcanzaidu,0,nextpos,primeroidu);
      }
    }
    juntarancestro(superpadre[u],w);
  } else {
    int posant=alcanzaanterior(alcanzaidu,superposicion[u],primeroidu);
    if (posant==-1) {
      inserta(alcanzaidu,superposicion[w],superposicion[u],primeroidu);
    } else if (posant<=superposicion[w]) {
      if (alcanzaidu[primeroidu+posant]<superposicion[w])
	inserta(alcanzaidu,superposicion[w],superposicion[u],primeroidu);
      else if (alcanzaidu[primeroidu+posant]<superposicion[u])
	inserta(alcanzaidu,posant,superposicion[u],primeroidu);
    } else if (alcanzaidu[primeroidu+posant]<=superposicion[u]) {
      inserta(alcanzaidu,posant,0,primeroidu);
      juntarancestro(u,w);
    } else {
      int nextpos=alcanzaidu[primeroidu+posant];
      inserta(alcanzaidu,posant,0,primeroidu);
      juntarancestro(elemento[idu][nextpos],w);
    }
  }
}

void juntar(int u,int v)
{
  //cout<<"juntar "<<u<<" "<<v<<endl;
  int w=ancestro(u,v);
  juntarancestro(u,w);
  juntarancestro(v,w);
}

int obtenerancestro(int u)
{
  int idu=superidentificador[u];
  vector<int> &alcanzaidu=alcanza[idu];
  int primeroidu=primero[idu];
  if (superposicion[u]<=alcanzaidu[primeroidu])
    return obtenerancestro(superpadre[u]);
  int posant=alcanzaanterior(alcanzaidu,superposicion[u],primeroidu);
  if (posant==-1 or alcanzaidu[primeroidu+posant]<superposicion[u])
    return u;
  return elemento[idu][posant];
}

int obteneridentificadorexterno(int u)
{
  int idu=obtenerancestro(u);
  //cout<<"obtenerancestro "<<u<<" "<<idu<<endl;
  idu=computaidentificador(idu);
  //cout<<"obteneridentificadorexterno "<<u<<" "<<idu<<endl;
  return idu;
}

void fusionaexterno(int u,int v)
{
  //cout<<"fusionaexterno "<<u<<" "<<v<<endl;
  u=obteneridentificadorexterno(u);
  v=obteneridentificadorexterno(v);
  fusiona(u,v);
}

int R=0;
int rotate(int element)
{
  element=(element+R)%n;
  if (element==0)
    element=n;
  return element;
}

int numids=0;
vector<pair<int,int> > paresidnodo[limite];
int veo[limite];
int numraices;
int raices[2*limite];

void eliminarepes()
{
  if (numraices==0) return;
  sort(raices,raices+numraices);
  int last=0;
  for (int i=1;i<numraices;i++)
    if (raices[i]!=raices[last])
      raices[++last]=raices[i];
  numraices=last+1;
}

void recogearistas(int u,int prof)
{
  //cout<<"recogearistas "<<u<<" "<<prof<<" "<<numids<<endl;
  vector<pair<int,int> > &ar=gg[u];
  for (int i=0;i<int(ar.size());i++) {
    int v=ar[i].first;
    int ida=ar[i].second;
    if (profundidad[u]+1==profundidad[v] and veo[v]<profundidad[u])
      recogearistas(v,prof);
    else if (profundidad[v]<profundidad[u] and prof<=profundidad[v]) {
      int uu=au[ida];
      int vv=av[ida];
      int ru=superraiz[uu];
      int rv=superraiz[vv];
      paresidnodo[ru].push_back(pair<int,int> (numids,uu));
      paresidnodo[rv].push_back(pair<int,int> (numids,vv));
      apendiente[ida]=1;
    }
  }
}

void calcula(int u,int p,int prof)
{
  //cout<<"calcula "<<u<<" "<<p<<" "<<prof<<endl;
  bool vistop=false;
  profundidad[u]=prof;
  veo[u]=prof;
  vector<pair<int,int> > &ar=gg[u];
  for (int i=0;i<int(ar.size());i++) {
    int v=ar[i].first;
    if (v==p and not vistop) {
      vistop=true;
    } else if (profundidad[v]) {
      veo[u]=min(veo[u],profundidad[v]);
    } else {
      calcula(v,u,prof+1);
      veo[u]=min(veo[u],veo[v]);
      if (profundidad[u]<veo[v]) {
	recogearistas(v,prof+1);
	numids++;
      } else if (profundidad[u]==veo[v]) {
	recogearistas(v,prof);
	numids++;
      }
    }
  }
}

int main()
{
  ios::sync_with_stdio(false);
  cin>>n>>m>>casos;
  for (int i=0;i<m;i++) {
    cin>>au[i]>>av[i];
    if (au[i]!=av[i]) {
      int idu=computaidentificador(au[i]);
      int idv=computaidentificador(av[i]);
      if (idu==idv) apendiente[i]=1;
      else {
	g[au[i]].push_back(av[i]);
	g[av[i]].push_back(au[i]);
	fusiona(au[i],av[i]);
      }
    }
  }
  for (int u=1;u<=n;u++) {
    if (not visto[u]) {
      //cout<<"tratando "<<u<<endl;
      eliminapadre(u,0,1);
      genera(u,u,0);
    }
  }
  /*
  for (int u=1;u<=n;u++)
    cout<<u<<" "<<superidentificador[u]<<" "<<superposicion[u]<<endl;
  */
  for (int i=0;i<m;i++)
    if (apendiente[i])
      juntar(au[i],av[i]);
  // Eliminamos la memoria que no nos interesa recuperar:
  nmem=0;
  // Reutilizaremos el calculo de identificadores.
  for (int i=0;i<limite;i++) {
    identificador[i]=0;
    apendiente[i]=0;
    profundidad[i]=0;
  }
  for (cas=1;cas<=casos;cas++) {
    //cout<<"caso "<<cas<<endl;
    int numnodos;
    cin>>numnodos>>m;
    numraices=0;
    for (int i=0;i<numnodos;i++) {
      cin>>s[i];
      //if (cas==11) cout<<"nodo "<<s[i]<<endl;
      s[i]=rotate(s[i]);
    }
    /*
    cout<<"numnodos: ";
    for (int i=0;i<numnodos;i++)
      cout<<s[i]<<",";
    cout<<endl;
    */
    for (int i=0;i<m;i++) {
      cin>>au[i]>>av[i];
      //if (cas==11) cout<<"arista "<<au[i]<<" "<<av[i]<<endl;
      au[i]=rotate(au[i]);
      av[i]=rotate(av[i]);
      if (au[i]!=av[i]) {
	if (superraiz[au[i]]==superraiz[av[i]]) {
	  //if (cas==11) cout<<"juntar "<<au[i]<<" "<<av[i]<<endl;
	  juntar(au[i],av[i]);
	  //if (cas==11) cout<<"volvemos juntar "<<au[i]<<" "<<av[i]<<endl;
	} else {
	  int ru=superraiz[au[i]];
	  int rv=superraiz[av[i]];
	  raices[numraices++]=ru;
	  raices[numraices++]=rv;
	  gg[ru].push_back(pair<int,int> (rv,i));
	  gg[rv].push_back(pair<int,int> (ru,i));
	}
      }
    }
    /*
    cout<<"aristas: ";
    for (int i=0;i<m;i++)
      cout<<"("<<au[i]<<","<<av[i]<<")";
    cout<<endl;
    */
    eliminarepes();
    /*
    cout<<"raices"<<endl;
    for (int i=0;i<int(raices.size());i++)
      cout<<raices[i]<<",";
    cout<<endl;
    */
    for (int i=0;i<numraices;i++) {
      int u=raices[i];
      if (not profundidad[u])
	calcula(u,0,1);
    }
    for (int i=0;i<numraices;i++) {
      int r=raices[i];
      vector<pair<int,int> > &lista=paresidnodo[r];
      sort(lista.begin(),lista.end());
      for (int j=0;j<int(lista.size());j++) {
	if (j==0 or lista[j].first!=lista[j-1].first) {
	  for (int k=j+1;k<int(lista.size()) and lista[k].first==lista[j].first;k++) {
	    int u=lista[j].second;
	    int v=lista[k].second;
	    juntar(u,v);
	  }
	}
      }
    }
    for (int i=0;i<m;i++) {
      if (apendiente[i]) {
	fusionaexterno(au[i],av[i]);
	apendiente[i]=0;
      }
    }
    int as0=obteneridentificadorexterno(s[0]);
    //cout<<"as0 "<<as0<<endl;
    bool error=false;
    for (int i=1;i<numnodos and not error;i++)
      error=as0!=obteneridentificadorexterno(s[i]);
    if (error) cout<<"NO"<<endl;
    else {
      cout<<"YES"<<endl;
      R=(R+cas)%n;
    }
    for (int i=0;i<numraices;i++) {
      int r=raices[i];
      gg[r]=vector<pair<int,int> > ();
      paresidnodo[r]=vector<pair<int,int> > ();
      profundidad[r]=0;
    }
    numids=0;
    recupera();
  }
}


#include <bits/stdc++.h>
using namespace std;
#define rep(it,st,en) for(int it=(st);it<(int)(en);++it)
#define allof(c) (c).begin(), (c).end()
#define mt make_tuple
#define mp make_pair
#define pb push_back
#define X first
#define Y second
typedef long long int ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
const int INF=(int)1e9;
const double EPS=(ld)1e-7;

//#define cout (cout<<"\033[1;31m")
//#define endl "\033[0m"<<endl

const int maxn = 300005;
const int maxlg = 20;
struct Tree{
    int n,rt,T=0;
    int par[maxlg][maxn], depth[maxn], enter[maxn], exit[maxn];
    Tree(vvi& g,int root=0):n(g.size()),rt(root){dfs(rt, rt, g);}
    void dfs(int x, int p, vvi& g){
        depth[x] = (p==x) ? 0 : (depth[p]+1);
        par[0][x] = p;
        enter[x]=T++;
        rep(i,0,maxlg-1) par[i+1][x] = par[i][par[i][x]];
        for(int y:g[x]) if(y!=p) dfs(y,x,g);
        exit[x]=T;
    }
    int lca(int a, int b){
        if(depth[a]<depth[b]) swap(a,b);
        for(int i=maxlg-1;i>=0;--i)
            if(depth[par[i][a]] >= depth[b]) a = par[i][a];
        if(a==b) return a;
        for(int i=maxlg-1;i>=0;--i)
            if(par[i][a] != par[i][b]) a = par[i][a], b=par[i][b];
        return par[0][a];
    }
};
vi gg[maxn];
int imp[maxn];
void compact(vi& sub,Tree &t){
    static auto cmp = [&](int a,int b){return t.enter[a]<t.enter[b];};
    sort(allof(sub),cmp);
    int k=sub.size()-1;
    rep(i,0,k) sub.pb(t.lca(sub[i],sub[i+1]));
    sort(allof(sub),cmp);
    sub.erase(unique(allof(sub)),sub.end());
    stack<int> st;
    for(int x:sub){
        while(!st.empty() && t.exit[st.top()] <= t.enter[x]) st.pop();
        if(!st.empty()) gg[st.top()].pb(x), gg[x].pb(st.top());
        st.push(x);
    }
}

namespace bcc2{
    int bcc[maxn],tmm[maxn],low[maxn];
    int T=1,comp=0;
    stack<int> st;
    void dfs(int x,int p){
        tmm[x] = low[x] = T++;
        st.push(x);
        for(int y:gg[x]) if(y!=p && y!=0){
            if(tmm[y]) low[x] = min(low[x],tmm[y]);
            else dfs(y,x), low[x] = min(low[x],low[y]);
        }
        if(low[x]==tmm[x]){
            bcc[x] = ++comp;
            while(st.top()!=x)
                bcc[st.top()] = comp, st.pop();
            st.pop();
        }
    }
}

vvi g;
int bcc[maxn],tmm[maxn],low[maxn];
int T=1,comp=0;
stack<int> st;
void dfs(int x,int p){
    tmm[x] = low[x] = T++;
    st.push(x);
    for(int y:g[x]) if(y!=p){
        if(tmm[y]) low[x] = min(low[x],tmm[y]);
        else dfs(y,x), low[x] = min(low[x],low[y]);
    }
    if(low[x]==tmm[x]){
        bcc[x] = ++comp;
        while(st.top()!=x)
            bcc[st.top()] = comp, st.pop();
        st.pop();
    }
}
int n,m,q,a,b,x[maxn],y[maxn];
int R=0;
int rot(int element) { element=(element+R)%n; if (element==0) { element=n; } return element; }

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m>>q;
    g.resize(n+5);
    rep(i,0,m){
        cin>>a>>b;
        g[a].pb(b);
        g[b].pb(a);
        x[i]=a, y[i]=b;
    }
    rep(i,1,n+1) if(!tmm[i]) dfs(i,-1), g[0].pb(bcc[i]);
    g.resize(1);
    g.resize(comp+1,vi());
    rep(i,0,m) {
        a=bcc[x[i]], b=bcc[y[i]];
        if(a==b) continue;
        g[a].pb(b);
        g[b].pb(a);
    }
    Tree tree(g,0);
    //rep(i,0,n+1) cout<<i<<" = "<<bcc[i]<<endl;
    //rep(i,0,g.size()) rep(j,0,g[i].size())if(i<g[i][j]) cout<<i<<" "<<g[i][j]<<endl;
    rep(_i,0,q){
        int n,m,t;
        cin>>n>>m;
        vi v(n);
        rep(i,0,n){
            cin>>t;
            v[i]=bcc[rot(t)];
        }
        vi w=v;
        rep(i,0,m){
            cin>>a>>b;
            a=bcc[rot(a)], b=bcc[rot(b)];
            w.pb(a),w.pb(b);
            if(a!=b){
                gg[a].pb(b);
                gg[b].pb(a);
            }
        }
        sort(allof(w));
        w.erase(unique(allof(w)),w.end());
        compact(w,tree);
        bcc2::dfs(v[0],-1);
        //rep(i,0,n) rep(j,0,gg[i].size())if(i<gg[i][j]) cout<<i<<" "<<gg[i][j]<<endl;
        //cout<<endl;
        int s=bcc2::bcc[v[0]];
        for(int i:v) if(bcc2::bcc[i]!=s) {cout<<"NO"<<endl; goto fail;}
        cout<<"YES"<<endl;
        R=(R+_i+1)%::n;
        fail:
        for(int i:w){
            gg[i].clear();
            bcc2::bcc[i]=0;
            bcc2::tmm[i]=0;
            bcc2::low[i]=0;
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <set>
#include <ctime>
using namespace std;

const int Maxn=300010;

int n,m,q,R,pn,belong[Maxn],A[Maxn],B[Maxn],Dfn[Maxn],ed[Maxn],lim,s[Maxn],f[Maxn][30],depth[Maxn],root[Maxn];
bool imp[Maxn];

int Get()
{
	char ch; int v=0; bool f=false;
	while (!isdigit(ch=getchar())) if (ch=='-') f=true; v=ch-48;
	while (isdigit(ch=getchar())) v=v*10+ch-48;
	if (f) return -v;else return v;
}

int rotate(int element)
{
	element=(element+R)%n;
	if (element==0) element=n;
	return element;
}

bool cmp(const int &a,const int &b)
{
	return Dfn[a]<Dfn[b];
}

int QueryLca(int x,int y)
{
	if (root[x]!=root[y]) return -1;
	if (depth[x]<depth[y]) swap(x,y);
	for (int dif=depth[x]-depth[y],i=0;dif;dif>>=1,i++)
		if (dif&1) x=f[x][i];
	if (x==y) return x;
	for (int i=lim;i>=0;i--)
		if (f[x][i]!=f[y][i]) x=f[x][i],y=f[y][i];
	return f[x][0];
}

bool insub(int x,int y)
{
	return Dfn[x]<=Dfn[y] && Dfn[y]<=ed[x];
}

namespace Task
{
	const int Maxm=Maxn+Maxn;
	int tot,cnt,tpn,bel[Maxn],fst[Maxn],to[Maxm<<1],pre[Maxm<<1],st[Maxn],top,dfs_clock,dfn[Maxn],low[Maxn];

	bool inset[Maxn],vis[Maxn];

	void init() { tot=1; }
	void push(int x) { if (x==-1) return; if (!inset[x]) s[++cnt]=x,inset[x]=true; }
	void clean()
	{
		for (int i=1;i<=cnt;i++)
		{
			inset[s[i]]=imp[s[i]]=false;
			fst[s[i]]=vis[s[i]]=dfn[s[i]]=low[s[i]]=0;
			s[i]=0;
		}
		cnt=tot=0;
	}

	void AddE(int x,int y)
	{
	//	cout<<"Add:"<<x<<" "<<y<<endl;
		pre[++tot]=fst[x],fst[x]=tot,to[tot]=y;
		pre[++tot]=fst[y],fst[y]=tot,to[tot]=x;
	}

	void build()
	{
		//cout<<"cnt="<<cnt<<endl;
		//for (int i=1;i<=cnt;i++) cout<<s[i]<<" ";cout<<endl;
		sort(s+1,s+1+cnt,cmp);
		int tcnt=cnt;
		for (int i=1;i<=tcnt-1;i++) push(QueryLca(s[i],s[i+1]));
		sort(s+1,s+1+cnt,cmp);
		//for (int i=1;i<=cnt;i++) cout<<s[i]<<" ";cout<<endl;
		top=0;
		for (int i=1;i<=cnt;i++)
		{
			int x=s[i];
			while (top>0 && !insub(st[top],x)) top--;
			if (top>0) AddE(x,st[top]);
			st[++top]=x;
		}
	}

	void tarjan(int x,int prev)
	{
		vis[x]=true;
		dfn[x]=low[x]=++dfs_clock;
		for (int i=fst[x];i;i=pre[i])
		{
			int y=to[i];
			if ((i^1)==prev) continue;
			if (!vis[y]) tarjan(y,i),low[x]=min(low[x],low[y]);
			else low[x]=min(low[x],dfn[y]);
		}
	}

	bool iscut(int x,int y)
	{
		return low[x]>dfn[y] || low[y]>dfn[x];
	}

	void FindScc(int x)
	{
		vis[x]=true; bel[x]=tpn;
		for (int i=fst[x];i;i=pre[i])
			if (!vis[to[i]] && !iscut(x,to[i])) FindScc(to[i]);
	}

	void work(int test)
	{
		build();
		dfs_clock=0;
		for (int i=1;i<=cnt;i++) vis[s[i]]=false;
		for (int i=1;i<=cnt;i++)
			if (!vis[s[i]]) tarjan(s[i],-1);
		for (int i=1;i<=cnt;i++) vis[s[i]]=false;
		tpn=0;
		for (int i=1;i<=cnt;i++)
			if (!vis[s[i]]) tpn++,FindScc(s[i]);
		bool flag=true; int t=0;
		//for (int i=1;i<=cnt;i++) cout<<s[i]<<" "<<bel[s[i]]<<endl;cout<<endl;
		for (int i=1;i<=cnt;i++)
		{
			int x=s[i];
			if (imp[x])
			{
				if (t==0) t=bel[x];
				else if (t!=bel[x]) { flag=false; break; }
			}
		}
		if (flag) puts("YES"),R=(R+test)%n //干你**的出题人;
		else puts("NO");
	}
}

namespace Tree
{
	int tot,fst[Maxn],pre[Maxn<<1],to[Maxn<<1],dfs_clock;
	bool vis[Maxn];

	void AddE(int x,int y)
	{
		//cout<<"AddE"<<x<<" "<<y<<endl;
		pre[++tot]=fst[x],fst[x]=tot,to[tot]=y;
		pre[++tot]=fst[y],fst[y]=tot,to[tot]=x;
	}

	void dfs(int x)
	{
		vis[x]=true;
		for (int i=1;;i++)
		{
			f[x][i]=f[f[x][i-1]][i-1];
			if (f[x][i]) lim=max(lim,i);
			else break;
		}

		Dfn[x]=++dfs_clock;
		for (int i=fst[x];i;i=pre[i])
		{
			int y=to[i];
			if (!vis[y])
			{
				depth[y]=depth[x]+1;
				f[y][0]=x,root[y]=root[x];
				dfs(y);
			}
		}
		ed[x]=dfs_clock;
	}

	void build()
	{
		tot=0; dfs_clock=0;
		for (int i=1;i<=m;i++)
		{
			int x=belong[A[i]],y=belong[B[i]];
			if (x!=y) AddE(x,y);
		}

		lim=0;
		for (int i=1;i<=pn;i++) vis[i]=false;
		for (int i=1;i<=pn;i++)
			if (!vis[i]) f[i][0]=0,depth[i]=1,root[i]=i,dfs(i);
	}

	void solve(int test)
	{
		Task::init();
		int x,y;
		int tn=Get(),tm=Get();
		for (int i=1;i<=tn;i++) x=rotate(Get()),Task::push(belong[x]),imp[belong[x]]=true;
		for (int i=1;i<=tm;i++)
		{
			x=rotate(Get()),y=rotate(Get());
			//cout<<x<<" "<<y<<endl<<endl;
			Task::push(belong[x]),Task::push(belong[y]);
			Task::AddE(belong[x],belong[y]);
		}
		Task::work(test);
		Task::clean();
	}
}

namespace Graph
{
	int tot,fst[Maxn],pre[Maxn<<1],to[Maxn<<1],dfs_clock,dfn[Maxn],low[Maxn];
	bool vis[Maxn];

	void AddE(int x,int y)
	{
		pre[++tot]=fst[x],fst[x]=tot,to[tot]=y;
		pre[++tot]=fst[y],fst[y]=tot,to[tot]=x;
	}

	void tarjan(int x,int prev)
	{
		vis[x]=true;
		dfn[x]=low[x]=++dfs_clock;
		for (int i=fst[x];i;i=pre[i])
		{
			int y=to[i];
			if ((i^1)==prev) continue;
			if (!vis[y]) tarjan(y,i),low[x]=min(low[x],low[y]);
			else low[x]=min(low[x],dfn[y]);
		}
	}

	bool iscut(int x,int y)
	{
		return low[x]>dfn[y] || low[y]>dfn[x];
	}

	void FindScc(int x)
	{
		vis[x]=true; belong[x]=pn;
		for (int i=fst[x];i;i=pre[i])
			if (!vis[to[i]] && !iscut(x,to[i])) FindScc(to[i]);
	}

	void init()
	{
		tot=1;
		int x,y;
		for (int i=1;i<=m;i++)
		{
			A[i]=Get(),B[i]=Get();
			AddE(A[i],B[i]);
		}
		pn=0; dfs_clock=0;
		for (int i=1;i<=n;i++) vis[i]=false;
		for (int i=1;i<=n;i++) if (!vis[i]) tarjan(i,-1);

		for (int i=1;i<=n;i++) vis[i]=false;
		for (int i=1;i<=n;i++) if (!vis[i]) pn++,FindScc(i);
		//for (int i=1;i<=n;i++) cout<<belong[i]<<" ";cout<<endl;
	}
}

int main()
{
	n=Get(),m=Get(),q=Get();
	Graph::init();
	Tree::build();

	for (int i=1;i<=q;i++) Tree::solve(i);
	return 0;
}


#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define lson l,mid,rt << 1
#define rson mid + 1,r,rt << 1 | 1
using namespace std;

template<class T>inline void rd(T & x){ int f = 1;x = 0;char ch = getchar();for(;!isdigit(ch);ch = getchar()) if(ch == '-') f = -1; for(;isdigit(ch);ch = getchar()) x = x * 10 + ch - '0';x *= f;}

const int maxn = 1e5 + 10;

struct op{
	int type;
	int t,l,r,v,s;
} querys[maxn];

int times[maxn],n;
inline int upper(double time){
	int l = 1,r = n,ans = n + 1;
	while(l <= r){
		int mid = l + r >> 1;
		if(times[mid] >= time){
			ans = mid;
			r = mid - 1;
		} else {
			l = mid + 1;
		}
	}
	return ans;
}
inline int lower(double time){
	int l = 1,r = n,ans = 0;
	while(l <= r){
		int mid = l + r >> 1;
		if(times[mid] <= time){
			ans = mid;
			l = mid + 1;
		} else {
			r = mid - 1;
		}
	}
	return ans;
}

int mark[maxn];
namespace Fenwick{
	int tr[maxn];
	inline void update(int x,int v){ for(;x < maxn;x += x & (-x)) tr[x] += v;}
	inline int query(int x){ int ans = 0; for(;x;x ^= x & (-x)) ans += tr[x]; return ans;}
	inline int val(int x) { return query(x) - query(x - 1);}
	inline int bs(int x){ // min query(ans) >= x
		int l = 0,r = n,ans = 0;
		while(l <= r){
			int mid = l + r >> 1;
			if(query(mid) >= x) {
				ans = mid;
				r = mid - 1;
			} else {
				l = mid + 1;
			}
		}
		return ans;
	}
	inline int pre(int x){
		int d = query(x - 1);
		return bs(d);
	}
	inline int suc(int x){
		return bs(query(x) + 1);
	}
}
double cur[maxn];
const double inf = 2e20;
namespace Segment{
	double tra[maxn << 2],tri[maxn << 2];
	double lazy[maxn << 2];
	int mk[maxn << 2];

	inline void pushup(int rt){
		tra[rt] = max(tra[rt << 1],tra[rt << 1 | 1]);
		tri[rt] = min(tri[rt << 1],tri[rt << 1 | 1]);
	}
	inline void pushdown(int rt){
		if(!mk[rt]) return;
		mk[rt] = 0;
		mk[rt << 1] = 1;
		mk[rt << 1 | 1] = 1;
		lazy[rt << 1] += lazy[rt];
		lazy[rt << 1 | 1] += lazy[rt];
		tra[rt << 1] += lazy[rt];
		tri[rt << 1] += lazy[rt];
		tra[rt << 1 | 1] += lazy[rt];
		tri[rt << 1 | 1] += lazy[rt];
		lazy[rt] = 0;
	}
	void _update(double * target,int pos,double v,int l,int r,int rt){
		if(l == r){
			target[rt] = v;
			return;
		}
		pushdown(rt);
		int mid = l + r >> 1;
		if(pos <= mid) _update(target,pos,v,lson);
		else _update(target,pos,v,rson);
		pushup(rt);
	}
	void setVoid(int pos){
		_update(tra,pos,-inf,1,n,1);
		_update(tri,pos,inf,1,n,1);
	}
	void setZero(int pos){
		_update(tra,pos,0,1,n,1);
		_update(tri,pos,0,1,n,1);
	}
	void build(int l,int r,int rt){
		if(l == r){
			tra[rt] = -inf;
			tri[rt] = inf;
			return;
		}
		int mid = l + r >> 1;
		build(lson);
		build(rson);
		pushup(rt);
	}
	void update(int L,int R,double v,int l,int r,int rt){
		if(L <= l && r <= R){
			lazy[rt] += v;
			tra[rt] += v;
			tri[rt] += v;
			mk[rt] = 1;
			return;
		}
		pushdown(rt);
		int mid = l + r >> 1;
		if(L <= mid) update(L,R,v,lson);
		if(R > mid) update(L,R,v,rson);
		pushup(rt);
	}
	double querya(int L,int R,int l,int r,int rt){
		if(L <= l && r <= R){
			return tra[rt];
		}
		pushdown(rt);
		int mid = l + r >> 1;
		double ans = -inf;
		if(L <= mid) ans = max(ans,querya(L,R,lson));
		if(R > mid)ans = max(ans,querya(L,R,rson));
		return ans;
	}
	double queryi(int L,int R,int l,int r,int rt){
		if(L <= l && r <= R){
			return tri[rt];
		}
		pushdown(rt);
		int mid = l + r >> 1;
		double ans = inf;
		if(L <= mid) ans = min(ans,queryi(L,R,lson));
		if(R > mid) ans = min(ans,queryi(L,R,rson));
		return ans;
	}

}
double getV(double l){
	int x = lower(l);
	if(x == 0) return 0;
	if(Fenwick::val(x) == 0)x = Fenwick::pre(x);
	if(x == 0) return 0;
	return cur[x];
}
double calc(double l){
	int x = lower(l);
	if(x == 0) return 0;
	if(Fenwick::val(x) == 0)x = Fenwick::pre(x);
	if(x == 0) return 0;
	return (double)(l - times[x]) * cur[x] + Segment::querya(x,x,1,n,1);
}
const double eps = 1e-15;
bool check(double l,double r,double c){
	double qa = -inf,qi = inf;
	if(fabs(l - r) <= eps) return fabs(calc(l) - c) <= eps;
	qa = max(calc(l),qa);
	qi = min(calc(l),qi);
	qa = max(calc(r),qa);
	qi = min(calc(r),qi);
	int lx = upper(l),rx = lower(r);
	if(lx <= rx && lx != 0 && rx != 0){
		qa = max(qa,Segment::querya(lx,rx,1,n,1));
		qi = min(qi,Segment::queryi(lx,rx,1,n,1));
	}
//	printf("%.9f %.9f %.9f %.9f %.9f\n",l,r,qa,qi,c);
	return qa - c >= 0 && qi - c <= 0;
}

int main(){
	int TAT;
	int ttt = 0;
	rd(TAT);
	for(int i = 1;i <= TAT;i++){
		int type,t,l,r,v,s;
		rd(type);
		if(type == 1){ // add
			rd(t); rd(v);
			times[++n] = t;
			querys[i].type = 1;
			querys[i].t = t;
			querys[i].v = v;
		} else if(type == 2){
			rd(t);
			querys[i].type = 2;
			querys[i].t = t;
		} else {
			rd(l); rd(r); rd(s);
			querys[i].type = 3;
			querys[i].l = l;
			querys[i].r = r;
			querys[i].s = s;
		}
	}
	sort(times + 1,times + n + 1);
	n = unique(times + 1,times + n + 1) - times - 1;

	if(n!=0)Segment::build(1,n,1);
	for(int i = 1;i <= TAT;i++){
		int type = querys[i].type;
		if(type == 1){
			int t = querys[i].t, v = querys[i].v;
			int pos = upper(t);
			Fenwick::update(pos,1);
			int pre = Fenwick::pre(pos),suc = Fenwick::suc(pos);
			cur[pos] = v;
			assert(pos != n + 1);
			Segment::setZero(pos);
			if(pre){
				double delta = (double)cur[pre] * (times[pos] - times[pre]) + Segment::querya(pre,pre,1,n,1);
				Segment::update(pos,pos,delta,1,n,1);
			}
			if(suc){
				double delta = (double)(v - cur[pre]) * (times[suc] - times[pos]);
				Segment::update(suc,n,delta,1,n,1);
			}
		} else if(type == 2){
			int t = querys[i].t;
			int pos = upper(t);
			int pre = Fenwick::pre(pos),suc = Fenwick::suc(pos);
			Fenwick::update(pos,-1);
			if(suc){
				double delta = (double)(cur[pre] - cur[pos]) * (times[suc] - times[pos]);
				Segment::update(suc,n,delta,1,n,1);
			}
			Segment::setVoid(pos);
			cur[pos] = 0;
		} else {
			ttt++;
			double l = querys[i].l , r = querys[i].r , s = -querys[i].s;
			int lx = upper(l);
			if(Fenwick::val(lx) == 0) lx = Fenwick::suc(lx);
			l = times[lx];
			if(s == 0) {
				printf("%d\n",querys[i].l);
				continue;
			}
			if(n == 0 || Fenwick::query(n) == 0 || !lx || l > r) {
				printf("-1\n");
				continue;
			}
			s += Segment::querya(lx,lx,1,n,1);

			bool ok = 0;
			l -= eps * 2;
			r += eps * 2;
			for(int k = 0;k < 100;k++){
				double mid = (l + r) / 2;
				if(check(l,mid,s)){
					r = mid;
					ok = 1;
				} else {
					l = mid;
				}
			}
			if(fabs(calc(l) - s) <= eps) ok = 1;
			if(ok)printf("%.9f\n",r);
			else printf("-1\n");
		}
	}
}


#include<bits/stdc++.h>
#define lson l,mid,rt << 1
#define rson mid + 1,r,rt << 1 | 1
using namespace std;

template<class T>inline void rd(T & x){ int f = 1;x = 0;char ch = getchar();for(;!isdigit(ch);ch = getchar()) if(ch == '-') f = -1; for(;isdigit(ch);ch = getchar()) x = x * 10 + ch - '0';x *= f;}

const int maxn = 1e5 + 10;

struct op{
	int type;
	int t,l,r,v,s;
} querys[maxn];

int times[maxn],n;
inline int upper(double time){
	int l = 1,r = n,ans = n + 1;
	while(l <= r){
		int mid = l + r >> 1;
		if(times[mid] >= time){
			ans = mid;
			r = mid - 1;
		} else {
			l = mid + 1;
		}
	}
	return ans;
}
inline int lower(double time){
	int l = 1,r = n,ans = 0;
	while(l <= r){
		int mid = l + r >> 1;
		if(times[mid] <= time){
			ans = mid;
			l = mid + 1;
		} else {
			r = mid - 1;
		}
	}
	return ans;
}

int mark[maxn];
namespace Fenwick{
	int tr[maxn];
	inline void update(int x,int v){ for(;x < maxn;x += x & (-x)) tr[x] += v;}
	inline int query(int x){ int ans = 0; for(;x;x ^= x & (-x)) ans += tr[x]; return ans;}
	inline int val(int x) { return query(x) - query(x - 1);}
	inline int bs(int x){ // min query(ans) >= x
		int l = 0,r = n,ans = 0;
		while(l <= r){
			int mid = l + r >> 1;
			if(query(mid) >= x) {
				ans = mid;
				r = mid - 1;
			} else {
				l = mid + 1;
			}
		}
		return ans;
	}
	inline int pre(int x){
		int d = query(x - 1);
		return bs(d);
	}
	inline int suc(int x){
		return bs(query(x) + 1);
	}
}
double cur[maxn];
const double inf = 2e20;
namespace Segment{
	double tra[maxn << 2],tri[maxn << 2];
	double lazy[maxn << 2];
	int mk[maxn << 2];

	inline void pushup(int rt){
		tra[rt] = max(tra[rt << 1],tra[rt << 1 | 1]);
		tri[rt] = min(tri[rt << 1],tri[rt << 1 | 1]);
	}
	inline void pushdown(int rt){
		if(!mk[rt]) return;
		mk[rt] = 0;
		mk[rt << 1] = 1;
		mk[rt << 1 | 1] = 1;
		lazy[rt << 1] += lazy[rt];
		lazy[rt << 1 | 1] += lazy[rt];
		tra[rt << 1] += lazy[rt];
		tri[rt << 1] += lazy[rt];
		tra[rt << 1 | 1] += lazy[rt];
		tri[rt << 1 | 1] += lazy[rt];
		lazy[rt] = 0;
	}
	void _update(double * target,int pos,double v,int l,int r,int rt){
		if(l == r){
			target[rt] = v;
			return;
		}
		int mid = l + r >> 1;
		if(pos <= mid) _update(target,pos,v,lson);
		else _update(target,pos,v,rson);
		pushup(rt);
	}
	void setVoid(int pos){
		_update(tra,pos,-inf,1,n,1);
		_update(tri,pos,inf,1,n,1);
	}
	void setZero(int pos){
		_update(tra,pos,0,1,n,1);
		_update(tri,pos,0,1,n,1);
	}
	void build(int l,int r,int rt){
		if(l == r){
			tra[rt] = -inf;
			tri[rt] = inf;
			return;
		}
		int mid = l + r >> 1;
		build(lson);
		build(rson);
		pushup(rt);
	}
	void update(int L,int R,double v,int l,int r,int rt){
		if(L <= l && r <= R){
			lazy[rt] += v;
			tra[rt] += v;
			tri[rt] += v;
			mk[rt] = 1;
			return;
		}
		pushdown(rt);
		int mid = l + r >> 1;
		if(L <= mid) update(L,R,v,lson);
		if(R > mid) update(L,R,v,rson);
		pushup(rt);
	}
	double querya(int L,int R,int l,int r,int rt){
		if(L <= l && r <= R){
			return tra[rt];
		}
		pushdown(rt);
		int mid = l + r >> 1;
		double ans = -inf;
		if(L <= mid) ans = max(ans,querya(L,R,lson));
		if(R > mid)ans = max(ans,querya(L,R,rson));
		return ans;
	}
	double queryi(int L,int R,int l,int r,int rt){
		if(L <= l && r <= R){
			return tri[rt];
		}
		pushdown(rt);
		int mid = l + r >> 1;
		double ans = inf;
		if(L <= mid) ans = min(ans,queryi(L,R,lson));
		if(R > mid) ans = min(ans,queryi(L,R,rson));
		return ans;
	}

}
double getV(double l){
	int x = lower(l);
	if(x == 0) return 0;
	if(Fenwick::val(x) == 0)x = Fenwick::pre(x);
	if(x == 0) return 0;
	return cur[x];
}
double calc(double l){
	int x = lower(l);
	if(x == 0) return 0;
	if(Fenwick::val(x) == 0)x = Fenwick::pre(x);
	if(x == 0) return 0;
	return (double)(l - times[x]) * cur[x] + Segment::querya(x,x,1,n,1);
}
const double eps = 1e-15;
bool check(double l,double r,double c){
	double qa = -inf,qi = inf;
	if(l == r) return abs(calc(l) - c) <= eps;
	qa = max(calc(l),qa);
	qi = min(calc(l),qi);
	qa = max(calc(r),qa);
	qi = min(calc(r),qi);
	int lx = upper(l),rx = lower(r);
	if(lx <= rx && lx != 0 && rx != 0){
		qa = max(qa,Segment::querya(lx,rx,1,n,1));
		qi = min(qi,Segment::queryi(lx,rx,1,n,1));
	}
//	printf("%.9f %.9f %.9f %.9f %.9f\n",l,r,qa,qi,c);
	return qa - c >= 0 && qi - c <= 0;
}

int main(){
	int TAT;
	int ttt = 0;
	rd(TAT);
	for(int i = 1;i <= TAT;i++){
		int type,t,l,r,v,s;
		rd(type);
		if(type == 1){ // add
			rd(t); rd(v);
			times[++n] = t;
			querys[i].type = 1;
			querys[i].t = t;
			querys[i].v = v;
		} else if(type == 2){
			rd(t);
			querys[i].type = 2;
			querys[i].t = t;
		} else {
			rd(l); rd(r); rd(s);
			querys[i].type = 3;
			querys[i].l = l;
			querys[i].r = r;
			querys[i].s = s;
		}
	}
	sort(times + 1,times + n + 1);
	n = unique(times + 1,times + n + 1) - times - 1;

	if(n!=0)Segment::build(1,n,1);
	for(int i = 1;i <= TAT;i++){
		int type = querys[i].type;
		if(type == 1){
			int t = querys[i].t, v = querys[i].v;
			int pos = upper(t);
			Fenwick::update(pos,1);
			int pre = Fenwick::pre(pos),suc = Fenwick::suc(pos);
			cur[pos] = v;
			Segment::setZero(pos);
			if(pre){
				double delta = (double)cur[pre] * (times[pos] - times[pre]) + Segment::querya(pre,pre,1,n,1);
				Segment::update(pos,pos,delta,1,n,1);
			}
			if(suc){
				double delta = (double)(v - cur[pre]) * (times[suc] - times[pos]);
				Segment::update(suc,n,delta,1,n,1);
			}
		} else if(type == 2){
			int t = querys[i].t;
			int pos = upper(t);
			int pre = Fenwick::pre(pos),suc = Fenwick::suc(pos);
			Fenwick::update(pos,-1);
			if(suc){
				double delta = (double)(cur[pre] - cur[pos]) * (times[suc] - times[pos]);
				Segment::update(suc,n,delta,1,n,1);
			}
			Segment::setVoid(pos);
			cur[pos] = 0;
		} else {
			t++;
			double l = querys[i].l , r = querys[i].r , s = -querys[i].s;
			int lx = upper(l);
			if(Fenwick::val(lx) == 0) lx = Fenwick::suc(lx);
			l = times[lx];
			if(s == 0) {
				printf("%d\n",querys[i].l);
				continue;
			}
			if(n == 0 || Fenwick::query(n) == 0 || !lx || l > r) {
				if(t == 20) printf("FUCK\n");
				printf("-1\n");

				continue;
			}
			s += Segment::querya(lx,lx,1,n,1);

			bool ok = 0;
			if(check(r,r,s) || check(l,l,s)) ok = 1;
			for(int k = 0;k < 1000;k++){
				double mid = (l + r) / 2;
				if(check(l,mid,s)){
					r = mid;
					ok = 1;
				} else {
					l = mid;
				}
			}
			if(ok)printf("%.9f\n",r);
			else printf("-1\n");
		}
	}
}


#include <iostream>
#include <queue>
#include <stack>
#include <set>
#include <cstring>
#include <stdio.h>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <iterator>
#include <algorithm>
#include <functional>
#include <map>
#include <cassert>
#include <bitset>
#include <iomanip>

using namespace std;

typedef long long ll;
#define pii pair<ll, ll>
#define mp make_pair

ll read() {
    int f = 1;
    ll res = 0;
    char ch;
    do {
        ch = getchar();
        if (ch == '-') f = -f;
    } while (ch < '0' || ch > '9');
    do {
        res = res * 10 + ch - '0';
        ch = getchar();
    } while (ch >= '0' && ch <= '9');
    return f == 1 ? res : -res;
}

void fast_io() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const int N = 100010;
const int mod = 1000000007;
const ll INF = 1e18;
int n,m,q;
int A[N], B[N];
char str[N];

int head[N*2], to[N * 2], nxt[N * 2], tot;
void addEdge(int u, int v) {
    tot++;
    nxt[tot] = head[u];
    to[tot] = v;
    head[u] = tot;
}

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

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

int countOne(int set) {
    int res = 0;
    while (set) {
        res++;
        set &= set - 1;
    }
    return res;
}

bool contain(int set, int i) {
    return (set & (1 << i)) > 0;
}

ll myPow(ll a, int p) {
    if (p == 0) return 1;
    ll res = myPow(a, p / 2);
    res *= res;
    res %= mod;
    if (p % 2 == 1) {
        res *= a;
        res %= mod;
    }
    return res;
}

void addMode(int &a, ll b) {
    a = (a+b) % mod;
}

ll mul(ll a, ll b) {
    return a * b % mod;
}

template <class T>
void mySwap(T &a, T &b) {
    T tmp = a;
    a = b;
    b = tmp;
}

struct Query {
    int time, l, r, type;
    int speed, vol;
};

vector<int> added;
vector<Query> query;

const int M = N * 4;
struct ST {
    pii f[M], e[M];
    ll res[M], mn[M];

    void init() {
        fill(mn, mn+M, INF);
    }
    void build(int x, int nl, int nr) {
        if (nl == nr) {
            mn[x] = INF;
            return;
        }
        int m = (nl + nr) / 2;
        build(x*2, nl, m);
        build(x*2+1, m+1, nr);
        mn[x] = INF;
    }

    void update(int x) {
        if (mn[x*2] == INF) {
            int child = x*2+1;
            f[x] = f[child];
            e[x] = e[child];
            res[x] = res[child];
            mn[x] = mn[child];
            return;
        }
        if (mn[x*2+1] == INF) {
            int child = x*2;
            f[x] = f[child];
            e[x] = e[child];
            res[x] = res[child];
            mn[x] = mn[child];
            return;
        }
        int l = x*2;
        int r = x*2+1;
        f[x] = f[l];
        e[x] = e[r];
        ll diff = e[l].second * (f[r].first - e[l].first);
        res[x] = res[l] + diff + res[r];
        mn[x] = mmin(mn[l], res[l] + diff);
        mn[x] = mmin(mn[x], res[l] + diff + mn[r]);
    }

    void set(int l, int time, int speed, int x, int nl ,int nr) {
        if (nl == nr) {
            f[x] = mp(time, speed);
            e[x] = mp(time, speed);
            res[x] = 0;
            mn[x] = 0;
            return;
        }
        int m = (nl + nr) / 2;
        if (l <= m) set(l, time, speed, x*2, nl, m);
        else set(l, time, speed, x*2+1, m+1, nr);
        update(x);
    }

    void del(int l, int x, int nl , int nr) {
        if (nl == nr) {
            mn[x] = INF;
            return;
        }
        int m = (nl + nr) / 2;
        if (l <= m) del(l, x*2, nl, m);
        else del(l, x*2+1, m+1, nr);
        update(x);
    }

    struct node {
        double to;
        ll v;
    };
    node query(int l, int r, ll v, int ss, int rr, int x, int nl, int nr) {

        if (mn[x] == INF) return {-1, v};
        if (l > r) return {-1, v};
//        if (rr <= f[x].first) {
//            return {-1, v};
//        }
        if (l == nl && r == nr) {
            if (f[x] == e[x]) {
                ll nv = res[x] + v + (rr - e[x].first) * e[x].second;
                if (nv > 0) return {-1, nv};
                else return {e[x].first - (res[x] + v) * 1.0 / e[x].second, 0LL};
            }
            int lchild = x*2;
            int rchild = x*2+1;
            int m = (nl + nr) / 2;
            if (mn[rchild] == INF) return query(l, m, v, ss, rr, x*2, nl, m);
            if (mn[lchild] == INF) return query(m+1, r, v, ss, rr, x*2+1, m+1, nr);

            if (mn[lchild] + v <= 0) return query(l, m, v, ss, mmin(rr, f[x*2+1].first), x*2, nl, m);
            ll diff = e[lchild].second * (f[rchild].first - e[lchild].first);
            if (v + res[lchild] + diff <= 0) {
                return {e[lchild].first - (v + res[lchild]) * 1.0 / e[lchild].second, 0};
            }

            if (mn[x] + v > 0) {
                ll nv = res[x] + v + (rr - e[x].first) * e[x].second;
                if (nv <= 0) {
                    return {e[x].first - (v + res[x]) * 1.0 / e[x].second, 0};
                } else {
                    return {-1, nv};
                }
            } else {
                v = v + res[lchild] + diff;
                return query(m+1, r, v, ss, rr, x*2+1, m+1, nr);
            }
        }

        int lchild = x*2;
        int rchild = x*2+1;
        int m = (nl + nr) / 2;
        if (mn[rchild] == INF) return query(l, mmin(m, r), v, ss, rr, x*2, nl, m);
        if (mn[lchild] == INF) return query(mmax(l, m+1), r, v, ss, rr, x*2+1, m+1, nr);
        node res = query(l, mmin(r, m), v, ss, f[x*2+1].first, x*2, nl, m);
        if (res.to != -1) return res;
        return query(mmax(l, m+1), r, res.v, ss, rr, x*2+1, m+1, nr);
    }
}st;

int main() {

    fast_io();
    cout << fixed << setprecision(10);

    cin >> n;
    for (int i = 0; i < n; i++) {
        int tp;
        cin >> tp;
        Query q;
        q.type = tp;
        if (tp == 1) {
            int time, speed;
            cin >> time >> speed;
            q.time = time;
            q.speed = speed;
            added.push_back(time);
        } else if (tp == 2) {
            int time;
            cin >> time;
            q.time = time;
        } else {
            int l, r, v;
            cin >> l >> r >> v;
            q.l = l;
            q.r = r;
            q.vol = v;
        }
        query.push_back(q);
    }
    if (added.size() == 0) added.push_back(0);

    sort(added.begin(), added.end());
    added.erase(unique(added.begin(), added.end()), added.end());

    int m = added.size();
    st.init();
    st.build(1, 1, m);

    for (int i = 0; i < n; i++) {
        Query q = query[i];
        if (q.type == 1) {
            int idx = lower_bound(added.begin(), added.end(), q.time) - added.begin();
            idx++;
            int time = q.time;
            int speed = q.speed;
            st.set(idx, time, speed, 1, 1, m);
        } else if (q.type == 2) {
            int idx = lower_bound(added.begin(), added.end(), q.time) - added.begin();
            idx++;
            st.del(idx, 1, 1, m);
        } else {
            if (q.vol == 0) {
                cout << q.l << '\n';
            } else {
                int l = lower_bound(added.begin(), added.end(), q.l) - added.begin();
                l++;
                int r = lower_bound(added.begin(), added.end(), q.r) - added.begin();
                cout << st.query(l, r, q.vol, q.l, q.r, 1, 1, m).to << '\n';
            }
        }
    }
    return 0;
}


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

#define PB push_back
#define CL(A,I) (memset(A,I,sizeof(A)))

#define FOR(i, m, n) for (int i=m; i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)

#define D(X) cout<<"  "<<#X": "<<X<<endl;

using ll=long long;
using ii=pair<ll,ll>;
using vi=vector<ll>;
using vii=vector<ii>;

#define aa first
#define bb second

#define EPS (1e-9)
#define EQ(A,B) (A+EPS>B&&A-EPS<B)

vector<int> g[6666];
int lerank[6666];

int vals[6666];

int main() {
    CL(vals,-1);

    string s;
    getline(cin,s);

    int x = s.find_first_of(')');

    string gg = s.substr(2,x-2);
    string ff = s.substr(x+3);
    ff = ff.substr(0,ff.size()-1);

    map<string,vector<int>> remap;
    map<string,int> nodemap;

    int ggi=0;
    int cnt=0;
    int ncnt=0;
    while(1){
        int gge = gg.find_first_not_of('_',ggi);

        // cout<<ggi<<' '<<gge<<endl;

        string ss = gg.substr(ggi,gge-ggi);

        remap[ss].PB(cnt++);
        if(nodemap.find(ss) == nodemap.end()) nodemap[ss]=ncnt++;

        ggi = gge+1;

        if(gge==-1) break;
    }

    // for(auto p : nodemap)
        // cout<<p.aa<<' '<<p.bb<<endl;

    vector<string> podm;

    int ffi=0;
    while(1){
        int ffe = ff.find_first_of(',',ffi);

        string ss = ff.substr(ffi,ffe-ffi);

        // cout<<ss<<endl;

        int op = ss.find_first_not_of('_');

        // cout<<ss[op]<<endl;

        string a = ss.substr(0,op);
        string b = ss.substr(op+1);

        if(a==b){
            cout<<"false"<<endl;
            return 0;
        }

        if(ss[op]=='>'){
            g[nodemap[b]].PB(nodemap[a]);
            lerank[nodemap[a]]++;
        }
        else {
            g[nodemap[a]].PB(nodemap[b]);
            lerank[nodemap[b]]++;
        }

        ffi=ffe+1;

        if(ffe==-1) break;
    }

    vector<int> q;
    F(ncnt) if(lerank[i]==0)q.PB(i);

    int val=0;
    int vis=0;
    while(q.size()){
        vector<int> next;

        for(int node : q) {
            vis++;
            vals[node]=val;

            for(int neigh : g[node]) {
                lerank[neigh]--;
                if(lerank[neigh]==0)
                    next.PB(neigh);
            }
        }

        val++;
        q = move(next);
    }

    if(vis!=ncnt || val>=10){
        cout<<"false"<<endl;
        return 0;
    }

    string res(cnt,'x');

    for(auto & p : nodemap){

        // cout<<p.aa<<' '<<p.bb<<' '<<vals[p.bb]<<endl;

        for(int mm : remap[p.aa]){
            // cout<<mm<<' ';
            res[mm] = vals[p.bb]+'0';
        }
        // cout<<endl;
    }

    cout<<res<<endl;

    return 0;
}


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

#define PB push_back
#define CL(A,I) (memset(A,I,sizeof(A)))

#define FOR(i, m, n) for (int i=m; i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)

#define D(X) cout<<"  "<<#X": "<<X<<endl;

using ll=long long;
using ii=pair<ll,ll>;
using vi=vector<ll>;
using vii=vector<ii>;

#define aa first
#define bb second

#define EPS (1e-9)
#define EQ(A,B) (A+EPS>B&&A-EPS<B)

vector<int> g[6666];
int lerank[6666];

int vals[6666];

int main() {
    CL(vals,-1);

    string s;
    getline(cin,s);

    int x = s.find_first_of(')');

    string gg = s.substr(2,x-2);
    string ff = s.substr(x+3);
    ff = ff.substr(0,ff.size()-1);

    map<string,vector<int>> remap;
    map<string,int> nodemap;

    int ggi=0;
    int cnt=0;
    int ncnt=0;
    while(1){
        int gge = gg.find_first_not_of('_',ggi);

        // cout<<ggi<<' '<<gge<<endl;

        string ss = gg.substr(ggi,gge-ggi);

        remap[ss].PB(cnt++);
        if(nodemap.find(ss) == nodemap.end()) nodemap[ss]=ncnt++;

        ggi = gge+1;

        if(gge==-1) break;
    }

    // for(auto p : nodemap)
        // cout<<p.aa<<' '<<p.bb<<endl;

    vector<string> podm;

    int ffi=0;
    while(1){
        int ffe = ff.find_first_of(',',ffi);

        string ss = ff.substr(ffi,ffe-ffi);

        // cout<<ss<<endl;

        int op = ss.find_first_not_of('_');

        // cout<<ss[op]<<endl;

        string a = ss.substr(0,op);
        string b = ss.substr(op+1);

        if(a==b){
            cout<<"false"<<endl;
            return 0;
        }

        if(ss[op]=='>'){
            g[nodemap[b]].PB(nodemap[a]);
            lerank[nodemap[a]]++;
        }
        else {
            g[nodemap[a]].PB(nodemap[b]);
            lerank[nodemap[b]]++;
        }

        ffi=ffe+1;

        if(ffe==-1) break;
    }

    vector<int> q;
    F(ncnt) if(lerank[i]==0)q.PB(i);

    int val=0;
    int vis=0;
    while(q.size()){
        vector<int> next;

        for(int node : q) {
            vis++;
            vals[node]=val;

            for(int neigh : g[node]) {
                lerank[neigh]--;
                if(lerank[neigh]==0)
                    next.PB(neigh);
            }
        }

        val++;
        q = move(next);
    }

    if(vis!=ncnt){
        cout<<"false"<<endl;
        return 0;
    }

    string res(cnt,'x');

    for(auto & p : nodemap){

        // cout<<p.aa<<' '<<p.bb<<' '<<vals[p.bb]<<endl;

        for(int mm : remap[p.aa]){
            // cout<<mm<<' ';
            res[mm] = vals[p.bb]+'0';
        }
        // cout<<endl;
    }

    cout<<res<<endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int sz;
int len[100];
int val[100];
bool b[100][100];

int pos(char * s, char c) {
    for (int i = 0; s[i]; ++i) {
        if (s[i] == c) {
            return i;
        }
    }
    return -1000010101;
}

int getLen(char * s, int i) {
    int j = i;
    while (s[j] == '_') ++j;
    return j - i;
}

int main() {
    char s[10000];
    gets(s);
    int l = pos(s, '(');
    int r = pos(s, ')');
    for (int i = l; i < r; ++i) {
        if (s[i]  != '_') continue;
        len[sz++] = getLen(s, i);
        i = i + len[sz - 1];
    }
    l = pos(s, '-') + 1;
    r = pos(s, '.');
    for (int i = l; i < r; ++i) {
        if (s[i]  != '_') continue;
        int l1 = getLen(s, i);
        int l2 = getLen(s, i + l1 + 1);
        if (s[i + l1] == '>') swap(l1, l2);
        b[l1][l2] = true;
        i = i + l1 + 1 + l2;
    }
    for (bool did = true; did; ) {
        did = false;
        for (int i = 0; i < sz; ++i) {
            for (int j = 0; j < sz; ++j) {
                int l1 = len[i];
                int l2 = len[j];
                if (val[i] >= val[j] && b[l1][l2]) {
                    val[j] = val[i] + 1;
                    did = true;
                    if (val[j] >= 10) {
                        puts("false");
                        return 0;
                    }
                }
            }
        }
    }
    for (int i = 0; i < sz; ++i) {
        putchar('0' + val[i]);
    }
    return 0;
}


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

using namespace std;

bool dfs(vector <int>* v, int start, int* used);
void bfs(vector <int>* v, int* l, int start);

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    string s;
    cin >> s;
    vector <int> a;
    set <int> m;
    int i = 2;
    for(;s[i] != ')';i++)
    {
        for(;s[i] != '_';i++);
        int j = 0;
        for(;s[i] == '_';i++, j++);
//        cout << i << endl;
        i--;
        a.push_back(j);
        m.insert(j);
    }
//    for(int i = 0;i < a.size();i++)
//        cout << a[i] << ' ';
    vector <int>* v = new vector <int>[m.size()];
    for(;s[i] != '-';i++);
    i++;
    bool* q = new bool[m.size()];
    for(int i = 0;i < m.size();i++)
        q[i] = false;
    for(;i < s.size();i++)
    {
        for(;s[i] != '_';i++);
        int j = 0;
        for(;s[i] == '_';i++, j++);
        char c = s[i];
        i++;
        int j1 = 0;
        for(;s[i] == '_';i++, j1++);
        if(j == j1)
        {
            cout << "false";
            return 0;
        }
        int l = 0;
        set <int>::iterator t1 = m.find(j);
        for(set <int>::iterator t = m.begin();t != t1;++t, l++);
        int l1 = 0;
        t1 = m.find(j1);
        for(set <int>::iterator t = m.begin();t != t1;++t, l1++);
        if(c == '<')
        {

            v[l].push_back(l1);
            q[l1] = true;
        }
        if(c == '>')
        {
            v[l1].push_back(l);
            q[l] = true;
        }
    }
    int* path = new int[m.size()];
    int* used = new int[m.size()];
    for(int i = 0;i < m.size();i++)
        used[i] = path[i] = 0;
    for(int i = 0;i < m.size();i++)
    {
        if(!q[i])
            if(!dfs(v, i, used))
            {
                cout << "false";
                return 0;
            }
    }
    for(int i = 0;i < m.size();i++)
        if(!q[i])
            bfs(v, path, i);
    for(int i = 0;i < m.size();i++)
//    {
        if(path[i] > 9)
        {
            cout << "false";
            return 0;
        }
//        cout << v[i].size() << ' ';
//        for(int j = 0;j < v[i].size();j++)
//            cout << v[i][j] << ' ';
//        cout << path[i] << ' ';
//        cout << endl;
//    }
    for(int i = 0;i < a.size();i++)
    {
        set <int>::iterator t1 = m.find(a[i]);
        int l = 0;
        for(set <int>::iterator t = m.begin();t != t1;++t, ++l);
        cout << path[l];
    }
    return 0;
}

bool dfs(vector <int>* v, int start, int* used)
{
    used[start] = 1;
    for(int i = 0;i < v[start].size();i++)
    {
        if(used[v[start][i]] == 0)
        {
//            l[v[start][i]] = max(l[v[start][i]], l1 + 1);
            if(!dfs(v, v[start][i], used))
                return false;
        }
        if(used[v[start][i]] == 1)
            return false;
    }
    used[start] = 2;
    return true;
}

void bfs(vector <int>* v, int* l, int start)
{
    queue <pair <int, int> > q;
    q.push(make_pair(start, 0));
    l[start] = 0;
    while(!q.empty())
    {
        int t = q.front().first;
        l[t] = q.front().second;
        for(int i = 0;i < v[t].size();i++)
            q.push(make_pair(v[t][i], l[t] + 1));
        q.pop();
    }
}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define eb emplace_back

typedef long long ll;
typedef long double ld;

const int inf = 2e9;
const ll base = 998244353;
const int maxn = 300500;

int main() {
    srand(time(NULL));
    // freopen("input.txt", "r", stdin);
    //freopen("output.txt", "r", stdin);
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    string a; cin >> a;
    int n = a.length();
    vector <int> b(n);
    for (int i = 0; i < n; ++i) {
        if (a[i] == 'A') {
            b[i] = 1;
        } else {
            b[i] = 0;
        }
    }
    vector<pair<int, int>> dp1(n + 1), dp2(n + 1);
    dp1[0] = {1, 0};
    dp2[0] = {0, 1};
    map<pair<int, int>, pair<vector<int>, vector<int>>> s;
    s[{0, 0}] = {{0, 1}, {}};
    s[{0, 1}] = {{1}, {0}};
    s[{1, 0}] = {{0, 1}, {1}};
    s[{1, 1}] = {{1}, {1}};
    for (int i = 1; i <= n; ++i) {
        int cur = i % n, prev = i - 1;
        for (auto c : s[{b[prev], b[cur]}].first) {
            if (!c) dp1[i].first += dp1[prev].first;
            else dp1[i].second += dp1[prev].first;
            if (!c) dp2[i].first += dp2[prev].first;
            else dp2[i].second += dp2[prev].first;
        }
        for (auto c : s[{b[prev], b[cur]}].second) {
            if (!c) dp1[i].first += dp1[prev].second;
            else dp1[i].second += dp1[prev].second;
            if (!c) dp2[i].first += dp2[prev].second;
            else dp2[i].second += dp2[prev].second;
        }
    }
    cout << 1LL*dp1[n].first + 1LL*dp2[n].second;
    return 0;
}


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

using namespace std;
typedef long long LL;

#define oo 1000000000
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))

const double pi = acos(-1.0);

#define maxn 100 + 10

int n;
char str[maxn];
int f[maxn][2][2][2][2];

int main()
{
	int i,j,k,l,u,v,ans = 0;

	scanf("%s",str+1);
	n = strlen(str+1);

	f[2][0][0][0][0] = 1, f[2][1][1][0][1] = 1, f[2][1][0][0][0] = 1, f[2][1][0][1][0] = 1;
	for( i = 2 ; i < n ; ++i )
		for( j = 0 ; j <= 1 ; ++j )
			for( v = 0 ; v <= 1 ; ++v )
				for( k = 0 ; k <= 1 ; ++k )
					for( l = 0 ; l <= 1 ; ++l )
						for( u = 0 ; u <= 1 ; ++u )
							{
								if( k == 0 && u == 1 && l == 0 )
									{
										if( str[i] == 'B' )
											f[i+1][j][v][0][1] += f[i][j][v][k][l];
									}
								else if( k == str[i]-'A' )
									f[i+1][j][v][u][0] += f[i][j][v][k][l];
							}
	for( i = 0 ; i <= 1 ; ++i )
		for( v = 0 ; v <= 1 ; ++v )
			for( j = 0 ; j <= 1 ; ++j )
				for( k = 0 ; k <= 1 ; ++k )
					{
						if( j == 0 && i == 1 && k == 0 && v == 0 )
							{
								if( str[1] == 'A' && str[n] == 'B' )
									ans += f[n][i][v][j][k];
							}
						else if( i == str[1]-'A' && j == str[n]-'A' )
							ans += f[n][i][v][j][k];
					}
	printf("%d\n",ans);

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define eb emplace_back

typedef long long ll;
typedef long double ld;
typedef int long long;

const int inf = 2e9;
const ll base = 998244353;
const int maxn = 300500;

int main() {
    srand(time(NULL));
    // freopen("input.txt", "r", stdin);
    //freopen("output.txt", "r", stdin);
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    string a; cin >> a;
    int n = a.length();
    vector <int> b(n);
    for (int i = 0; i < n; ++i) {
        if (a[i] == 'A') {
            b[i] = 1;
        } else {
            b[i] = 0;
        }
    }
    vector<pair<int, int>> dp1(n + 1), dp2(n + 1);
    dp1[0] = {1, 0};
    dp2[0] = {0, 1};
    map<pair<int, int>, pair<vector<int>, vector<int>>> s;
    s[{0, 0}] = {{0, 1}, {}};
    s[{0, 1}] = {{1}, {0}};
    s[{1, 0}] = {{0, 1}, {1}};
    s[{1, 1}] = {{1}, {1}};
    for (int i = 1; i <= n; ++i) {
        int cur = i % n, prev = i - 1;
        for (auto c : s[{b[prev], b[cur]}].first) {
            if (!c) dp1[i].first += dp1[prev].first;
            else dp1[i].second += dp1[prev].first;
            if (!c) dp2[i].first += dp2[prev].first;
            else dp2[i].second += dp2[prev].first;
        }
        for (auto c : s[{b[prev], b[cur]}].second) {
            if (!c) dp1[i].first += dp1[prev].second;
            else dp1[i].second += dp1[prev].second;
            if (!c) dp2[i].first += dp2[prev].second;
            else dp2[i].second += dp2[prev].second;
        }
    }
    cout << dp1[n].first + dp2[n].second;
    return 0;
}


#pragma comment(linker, "/STACK:100000000")
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <ctime>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
using namespace std;
#define int64 long long
#define ldb long double
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define taskname "task_c"
const ldb pi = acos(-1.0);

const int MAXN = 150;

string s;
bool is_ab[MAXN], used[MAXN];
vector <int> adj[MAXN];
long long cycles[MAXN], lines[MAXN];

int dfs (int v) {
	used[v] = false;

	int num = 1;
	for (int i = 0; i < sz(adj[v]); ++i) {
		if (!used[adj[v][i]]) {
			num += dfs(adj[v][i]);
		}
	}

	return num;
}

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

	cin >> s;
	reverse(s.begin(), s.end());
	int n = s.length();

	lines[0] = 1;
	lines[1] = 2;
	for (int i = 2; i <= n / 2; ++i) {
		lines[i] = lines[i - 1] + lines[i - 2];
	}

	cycles[2] = 3;
	for (int i = 3; i <= n / 2; ++i) {
		cycles[i] = lines[i - 1] + lines[i - 3];
	}

	for (int i = 0; i < n; ++i) {
		is_ab[i] = false;
	}

	for (int i = 0; i < n; ++i) {
		if (s[i] == 'A' && s[(i + 1) % n] == 'B') {
			is_ab[i] = true;
		}
	}

	int num_ab = 0;
	for (int i = 0; i < n; ++i) {
		used[i] = !is_ab[i];
		num_ab += (int) is_ab[i];
	}

	if (num_ab == n / 2 && (n % 2 == 0)) {
		cout << cycles[n / 2] << endl;
		return 0;
	}

	for (int i = 0; i < n; ++i) {
		if (s[i] == 'B' && s[(i + 1) % n] == 'A') {
			int v1 = (i - 1 + n) % n;
			int v2 = (i + 1) % n;

			if (!is_ab[v1] && !is_ab[v2]) {
				cout << 0 << endl;
				return 0;
			} else if (is_ab[v1] && is_ab[v2]) {
				adj[v1].pb(v2);
				adj[v2].pb(v1);
			} else if (is_ab[v1]) {
			 	used[v1] = true;
			} else {
				used[v2] = true;
			}
		}
	}

	long long ans = 1;
	for (int i = 0; i < n; ++i) {
		if (!used[i]) {
			ans = ans * lines[dfs(i)];
		}
	}
	cout << ans << endl;

	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
const int N=3000;
const double Pi=acos(-1),eps=1e-9;
int n,k,c,Ans;
double x[N],y[N],r[N];
struct cf{double x;int v;}q[N];
int cmp(const cf&A,const cf&B) {return fabs(A.x-B.x)<eps?A.v<B.v:A.x<B.x;}
int Calc(double ang)
{
	double X=sin(ang),Y=cos(ang);
	int tot=0;
	for(int i=1;i<=n;i++)
	{
		double val=-x[i]*X+y[i]*Y;
		q[++tot]=(cf){val-r[i],1};
		q[++tot]=(cf){val+r[i],-1};
	}
	sort(q+1,q+tot+1,cmp);
	int tmp=0,ans=0;
	for(int i=1;i<=tot;i++)
		ans=max(ans,tmp+=q[i].v);
	return ans;
}
/*int Calc(double nw)
{
	if(nw==Pi/2) return 0;
	int ans=0;
	double co=cos(nw),ta=tan(nw);
	for(int i=1;i<=n;i++)
	{
		double b=A[i].y-A[i].x*ta;
		double d=fabs(A[i].r/co);
		q[i*2-1]=(cf){b-d,1};
		q[i*2]=(cf){b+d,-1};
	}
	sort(q+1,q+2*n+1,cmp);
	for(int i=1,res=0;i<=2*n;i++)
		res+=q[i].v,ans=max(ans,res);
	return ans;
}*/
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>x[i]>>y[i]>>r[i];
	for(double step=0.0005,st=0,ed=2*Pi,res;step>eps;step/=5)
	{
		int mx=0;
		for(double i=st;i<ed;i+=step)
		{
			int nw=Calc(i);
			if(nw>mx) mx=nw,res=i;
		}
		st=res-step*5;
		ed=res+step*5;
		Ans=max(Ans,mx);
	}
//	printf("Ans=%d\n",Ans);
	cout<<1ll*k*(k+1)/2+n+1ll*(Ans-1)*k<<endl;
}


#include<iostream>
#include<algorithm>
using namespace std;
const int N=3000;
const double Pi=acos(-1),eps=1e-9;
int n,k,c,Ans;
double x[N],y[N],r[N];
struct cf{double x;int v;}q[N];
int cmp(const cf&A,const cf&B) {return fabs(A.x-B.x)<eps?A.v<B.v:A.x<B.x;}
int Calc(double ang)
{
	double X=sin(ang),Y=cos(ang);
	int tot=0;
	for(int i=1;i<=n;i++)
	{
		double val=-x[i]*X+y[i]*Y;
		q[++tot]=(cf){val-r[i],1};
		q[++tot]=(cf){val+r[i],-1};
	}
	sort(q+1,q+tot+1,cmp);
	int tmp=0,ans=0;
	for(int i=1;i<=tot;i++)
		ans=max(ans,tmp+=q[i].v);
	return ans;
}
/*int Calc(double nw)
{
	if(nw==Pi/2) return 0;
	int ans=0;
	double co=cos(nw),ta=tan(nw);
	for(int i=1;i<=n;i++)
	{
		double b=A[i].y-A[i].x*ta;
		double d=fabs(A[i].r/co);
		q[i*2-1]=(cf){b-d,1};
		q[i*2]=(cf){b+d,-1};
	}
	sort(q+1,q+2*n+1,cmp);
	for(int i=1,res=0;i<=2*n;i++)
		res+=q[i].v,ans=max(ans,res);
	return ans;
}*/
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>x[i]>>y[i]>>r[i];
	for(double step=0.00005,st=0,ed=2*Pi,res;step>eps;step/=5)
	{
		int mx=0;
		for(double i=st;i<ed;i+=step)
		{
			int nw=Calc(i);
			if(nw>mx) mx=nw,res=i;
		}
		st=res-step*5;
		ed=res+step*5;
		Ans=max(Ans,mx);
	}
//	printf("Ans=%d\n",Ans);
	cout<<1ll*k*(k+1)/2+n+1ll*(Ans-1)*k<<endl;
}


#pragma comment(linker, "/STACK:65777216")

#include <algorithm>
#include <iostream>
#include <string>
#include<sstream>
#include<string.h>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include<stack>
#include <set>
#include <map>
#include<ctime>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef unsigned long long ull;

#define FOR(i,a,b) for (int i(a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define SORT(v) sort((v).begin(),(v).end())
#define UN(v) sort((v).begin(),(v).end()),v.erase(unique(v.begin(),v.end()),v.end())
#define CL(a,b) memset(a,b,sizeof(a))
#define pb push_back

typedef pair<double,int> pdi;

const double eps = 1e-8;
const double pi = acos(-1.);

int n;
int x[1111],y[1111],r[1111];

double getA(double a){
	if(a<0) return a+2*pi;
	return a;
}
void add(vector<pdi> &v, double a1,double a2,int q){
	if(a2<=2*pi){
		v.pb(pdi(a1+eps,q+1));
		v.pb(pdi(a2-eps,-q-1));
	}else{
		v.pb(pdi(0,q+1));
		v.pb(pdi(a2-2*pi-eps,-q-1));
		v.pb(pdi(a1+eps,q+1));
		v.pb(pdi(2*pi,-q-1));
	}
}

double go(int i,int j,double a,double b,double c){
	if(a<0 || a<eps && b<0) a=-a,b=-b,c=-c;
	//cout<<a<<' '<<b<<' '<<c<<endl;
	double xx = a*r[i];
	double yy = b*r[i];
	if(fabs(fabs(xx*a+yy*b+c)-0)>eps) xx = -xx, yy = -yy;
	//cout<<xx<<' '<<yy<<endl;
	return getA(atan2(yy,xx));
}

bool good(int i,int j,double a){
	double xx = cos(a)*r[i];
	double yy = sin(a)*r[i];
	double A = cos(a), B = sin(a);
	double C = -(xx*A+yy*B);
	//cout<<A*xx+B*yy+C<<endl;
	return fabs(A*x[j]+B*y[j]+C)<r[j];
	//return 1;
}

int solve(){
	int res = 1;
	REP(i,n){
		REP(j,n)if(i!=j)x[j]-=x[i],y[j]-=y[i];
		vector<pdi> v;
		REP(j,n)if(i!=j){
			double ang[9];int pos=0;
			REP(t1,2)REP(t2,2){
				double c = (t1?-r[i]:r[i]);
				double E = (t2?-r[j]:r[j])-c;
				if(x[j]==0){
					double b = E / y[j];
					double a1 = sqrt(1-b*b);
					double a2 = -a1;

					ang[pos++]=go(i,j,a1,b,c);
					ang[pos++]=go(i,j,a2,b,c);
				}else{
					double A = E/x[j];
					double B = -y[j]/double(x[j]);

					double k1 = B*B+1;
					double k2 = 2*A*B;
					double k3 = A*A-1;
					double D = k2*k2-4*k1*k3;
					D = sqrt(D);

					double b1 = (-k2-D)/2/k1;
					double b2 = (-k2+D)/2/k1;
					double a1 = A+B*b1;
					double a2 = A+B*b2;

					ang[pos++]=go(i,j,a1,b1,c);
					ang[pos++]=go(i,j,a2,b2,c);
				}
			}
			sort(ang,ang+8);
			ang[8]=ang[0]+2*pi;
			//REP(k,9) cout<<ang[k]<<' ';puts("");
			FOR(k,1,9){
				double s =(ang[k-1]+ang[k])/2;
				if(good(i,j,s)){
					add(v, ang[k-1],ang[k], j);
					//cout<<ang[i-1]<<' '<<ang[i]<<endl;
				}
			}
		}

		REP(j,n)if(i!=j)x[j]+=x[i],y[j]+=y[i];
		SORT(v);
		int cnt=1,z=1;
		REP(j,v.size()){
			if(v[j].second>=0) cnt++;
			else cnt--;
			z=max(z,cnt);
		}
		//cout<<i<<": "<<z<<endl;
		res = max(res, z);
	}
	return res;
}

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

	ll k;
	cin>>n>>k;
	REP(i,n) scanf("%d %d %d",x+i,y+i,r+i);
	cout<<n+(2*solve()+k-1)*k/2<<endl;

#ifdef LocalHost
	cout<<endl<<endl<<"TIME: "<<clock()<<endl;
#endif
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
const int N=3000;
const double Pi=acos(-1),eps=1e-9;
int n,k,c,Ans;
double x[N],y[N],r[N];
struct cf{double x;int v;}q[N];
int cmp(const cf&A,const cf&B) {return fabs(A.x-B.x)<eps?A.v<B.v:A.x<B.x;}
int Calc(double ang)
{
	double X=sin(ang),Y=cos(ang);
	int tot=0;
	for(int i=1;i<=n;i++)
	{
		double val=-x[i]*X+y[i]*Y;
		q[++tot]=(cf){val-r[i],1};
		q[++tot]=(cf){val+r[i],-1};
	}
	sort(q+1,q+tot+1,cmp);
	int tmp=0,ans=0;
	for(int i=1;i<=tot;i++)
		ans=max(ans,tmp+=q[i].v);
	return ans;
}
/*int Calc(double nw)
{
	if(nw==Pi/2) return 0;
	int ans=0;
	double co=cos(nw),ta=tan(nw);
	for(int i=1;i<=n;i++)
	{
		double b=A[i].y-A[i].x*ta;
		double d=fabs(A[i].r/co);
		q[i*2-1]=(cf){b-d,1};
		q[i*2]=(cf){b+d,-1};
	}
	sort(q+1,q+2*n+1,cmp);
	for(int i=1,res=0;i<=2*n;i++)
		res+=q[i].v,ans=max(ans,res);
	return ans;
}*/
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>x[i]>>y[i]>>r[i];
	for(double step=0.0005,st=0,ed=2*Pi,res;step>eps;step/=10)
	{
		int mx=0;
		for(double i=st;i<ed;i+=step)
		{
			int nw=Calc(i);
			if(nw>mx) mx=nw,res=i;
		}
		st=res-step*5;
		ed=res+step*5;
		Ans=max(Ans,mx);
	}
//	printf("Ans=%d\n",Ans);
	cout<<1ll*k*(k+1)/2+n+1ll*(Ans-1)*k<<endl;
}