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

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

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

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

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

d.z = c
n.x = k
c.u = n
k.u = c
k.v = c
k.y = c
assert c.u.x.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

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

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

d.z = c
n.x = k
c.u = n
k.u = c
k.v = c
k.y = c
assert c.u.x.u.u.txt == "n"