#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

void solve() {
    int N, H;
    cin >> N >> H;
    
    // Tạo chuỗi ban đầu có N - H ký tự '0' và H ký tự '1'
    string s = "";
    for (int i = 0; i < N - H; i++) s += '0';
    for (int i = 0; i < H; i++) s += '1';
    
    // In ra hoán vị đầu tiên và sinh các hoán vị tiếp theo theo thứ tự từ điển
    do {
        cout << s << "\n";
    } while (next_permutation(s.begin(), s.end()));
}

int main() {
    // Tối ưu hóa I/O
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int T;
    if (cin >> T) {
        while (T--) {
            solve();
            if (T > 0) {
                cout << "\n"; // Dòng trống phân tách giữa các bộ test
            }
        }
    }
    return 0;
}
