private static int lca(int a, int b) {
		boolean[] used = new boolean[n];
		for (;;) {
			a = base[a];
			used[a] = true;
			if (mt[a] == -1)
				break;
			a = p[mt[a]];
		}
		// from b node
		for (;;) {
			b = base[b];
			if (used[b])
				return b;
			b = p[mt[b]];
		}
	}