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

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

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

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

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

i.y = h
i.s = j
i.x = d
d.v = j
j.z = h
j.s = d
h.q = i
h.s = j
h.z = j
h.y = j
assert j.z.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.s: C = None
        self.x: B = None
        self.txt = txt

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

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

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

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

i.y = h
i.s = j
i.x = d
d.v = j
j.z = h
j.s = d
h.q = i
h.s = j
h.z = j
h.y = j
assert j.z.q.s.txt == "j"