private static void process(A[] as, S[] ss) {
		Arrays.sort(as);
		Queue<A> unchecked = new LinkedList<A>();
		for (int i = as.length - 1; i >= 0; i--) {
			A a = as[i];
			unchecked.offer(a);
		}

		while (!unchecked.isEmpty()) {
			A a = unchecked.poll();
			int[] xs = a.ss;
			for (int i = 0; i < xs.length; i++) {
				int rt = ss[xs[i]].checkAndProcess(a);
				if (rt >= 0) {
					A b = as[rt];
					unchecked.offer(b);
					break;
				} else if (rt == -1) {
					break;
				}

			}
		}
	}