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.o: A = None
        self.txt = txt

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

k.o = d
a.x = l
m.o = k
j.x = k
d.o = k
f.x = k
l.o = d
h.o = k
i.x = k
assert d.o.o.o.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.o: A = None
        self.txt = txt

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

k.o = d
a.x = l
m.o = k
j.x = k
d.o = k
f.x = k
l.o = d
h.o = k
i.x = k
assert d.o.o.o.txt == "k"