Binary Strings of Length N

EasyRecursion & Backtracking
Next
RecursionBacktracking

Print every binary string of length n (strings made of 0 and 1) in ascending lexicographic order, one per line.

Input

A single integer n.

Output

2^n lines, each a binary string of length n, in ascending order.

Constraints

1 <= n <= 12

Example 1
Input
2
Output
00
01
10
11

The four strings in order: 00, 01, 10, 11.

Hints

Binary Strings of Length N - Easy Recursion & Backtracking Problem | Skill Shiksha