problem no 308B
my second submission is wrong according to codeforces compiler but it gives the correct answer in ideone compiler.