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

#967. Gray code

You get n. Print the n-bit Gray code (code i = i XOR (i >> 1)) for i from 0 to 2ⁿ-1, each as a binary string of length n, one per line. ### Input One integer n (1 ≤ n ≤ 5). ### Output 2ⁿ lines.

Examples

Input
2
Output
00
01
11
10
Input
4
Output
0000
0001
0011
0010
0110
0111
0101
0100
1100
1101
1111
1110
1010
1011
1001
1000

💡 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!