Regarding output format

Do we need to print the output in the next line?

Usually, yes. It will be specified in the problem statement.