class A:
    def __init__(self, txt: str):
        self.x: C = 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.r: B = None
        self.u: B = None
        self.txt = txt

i = A("i")
k = B("k")
h = C("h")
d = C("d")
m = C("m")
l = B("l")

i.x = d
k.o = i
h.r = l
h.u = k
d.r = l
d.u = k
m.r = l
m.u = k
l.o = i
assert l.o.x.r.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = 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.r: B = None
        self.u: B = None
        self.txt = txt

i = A("i")
k = B("k")
h = C("h")
d = C("d")
m = C("m")
l = B("l")

i.x = d
k.o = i
h.r = l
h.u = k
d.r = l
d.u = k
m.r = l
m.u = k
l.o = i
assert l.o.x.r.o.x.txt == "d"