```ts
// solution.ts

export function stepAllowed(from: string, to: string, allowed: string[][]): boolean {
  return !!allowed.find((move) => move[0] === from && move[1] === to);
}

export function stepPlan(states: string[], allowed: string[][]): number {
  for (let i = 0; i < states.length - 1; i++) {
    if (!stepAllowed(states[i], states[i + 1], allowed)) {
      return i;
    }
  }
  throw new Error("All moves are allowed.");
}
```