3 3
2 As shown below, the condition is satisfied only when $c = (2,3,1)$ or $c = (3,2,1)$. Sequences such as $c = (2,3,2)$, $c = (2,1,3)$, $c = (1,2,2)$ do not satisfy the condition. 
150 300
734286322
300 150
0
{
"problem": {
"name": "Road of the King",
"description": {
"content": "There are $N$ towns in Takahashi Kingdom. They are conveniently numbered $1$ through $N$. Takahashi the king is planning to go on a tour of inspection for $M$ days. He will determine a sequence of tow",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 3000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "codefestival_2016_final_f"
},
"statements": [
{
"statement_type": "Markdown",
"content": "There are $N$ towns in Takahashi Kingdom. They are conveniently numbered $1$ through $N$.\nTakahashi the king is planning to go on a tour of inspection for $M$ days. He will determine a sequence of tow...",
"is_translate": false,
"language": "English"
}
]
}