CF605D Board Game
Description
You are playing a board card game. In this game the player has two characteristics, $ x $ and $ y $ — the white magic skill and the black magic skill, respectively. There are $ n $ spell cards lying on the table, each of them has four characteristics, $ a_{i} $ , $ b_{i} $ , $ c_{i} $ and $ d_{i} $ . In one move a player can pick one of the cards and cast the spell written on it, but only if first two of it's characteristics meet the requirement $ a_{i}
Input Format
The first line of the input contains a single integer $ n $ ( $ 1
Output Format
In the first line print a single integer $ k $ — the minimum number of moves needed to cast the $ n $ -th spell and in the second line print $ k $ numbers — the indices of the cards in the order in which you should cast them. In case there are multiple possible solutions, print any of them.
If it is impossible to cast the $ n $ -th spell, print $ -1 $ .