class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.q: B = None
        self.p: D = None
        self.z: D = None
        self.txt = txt

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

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

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

c = A("c")
d = B("d")
f = C("f")
h = D("h")
k = C("k")
m = A("m")
i = C("i")
e = D("e")

c.t = k
c.q = d
c.p = e
c.z = e
d.s = c
f.s = d
f.t = d
f.z = i
f.p = h
h.r = c
k.s = d
k.t = d
k.z = f
k.p = e
m.t = k
m.q = d
m.p = h
m.z = h
i.s = d
i.t = d
i.z = f
i.p = e
e.r = c
assert m.q.s.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.q: B = None
        self.p: D = None
        self.z: D = None
        self.txt = txt

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

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

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

c = A("c")
d = B("d")
f = C("f")
h = D("h")
k = C("k")
m = A("m")
i = C("i")
e = D("e")

c.t = k
c.q = d
c.p = e
c.z = e
d.s = c
f.s = d
f.t = d
f.z = i
f.p = h
h.r = c
k.s = d
k.t = d
k.z = f
k.p = e
m.t = k
m.q = d
m.p = h
m.z = h
i.s = d
i.t = d
i.z = f
i.p = e
e.r = c
assert m.q.s.p.r.txt == "c"