public static void main(String[] args) {
		Random gen = new Random();

		for (int times = 0; times < 1000; ++times) {
			List<Integer> p = new ArrayList<Integer>();
			if (args.length > 2) {
				for (int i = 1; i < args.length; ++i) {
					p.add(Integer.valueOf(args[i]));
				}
			} else {
				int n = (args.length == 2 ? Integer.valueOf(args[1]) : (gen.nextInt(100) + 1));
				for (int i = 0; i < n; ++i) {
					p.add(gen.nextInt(n));
				}
			}
			// System.out.print("p = ");
			// simplePrint(p);
			// System.out.println();

			// goldenNextPermutation does not change does not change p
			List<Integer> gold = goldenNextPermutation(p);
			// System.out.print("gold = ");
			// simplePrint(gold);
			// System.out.println();
			
			List<Integer> ans = next_permutation(p);
			// System.out.print("ans = ");
			// simplePrint(ans);
			// System.out.println();
			
			assert equal(gold, ans);
		}
	}