class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.u: D = None
        self.p: D = None
        self.q: C = None
        self.txt = txt

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

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

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

h = A("h")
l = B("l")
i = C("i")
m = D("m")
b = D("b")
c = D("c")
f = C("f")

h.w = l
h.u = b
h.p = m
h.q = f
l.y = i
l.p = c
i.t = c
i.w = c
i.p = h
i.q = m
m.u = h
b.u = h
c.u = h
f.t = m
f.p = h
f.q = c
f.w = c
assert m.u.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.u: D = None
        self.p: D = None
        self.q: C = None
        self.txt = txt

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

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

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

h = A("h")
l = B("l")
i = C("i")
m = D("m")
b = D("b")
c = D("c")
f = C("f")

h.w = l
h.u = b
h.p = m
h.q = f
l.y = i
l.p = c
i.t = c
i.w = c
i.p = h
i.q = m
m.u = h
b.u = h
c.u = h
f.t = m
f.p = h
f.q = c
f.w = c
assert m.u.q.t.txt == "m"