public ArrayList<ArrayList<Integer>> fourSum(int[] num, int target) {
        HashMap<Integer,char[]> m = new HashMap<Integer, char[]>();
        m.put(2, new char[] {'a', 'b', 'c'});
        
        
        
        
        // Note: The Solution object is instantiated only once and is reused by each test case.
        ArrayList<ArrayList<Integer>> results = new ArrayList<ArrayList<Integer>>();
        Arrays.sort(num);
        
        
        Object[][] f = new Object[num.length][5];
        
        for (int i=0; i<num.length; i++) {
        	HashMap<Integer, Node> dest = new HashMap<Integer, Node>();
        	dest.put(0, new Node(0));
        	f[i][0] = dest;
        }
        for (int i=0; i<num.length; i++) {
        	for (int j=1; j<=4; j++) {
        		HashMap<Integer, Node> dest = new HashMap<Integer, Node>();
        		for (int k=0; k<i; k++) {
        			HashMap<Integer, Node> src = (HashMap<Integer, Node>) f[k][j-1];
        			
        			for (Integer oldsum : src.keySet()) {
        				Integer newsum = oldsum + num[i];
        				Node destNode = dest.get(newsum);
        				if (destNode == null) {
        					destNode = new Node(num[i]);
        					dest.put(newsum, destNode);
        				}
        				destNode.addPrev(src.get(oldsum));
        			}
        		}
        		f[i][j] = dest;
        	}
        }
        
        for (int i=0; i<num.length; i++) {
        	HashMap<Integer, Node> dest = (HashMap<Integer, Node>) f[i][4];
        	if (dest.containsKey(target)) {
        		buildResults(dest.get(target), 0, new int[4], results, new HashSet<String>());
        	}
        }
        
        return results;
    }