class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: A = None
        self.t: B = None
        self.txt = txt

j = A("j")
l = B("l")
h = B("h")
d = B("d")

j.v = h
l.v = j
l.t = d
h.v = j
h.t = d
d.v = j
d.t = h
assert h.v.v.t.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: A = None
        self.t: B = None
        self.txt = txt

j = A("j")
l = B("l")
h = B("h")
d = B("d")

j.v = h
l.v = j
l.t = d
h.v = j
h.t = d
d.v = j
d.t = h
assert h.v.v.t.txt == "d"