private static void permute_tool (List<List<Integer>> ret, 
    		ArrayList<Integer> tmp, int num[], boolean[] visited) 
    {
    	if (tmp.size() == num.length) 
    	{
    		ret.add(new ArrayList<Integer>(tmp));
    		return;
    	}
    	else 
    	{
    		for (int i = 0; i < num.length; ++i) 
    		{
    			if (!visited[i])
    			{
    				tmp.add(num[i]);
    				visited[i] = true;
    				permute_tool(ret, tmp, num, visited);
    				tmp.remove(tmp.size()-1);
    				visited[i] = false;
    				while (i+1 < num.length && num[i] == num[i+1])
    					++i;//jump over duplicate data
    			}
    		}
    	}
    }