public void Solve() {
        ArrayList<HashMap<String, List<String>>> polygonals = new ArrayList<HashMap<String, List<String>>>();
        for (int i = 0; i < 6; i++) {
            polygonals.add(new HashMap<String, List<String>>());
        }

        int n = 1;
        int minValue = 0;
        while (minValue < _max) {
            int triangle = Triangle(n);
            CheckAndAdd(triangle, polygonals.get(0));
            minValue = triangle;

            int square = Square(n);
            CheckAndAdd(square, polygonals.get(1));
            minValue = Math.min(minValue, square);

            int pentagonal = Pentagonal(n);
            CheckAndAdd(pentagonal, polygonals.get(2));
            minValue = Math.min(minValue, pentagonal);

            int hexagonal = Hexagonal(n);
            CheckAndAdd(hexagonal, polygonals.get(3));
            minValue = Math.min(minValue, hexagonal);

            int heptagonal = Heptagonal(n);
            CheckAndAdd(heptagonal, polygonals.get(4));
            minValue = Math.min(minValue, heptagonal);

            int octagonal = Octagonal(n);
            CheckAndAdd(octagonal, polygonals.get(5));
            minValue = Math.min(minValue, octagonal);

            n++;
        }

        System.out.println("Initialization complete");
        for (int i = 0; i < polygonals.size(); i++) {
            System.out.println("Size for polygonal " + i + "= " + polygonals.get(i).size());
        }
        System.out.println();

        ArrayList<HashMap<String, List<String>>> list = new ArrayList<HashMap<String, List<String>>>(polygonals);
        list.remove(0);
        for (Iterator<Map.Entry<String, List<String>>> it = polygonals.get(0).entrySet().iterator(); it.hasNext();) {
            Map.Entry<String, List<String>> entry = it.next();

            for (Iterator<String> it1 = entry.getValue().iterator(); it1.hasNext();) {
                String n1 = it1.next();

                System.out.println("Processing n1=" + n1);

                ArrayList<String> initials = new ArrayList<String>();
                initials.add(n1);
                List<String> result = DoProcess(initials, list);
                if (result != null) {
                    System.out.print("Result= ");
                    int sum = 0;
                    for (int i = 0; i < result.size(); i++) {
                        System.out.print(result.get(i) + ", ");
                        sum += Integer.valueOf(result.get(i));
                    }
                    System.out.println("Sum= " + sum);
                    return;
                }
            }
        }
    }