#include <iostream>
#include <cmath>
#include <vector>
#include <cstring>
#include <queue>
#include <climits>
using namespace std;
const int MAXN = 153;
double e[MAXN][MAXN],dis[MAXN][MAXN],len[MAXN];
pair<int,int> cor[MAXN];
int n,cnt;
int far[MAXN];
bool vis[MAXN],in[MAXN];
void Dijkstra(int s){
priority_queue<pair<double,int> > q;
memset(vis,0,sizeof(vis));
q.push(make_pair(0,s));
dis[s][s] = 0;
if(!in[s]) cnt++;
while(q.size()){
int x = q.top().second;
q.pop();
if(!in[x]) far[x] = cnt,in[x] = 1;
if(vis[x]) continue;
vis[x] = 1;
for(int i = 1; i <= n; i++){
if(i != x && e[x][i] != 0){
if(dis[s][i] > dis[s][x] + e[x][i]){
dis[s][i] = dis[s][x] + e[x][i];
dis[s][0] = max(dis[s][i],dis[s][0]);
if(!vis[i]) q.push(make_pair(-e[s][i],i));
}
}
}
}
}
double cal(int i,int j){
return sqrt((cor[i].first - cor[j].first) * (cor[i].first - cor[j].first) + (cor[i].second - cor[j].second) * (cor[i].second - cor[j].second));
}
int main(){
cin >> n;
double ans = 2147483647;
for(int i = 1; i <= n; i++) {
int x,y;
cin >> x >> y;
cor[i] = make_pair(x,y);
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
scanf("%1d",&e[i][j]);
if(e[i][j]) e[i][j] = cal(i,j);
}
}
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)
dis[i][j] = 2147483647;
for(int i = 1; i <= n; i++) dis[i][0] = 0;
for(int i = 1; i <= n; i++) Dijkstra(i);
for(int i = 1;i <= n; i++)
len[far[i]] = max(len[far[i]],dis[i][0]);
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
if(far[i] != far[j]){
double l = cal(i,j);
double g = max(l + dis[i][0] + dis[j][0],max(len[far[i]],len[far[j]]));
ans = min(ans,g);
}
}
}
printf("%6f",ans);
return 0;
}