solve codeforces 490E