CodeLab Academy 📞 9936 6696
← List Python · Level 10: Algorithms Code · 100 points ← #957 #959 →

#958. Merge intervals

You get n intervals [s, e]. Merge the intervals that overlap (or touch) and print them as `s e` in increasing order of start. ### Input n, then n lines `s e`. ### Output Lines.

Examples

Input
2
20 21
7 10
Output
7 10
20 21
Input
7
17 22
12 16
16 19
3 9
0 2
12 14
8 11
Output
0 2
3 11
12 22

💡 You can solve it with Python, JavaScript or blocks. Read the input line by line with input(). Don't print a question (like input("Number: ")). Print exactly what the output asks for, nothing more.

🔒 You can solve the first 3 problems without an account. Sign up for free to solve this one!