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

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

e = A("e")
j = B("j")
h = B("h")
c = A("c")

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

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

e = A("e")
j = B("j")
h = B("h")
c = A("c")

e.v = h
j.u = e
j.o = h
h.u = c
h.o = j
c.v = j
assert h.o.o.o.txt == "j"