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

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

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

m = A("m")
f = B("f")
h = C("h")
d = A("d")
n = B("n")
c = C("c")
l = A("l")
i = A("i")
a = C("a")

m.x = d
f.p = c
f.t = c
f.s = n
h.x = m
h.r = c
d.x = l
n.p = c
n.t = c
n.s = f
c.x = i
c.r = h
l.x = d
i.x = l
a.x = l
a.r = h
assert i.x.x.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.p: C = None
        self.t: C = None
        self.s: B = None
        self.txt = txt

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

m = A("m")
f = B("f")
h = C("h")
d = A("d")
n = B("n")
c = C("c")
l = A("l")
i = A("i")
a = C("a")

m.x = d
f.p = c
f.t = c
f.s = n
h.x = m
h.r = c
d.x = l
n.p = c
n.t = c
n.s = f
c.x = i
c.r = h
l.x = d
i.x = l
a.x = l
a.r = h
assert i.x.x.x.x.x.x.txt == "d"