class AssocListNode {
    AssocListNode next;
    double key;
    String value;

    AssocListNode(double key, String value, AssocListNode next) {
	this.key = key;
	this.value = value;
	this.next = next;
    }

    AssocListNode() {
    }
}

class AssocListPosition {
    AssocListNode position;
    boolean found;

    AssocListPosition(AssocListNode position, boolean found) {
	this.position = position;
	this.found = found;
    }
}

class AssocList {
    static AssocListPosition findPos(AssocListNode origin, double key) {
	AssocListNode current;
	for(current = origin;
	    current.next!=null;
	    current=current.next) {
	    if (current.next.key > key) {
		return new AssocListPosition(current, false);
	    } else if (current.next.key == key) {
		return new AssocListPosition(current.next, true);
	    }
	}
	return new AssocListPosition(current, false);
    }

    static AssocListPosition findPreceding(AssocListNode origin, double key) {
	for(AssocListNode current = origin;
	    current.next!=null;
	    current=current.next) {
	    if (current.next.key >= key) {
		return new AssocListPosition(current, true);
	    }
	}
	return null;
    }

    static void put(AssocListNode origin, double key, String value) {
	AssocListPosition position = findPos(origin, key);
	if (position.found) {
	    position.position.value=value;
	} else {
	    position.position.next = new AssocListNode(key, value, position.position.next);
	}
    }

    static boolean isFound(AssocListNode origin, double key) {
	return findPos(origin, key).found;
    }

    static String get(AssocListNode origin, double key) {
	AssocListPosition p = findPos(origin, key);
	if (p.found) {
	    return p.position.value;
	} else {
	    return null;
	}
    }

    static void remove(AssocListNode origin, double key) {
	AssocListPosition p = findPreceding(origin, key);
	if(p != null && p.position.next.key == key) {
	    p.position.next = p.position.next.next;
	}
    }

    static int length(AssocListNode origin) {
	int count=0;
	for(AssocListNode current=origin.next;
	    current != null;
	    current = current.next) {
	    count++;
	}
	return count;
    }
}

