#define min(x, y) ((x)<(y)?(x):(y))
#define square(x) ((x)*(x))
#define swap(x, y) { x ^= y; y ^= x; x ^= y; }