```ts
function stepAllowed(from: string, to: string, allowed: string[][]): boolean {
  for (const move of allowed) {
    if (move[0] === from && move[1] === to) return true;
  }
  return false;
}

function stepPlan(states: string[], allowed: string[][]): number {
  for (let i = 0; i < states.length - 1; i++) {
    const from = states[i];
    const to = states[i + 1];
    if (!stepAllowed(from, to, allowed)) return i;
  }
  return -1;
}
```