【Codeforces 639C】Bear and Polynomials

【BZOJ2456】mode