spoj0; solve "Power" from Contest 61