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

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

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

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

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

k.w = b
k.y = g
g.o = b
c.z = j
b.w = j
j.z = c
assert b.w.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.y: B = None
        self.txt = txt

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

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

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

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

k.w = b
k.y = g
g.o = b
c.z = j
b.w = j
j.z = c
assert b.w.z.z.txt == "j"