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

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

class C:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

e = A("e")
k = B("k")
d = C("d")
b = C("b")
h = B("h")
m = B("m")

e.x = d
e.u = h
k.o = e
d.q = h
b.q = h
h.o = e
m.o = e
assert e.x.q.o.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.u: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

e = A("e")
k = B("k")
d = C("d")
b = C("b")
h = B("h")
m = B("m")

e.x = d
e.u = h
k.o = e
d.q = h
b.q = h
h.o = e
m.o = e
assert e.x.q.o.x.q.txt == "h"