import java.io.*;
import java.util.*;
import java.lang.*;

public class LocationImages {
  Vector imgs;
  String file;

  LocationImages (String f){
    file = f;
    imgs = new Vector();
  }

  public void load (){
    StreamTokenizer st;

    try { st = new StreamTokenizer(new FileInputStream(new File(file))); }
    catch (Exception e) { return; }
    st.parseNumbers();
    st.wordChars(47,58); // : is a word character, for us
    while(true){
      double yc, xc;
      String url;

      yc = xc = -1;
      url = null;

      try {st.nextToken();} catch (Exception e) { return; }
      if(st.ttype == StreamTokenizer.TT_EOF)
        return;
      if(st.ttype == StreamTokenizer.TT_NUMBER)
        yc = (long) st.nval;

      try {st.nextToken();} catch (Exception e) { return; }
      if(st.ttype == StreamTokenizer.TT_EOF)
        return;
      if(st.ttype == StreamTokenizer.TT_NUMBER)
        xc = (long) st.nval;

      try {st.nextToken();} catch (Exception e) { return; }
      if(st.ttype == StreamTokenizer.TT_EOF)
        return;
      if(st.ttype == StreamTokenizer.TT_WORD)
        url = (String) st.sval;

      if((xc >0) && (yc > 0) && (url != null)){
	imgs.addElement(new LocImg(yc, xc, url));
      }

    }
  }

public String nearest(double y, double x) {
  Enumeration l;
  LocImg c;
  double best, distance;
  String match;

  match = "";
  best = Double.MAX_VALUE;
  l = imgs.elements();
  while(l.hasMoreElements()){
    c = (LocImg) l.nextElement();
    distance = (Math.pow((y-c.y),2)) + (Math.pow((x-c.x),2));
    if(distance < best){
      best = distance;
      match = c.url;
    }
  }
  return match;
}
}

class LocImg {
  double y, x;
  String url;

  LocImg(double yc, double xc, String u) {
    y = yc;
    x = xc;
    url = u;
  }
}

