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

int main()
{
	int t;
	std::cin >> t;

	std::vector<std::pair<int, int>> fgh(t);

	for (int i = 0; i < t; i++)
	{
		std::pair<int, int> p;
		std::cin >> p.first >> p.second;
		fgh[i] = p;
	}

	for (int i = 0; i < t; i++)
	{
		if (fgh[i].first != fgh[i].second)
		{
			std::cout << -1 << "\n";
			continue;
		}

		for (int j = 0; j < fgh[i].first; j++)
		{
			std::string s;

			for (int k = 0; k < fgh[i].second; k++)
			{
				if (k >= fgh[i].first - j - 1)
					s += "1 ";
				else
					s += "0 ";
			}

			std::cout << s + "\n";
		}
	}
}