private static int[][] getTransitionsPowers(int statesCount, int eventsCount, int varsCount, int transitionsCount,
			Random random) {

		int[] pow = new int[varsCount + 1];
		pow[0] = 1;
		for (int i = 1; i <= varsCount; i++) {
			pow[i] = pow[i - 1] * 2;
		}

		int[][] ans = new int[statesCount][eventsCount];
		for (int i = 0; i < statesCount; i++) {
			Arrays.fill(ans[i], varsCount);
		}

		int maxTransitions = statesCount * eventsCount * pow[varsCount];

		int[] stateSum = new int[statesCount];
		Arrays.fill(stateSum, eventsCount * pow[varsCount]);

		int sum = maxTransitions;
		while (sum > transitionsCount) {
			int state = random.nextInt(statesCount);
			int event = random.nextInt(eventsCount);
			if (ans[state][event] == -1) {
				continue;
			}

			int newVal = random.nextInt(varsCount + 2) - 1;
			if (newVal == -1 && stateSum[state] == pow[ans[state][event]]) {
				continue;
			}

			if (ans[state][event] > newVal) {
				int diff = pow[ans[state][event]];
				if (newVal > -1) {
					diff -= pow[newVal];
				}
				sum -= diff;
				stateSum[state] -= diff;
				ans[state][event] = newVal;
			}
		}
		return ans;
	}