class A:
    def __init__(self, txt: str):
        self.q: B = 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.o: B = None
        self.txt = txt

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

e.q = h
h.x = e
i.o = h
j.o = h
assert h.x.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = 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.o: B = None
        self.txt = txt

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

e.q = h
h.x = e
i.o = h
j.o = h
assert h.x.q.x.txt == "e"