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

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

class C:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: C = None
        self.txt = txt

b = A("b")
e = B("e")
h = C("h")
j = C("j")

b.o = j
e.x = b
h.x = j
h.y = j
j.x = h
j.y = h
assert b.o.x.y.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: C = None
        self.txt = txt

b = A("b")
e = B("e")
h = C("h")
j = C("j")

b.o = j
e.x = b
h.x = j
h.y = j
j.x = h
j.y = h
assert b.o.x.y.x.txt == "h"