input:
5 6 0 1 1 1 1 0 0 1 0 0 0 1 1 1 1 1 1 2 0 1 2 1 1 4 1 1 5 1
answer:
0 0 0 0 0 1
https://www.luogu.com.cn/article/dsuxavbf WA
https://www.luogu.com.cn/article/6mtajfxb CE
https://www.luogu.com.cn/article/hm0q4i9v WA