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

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

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

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

k.o = l
k.y = l
m.r = d
i.z = k
h.r = i
a.o = l
a.y = k
l.o = k
l.y = k
d.z = k
j.z = k
assert j.z.o.o.y.o.o.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.y: A = None
        self.txt = txt

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

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

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

k.o = l
k.y = l
m.r = d
i.z = k
h.r = i
a.o = l
a.y = k
l.o = k
l.y = k
d.z = k
j.z = k
assert j.z.o.o.y.o.o.o.y.txt == "l"