#include <bits/stdc++.h>
using namespace std;
double n, x[200], y[200], g[200][200], maxl[200];
char c;
double getl(int i, int j)
{
return sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
}
int main()
{
cin >> n;
// 邻接矩阵存图
for (int i = 1; i <= n; i++)
cin >> x[i] >> y[i];
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
{
cin >> c;
if (c == '1')
g[i][j] = getl(i, j);
else
g[i][j] = 1e10;
}
// floyd求最短路
for (int k = 1; k <= n; k++)
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
if (i != j && i != k && j != k && g[i][k] < 1e10 && g[k][j] < 1e10 && g[i][j] > g[i][k] + g[k][j])
{
g[i][j] = g[i][k] + g[k][j];
}
// maxl保存所有点在图中的直径
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
if (g[i][j] != 1e10)
maxl[i] = max(maxl[i], g[i][j]);
// 假设ij连通,找最小新直径
double ans = 2e10;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
if (i != j && g[i][j] == 1e10)
{
double t = getl(i, j);
ans = min(ans, maxl[i] + maxl[j] + t);
}
for (int i = 1; i <= n; i++)
ans = max(maxl[i], ans); // 存疑,同学理解了分享给老师
printf("%.6lf", ans);
return 0;
}