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

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

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

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

m = A("m")
d = B("d")
c = C("c")
i = D("i")
n = C("n")
e = B("e")

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

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

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

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

m = A("m")
d = B("d")
c = C("c")
i = D("i")
n = C("n")
e = B("e")

m.q = e
m.s = i
m.x = c
d.r = i
d.x = c
d.t = c
d.p = m
c.x = d
i.z = n
n.x = d
e.r = i
e.x = n
e.t = c
e.p = m
assert c.x.p.x.x.txt == "d"