private static void join (int a, int b) {
		int x = root (a), y = root (b);
		
		if (taken [x] == D && taken [y] == D)
			throw new RuntimeException();
		
		if (taken [x] == D) {
			par [x] = y;
			taken [y]++;
			if (depth [x] + 1 > depth [y])
				depth [y] = depth [x] + 1;
		} else if (taken [y] == D) {
			par [y] = x;
			taken [x]++;
			if (depth [y] + 1 > depth [x])
				depth [x] = depth [y] + 1;
		} else if (depth [x] > depth [y]) {
			par [y] = x;
			taken [x]++;
			if (depth [y] + 1 > depth [x])
				depth [x] = depth [y] + 1;
		} else {
			par [x] = y;
			taken [y]++;
			if (depth [x] + 1 > depth [y])
				depth [y] = depth [x] + 1;
		}
	}