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

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

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

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

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

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

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

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

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

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

c.z = d
c.p = d
c.t = m
m.q = n
d.v = n
n.x = m
n.v = d
n.p = c
assert n.p.t.q.txt == "n"