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

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

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

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

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

b.y = j
h.v = b
h.q = b
h.o = b
h.z = j
j.w = h
j.s = b
i.r = b
i.z = b
i.w = h
assert j.w.q.y.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

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

b.y = j
h.v = b
h.q = b
h.o = b
h.z = j
j.w = h
j.s = b
i.r = b
i.z = b
i.w = h
assert j.w.q.y.s.txt == "b"