public int findAllCircle(Map<Integer, Integer> map) {
		ArrayList<Integer> list = new ArrayList<Integer>();
		boolean[] visited = new boolean[map.size()];
		
		for(int i = 0; i < map.size(); i++) {
			if(!visited[i]) {
				int cur = i, count = 0;
				do{
					visited[cur] = true;
					cur = map.get(cur);
					count++;
				} while(cur != i);
//				System.out.println(count);
				if(count > 1) list.add(count);
			}
		}
		
		if(list.size() == 1) return list.get(0);
		else {
			int num = list.get(0);
			for(int i = 1; i < list.size(); i++) {
				int gcd = gcd(num, list.get(i));
				int lcm = num * list.get(i) / gcd;
				num = lcm;
			}
			return num;
		}
	}