import java.util.HashSet;
import java.util.Set;

class Plex {
    protected Set<Plex> containers   = new HashSet<Plex>();
    protected Set<Plex> contents     = new HashSet<Plex>();
    protected Set<Plex> origins      = new HashSet<Plex>();
    protected Set<Plex> destinations = new HashSet<Plex>();
    public Object value;
    
    public Plex() { }
    
    public Plex(Object value) {
        this.value = value;
    }

    public void addContainer(Plex that) {
        this.containers.add(that);
        that.contents.add(this);
    }

    public void removeContainer(Plex that) {
        this.containers.remove(that);
        that.contents.remove(this);
    }

    public void addContent(Plex that) {
        this.contents.add(that);
        that.containers.add(this);
    }

    public void removeContent(Plex that) {
        this.contents.remove(that);
        that.containers.remove(this);
    }

    public void addOrigin(Plex that) {
        this.origins.add(that);
        that.destinations.add(this);
    }

    public void removeOrigin(Plex that) {
        this.origins.remove(that);
        that.destinations.remove(this);
    }

    public void addDestination(Plex that) {
        this.destinations.add(that);
        that.origins.add(this);
    }

    public void removeDestination(Plex that) {
        this.destinations.remove(that);
        that.origins.remove(this);
    }
}