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

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

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

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

c = A("c")
j = B("j")
k = C("k")
b = D("b")

c.u = k
c.y = b
c.p = j
j.p = b
k.z = b
b.v = j
b.q = j
b.y = j
assert c.p.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.y: D = None
        self.p: B = None
        self.txt = txt

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

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

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

c = A("c")
j = B("j")
k = C("k")
b = D("b")

c.u = k
c.y = b
c.p = j
j.p = b
k.z = b
b.v = j
b.q = j
b.y = j
assert c.p.p.y.txt == "j"