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

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

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

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

i.x = b
l.r = a
l.t = k
l.s = d
e.o = m
a.o = m
d.r = e
d.t = a
d.s = l
k.o = b
h.o = i
m.x = b
b.x = m
assert i.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

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

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

i.x = b
l.r = a
l.t = k
l.s = d
e.o = m
a.o = m
d.r = e
d.t = a
d.s = l
k.o = b
h.o = i
m.x = b
b.x = m
assert i.x.x.x.x.txt == "m"