Working on TOJ - Problem 1409 & 1820