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

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

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

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

i = A("i")
j = B("j")
a = C("a")
c = D("c")
h = D("h")

i.w = c
i.z = a
i.y = j
j.r = c
j.x = i
a.z = h
c.x = h
c.q = h
c.w = i
c.r = i
h.x = c
h.q = c
h.w = i
h.r = i
assert a.z.q.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.z: C = None
        self.y: B = None
        self.txt = txt

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

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

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

i = A("i")
j = B("j")
a = C("a")
c = D("c")
h = D("h")

i.w = c
i.z = a
i.y = j
j.r = c
j.x = i
a.z = h
c.x = h
c.q = h
c.w = i
c.r = i
h.x = c
h.q = c
h.w = i
h.r = i
assert a.z.q.x.x.txt == "c"