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

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

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

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

d = A("d")
b = B("b")
h = C("h")
l = D("l")

d.z = h
d.q = b
b.y = l
h.v = l
l.v = h
assert h.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.q: B = None
        self.txt = txt

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

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

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

d = A("d")
b = B("b")
h = C("h")
l = D("l")

d.z = h
d.q = b
b.y = l
h.v = l
l.v = h
assert h.v.v.v.txt == "l"