var cache = {};
var family = {};

function add(parent, child){
	var p,c;
	if(parent in cache){
		p = cache[parent];
	} else { //初めての名前
		p = family[parent] = { name : parent };
		cache[parent] = p;
	}
	if(child in cache){
		p[child] = cache[child];
	} else { //初めての名前
		c = p[child] = { name : child };
		cache[child] = c;
	}
}

family_toString.tab = "  ";

function family_toString(f, tab){
	var result = "";

	if(tab == null) tab = -1;

	var indent = arguments.callee.tab.x(tab);

	for( x in f){
		if(x == "name") continue;
		else{
			result += indent + (tab < 0 ? "" : "->") + f[x].name + "\n";
			result += family_toString(f[x], tab+1);
		}
	}
	return result;
}

if(!String.prototype.x){
	String.prototype.x = function(n){
		var result="", i;
		for(i=0;i<n;i++){
			result += this;
		}
		return result;
	}
}