solved problem1 using php