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

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

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

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

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

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

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

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

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

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

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