var coor = [];

function mian(input){
  var In = input.split(" ");
  
  for(var i = 1; i < In[0]; i++){
    var In2 = input[i].split(" ");
    coor.push(In2);
  }
  
  var data = 0;
  var x = In[0] - 1;
  for(var i = 0; i < In[0]; i++){
   if(i == x) {
     var data2 = math(i, 0, In[1]);
   } else {
     var data2 = math(i, i+1, In[1]);
   }
   
    if(data ==0){
     data = data2; 
    } else if(data > data2){
      data = data2;
    }
  }
  
  console.log(data);
}


function math(row1, row2, column){
  var s = 0;
  for (var i = 0; i < column; i++){
    var num = Math.abs(coor[row1][i] - coor[row2][i]);
    var s = s + Math.pow(num, 2);
  }
  s = Math.sqrt(s);
  return s;
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));