#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <tuple>
#include <chrono>

//boilerplate point/vector class
template<typename T>
struct Point
{
	T x, y;
	Point(T x = T{}, T y = T{}) noexcept
	: x{x}
	, y{y}
	{
	}
	Point(Point const &) noexcept = default;
	Point(Point &&) noexcept = default;
	Point &operator=(Point const &) noexcept = default;
	Point &operator=(Point &&) noexcept = default;

	template<typename U>
	Point &operator*=(U const &u) noexcept
	{
		x = static_cast<T>(x*u);
		y = static_cast<T>(y*u);
		return *this;
	}
	template<typename U>
	friend Point operator*(Point const &p, U const &u) noexcept
	{
		return Point{p} *= u;
	}
	template<typename U>
	friend Point operator*(U const &u, Point const &p) noexcept
	{
		return Point{p} *= u;
	}
	template<typename U>
	Point &operator/=(U const &u) noexcept
	{
		x = static_cast<T>(x/u);
		y = static_cast<T>(y/u);
		return *this;
	}
	template<typename U>
	friend Point operator/(Point const &p, U const &u) noexcept
	{
		return Point{p} /= u;
	}
	template<typename U>
	friend Point operator/(U const &u, Point const &p) noexcept
	{
		return Point{p} /= u;
	}
	Point &operator+=(Point const &p) noexcept
	{
		x += p.x;
		y += p.y;
		return *this;
	}
	friend Point operator+(Point const &a, Point const &b) noexcept
	{
		return Point{a} += b;
	}
	Point &operator-=(Point const &p) noexcept
	{
		x -= p.x;
		y -= p.y;
		return *this;
	}
	friend Point operator-(Point const &a, Point const &b) noexcept
	{
		return Point{a} -= b;
	}

	friend bool operator==(Point const &a, Point const &b) noexcept
	{
		return std::tie(a.x, a.y) == std::tie(b.x, b.y);
	}
	friend bool operator<(Point const &a, Point const &b) noexcept
	{
		return std::tie(a.x, a.y) < std::tie(b.x, b.y);
	}

	friend std::ostream &operator<<(std::ostream &o, Point const &p) noexcept
	{
		return o << '(' << p.x << ", " << p.y << ')';
	}
};

using real_point = Point<double>;
using int_point = Point<long long>;

int_point cast(real_point const &p)
{
	return {static_cast<long long>(std::floor(p.x)), static_cast<long long>(std::floor(p.y))};
}

int main()
{
	std::size_t num_points;
	std::cin >> num_points;
	double radius;
	std::cin >> radius;

	std::mt19937 gen {std::random_device{}()};
	std::uniform_real_distribution<double> dist {-radius, radius};

	std::set<real_point> points;
	while(points.size() < num_points)
	{
		points.emplace(dist(gen), dist(gen));
	}

	std::multimap<int_point, real_point> grid;
	for(auto const &p : points)
	{
		grid.emplace(cast(p), p);
	}

	long long r_min = static_cast<long long>(std::floor(-radius*2.0));
	long long r_max = static_cast<long long>(std::ceil(radius*2.0));
	std::set<std::set<real_point>> solutions;
	auto start = std::chrono::high_resolution_clock::now();
	{
		for(auto it = std::begin(grid); it != std::end(grid); ++it)
		{
			auto const &a = it->second;
			auto jt = it;
			for(++jt; jt != std::end(grid); ++jt)
			{
				auto const &b = jt->second;
				auto slope = b - a;
				auto const abs = std::sqrt(slope.x*slope.x + slope.y*slope.y);
				slope /= abs;

				std::set<real_point> coincidences;
				coincidences.emplace(a);
				coincidences.emplace(b);
				for(auto r = r_min; r < r_max; ++r)
				{
					auto sector = grid.equal_range(cast(a + slope*r));
					for(auto kt = sector.first; kt != sector.second; ++kt)
					{
						auto const &c = kt->second;
						if(c == a || c == b)
						{
							continue;
						}
						auto slope2 = c - a;
						auto const abs2 = std::sqrt(slope2.x*slope2.x + slope2.y*slope2.y);
						slope2 /= abs2;
						slope2 -= slope;
						if(std::abs(slope2.x) < 0.0001 && std::abs(slope2.y) < 0.0001)
						{
							coincidences.emplace(c);
						}
					}
				}
				if(coincidences.size() >= 4)
				{
					solutions.emplace(std::move(coincidences));
				}
			}
		}
	}
	auto end = std::chrono::high_resolution_clock::now();
	std::chrono::duration<double> diff = end - start;
	std::cout << std::endl << "Time spent searching: " << diff.count() << 's' << std::endl;
	for(auto const &coincidences : solutions)
	{
		for(auto const &p : coincidences)
		{
			std::cout << p << " ";
		}
		std::cout << std::endl;
	}
}
