#include<iostream>
#include<set>
#include<vector>
#include<queue>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
#define endl '\n'
#define INF 0x3f3f3f3f
typedef long long LL;
typedef pair<int, int>PII;
typedef unsigned long long ULL;
const int N = 1e2+10;
const int mod = 998244353;
double eps = 1e-9;
double f[N][N][N],mnx[N],mny[N];
PII pre[N][N][N];
int mnxY[N], mnyX[N];
int X[N], Y[N];
double dist(int x0,int y0,int x1,int y1)
{
return sqrt((x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1));
}
struct P {
int o, x, y;
};
void solve()
{
int n, t;
cin >> n >> t;
int sx, sy, tx, ty;
cin >> sx >> sy >> tx >> ty;
for (int i = 1; i <= n; i++)
cin >> X[i] >> Y[i];
for (int i = 0; i <= 100; i++)
{
mnx[i] = mny[i] = 1e9;
}
for (int i = 0; i <= 100; i++)
for (int j = 0; j <= 100; j++)
{
f[0][i][j] = dist(sx, sy, i, j);
pre[0][i][j] = { sx,sy };
// cout << i << ' ' << j << ' '<< f[0][i][j] << endl;
if (f[0][i][j] < mnx[i])
mnx[i] = f[0][i][j], mnxY[i] = j;
if(f[0][i][j]<mny[j])
mny[j] = f[0][i][j],mnyX[j]=i;
}
for (int i = 1; i <= n; i++)
{
for (int x = 0; x <= 100; x++)
{
for (int y = 0; y <= 100; y++)
{
double temp= t + min(mnx[X[i]], mny[Y[i]]) + min(fabs(x - X[i]), fabs(y - Y[i]));
f[i][x][y] = min(f[i - 1][x][y],temp);
if (f[i - 1][x][y] <= temp)
{
pre[i][x][y] = pre[i - 1][x][y];
}
else
{
if (mnx[X[i]] < mny[Y[i]])
{
pre[i][x][y] = { X[i],mnxY[X[i]] };
}
else
pre[i][x][y] = { mnyX[Y[i]],Y[i] };
}
}
}
for (int x = 0; x <= 100; x++)
for (int y = 0; y <= 100; y++)
{
if (f[i][x][y] < mnx[x])
mnx[x] = f[i][x][y], mnxY[x] = y;
if (f[i][x][y] < mny[y])
mny[y] = f[i][x][y], mnyX[y] = x;
}
}
cout << f[n][tx][ty] << endl;
vector<P>ans;
for (int i = n; i; i--)
{
if (fabs(f[i][tx][ty] - f[i - 1][tx][ty]) < eps)
{
continue;
}
ans.push_back({ 0,tx,ty });
int ttx = tx, tty = ty;
if (fabs(tx - X[i]) < fabs(ty - Y[i]))
ttx = X[i];
else
tty = Y[i];
ans.push_back({ i,ttx,tty });
ttx = tx, tty = ty;
tx = pre[i][ttx][tty].first;
ty = pre[i][ttx][tty].second;
}
ans.push_back({ 0,tx,ty });
cout << ans.size() << endl;
reverse(ans.begin(), ans.end());
for (auto& [i, x, y] : ans)
cout << i << ' ' << x << ' ' << y << endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T;
T = 1;
while (T--)
solve();
}