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

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

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

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

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

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

j.v = h
h.o = f
h.u = j
d.o = f
d.u = j
f.o = h
f.u = j
assert h.u.v.o.u.txt == "j"