class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.w: C = None
        self.o: D = None
        self.x: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: A = None
        self.w: A = None
        self.txt = txt

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

c.u = j
c.w = j
c.o = i
c.x = i
b.z = j
b.x = c
b.p = c
j.x = b
j.w = c
i.x = j
i.y = c
i.w = c
assert c.w.x.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.w: C = None
        self.o: D = None
        self.x: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: A = None
        self.w: A = None
        self.txt = txt

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

c.u = j
c.w = j
c.o = i
c.x = i
b.z = j
b.x = c
b.p = c
j.x = b
j.w = c
i.x = j
i.y = c
i.w = c
assert c.w.x.z.w.txt == "c"