Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/rekursiya-ikkilik-satrlar

Binary strings with k ones

Easy 1000 ms 128 MB 33%
Share

You are given integers $n$ and $k$. Print in lexicographic order (the character 0 comes before 1) all strings of length $n$ made of the characters 0 and 1 that contain exactly $k$ ones 1.

A list of strings of zero and one cells, the ones in every string highlighted

Input

One line with two integers: $n$ and $k$.

Output

Each string on its own line, in lexicographic order.

Note

$1 \le n \le 16$
$0 \le k \le n \le 16$

Examples

Input #1
3 1
Output #1
001
010
100
Input #2
4 2
Output #2
0011
0101
0110
1001
1010
1100

Sign in to submit a solution

Signing up is free and takes a minute.