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

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

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

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

b = A("b")
l = B("l")
h = C("h")
c = D("c")
n = C("n")

b.z = c
l.o = c
l.w = c
l.z = b
h.v = l
h.s = b
h.y = b
h.q = n
c.r = h
n.v = l
n.s = b
n.y = b
n.q = h
assert h.q.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

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

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

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

b = A("b")
l = B("l")
h = C("h")
c = D("c")
n = C("n")

b.z = c
l.o = c
l.w = c
l.z = b
h.v = l
h.s = b
h.y = b
h.q = n
c.r = h
n.v = l
n.s = b
n.y = b
n.q = h
assert h.q.q.v.txt == "l"