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

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

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

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

l = A("l")
e = B("e")
i = C("i")
h = D("h")

l.t = e
l.r = e
e.w = i
e.z = h
i.z = l
i.r = h
i.q = h
h.w = i
assert i.r.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.r: B = None
        self.txt = txt

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

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

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

l = A("l")
e = B("e")
i = C("i")
h = D("h")

l.t = e
l.r = e
e.w = i
e.z = h
i.z = l
i.r = h
i.q = h
h.w = i
assert i.r.w.q.txt == "h"