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

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

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

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

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

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

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

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

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

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

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