struct FastIO {
static const int S = 1000 << 1;
int wpos;
char wbuf[S];
FastIO() : wpos(0) {}
inline int xchar() {
static char buf[S];
static int len = 0, pos = 0;
if (pos == len) {
pos = 0;
len = (int)fread(buf, 1, S, stdin);
}
if (pos == len) {
return -1;
}
return buf[pos++];
}
inline int xint() {
int s = 1, c = xchar(), x = 0;
while (c <= 32) {
c = xchar();
}
if (c == '-') {
s = -1;
c = xchar();
}
for (; '0' <= c && c <= '9'; c = xchar()) {
x = x * 10 + c - '0';
}
return x * s;
}
~FastIO() {
if (wpos) {
fwrite(wbuf, 1, wpos, stdout);
wpos = 0;
}
}
} io;
class Reader
{
public:
inline char nc();
template<class T> inline void read(T &x);
template<class T> inline Reader& operator >> (T &x) { read(x); return *this; }
} rd;
inline char Reader::nc()
{
static char buf[100000], *p1=buf, *p2=buf;
if (p1 == p2) { p2 = (p1 = buf) + fread(buf, 1, 100000, stdin); if (p1 == p2) exit(0); }
return *p1++;
}
template<class T> inline void Reader::read(T &x)
{
char c = nc(); bool b = 0;
for (; !(c >= '0' && c <= '9'); c = nc()) if (c == '-') b = 1;
for (x = 0; c >= '0' && c <= '9'; x = x * 10 + c - '0',c = nc());
if(b) x = -x;
}