cleaned up, kattis subm 450935